PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 6, 2022

[FIXED] How to open custom type from plsql on php?

 December 06, 2022     database, oci8, oracle, php, plsql     No comments   

Issue

I have created a type on Oracle

CREATE OR REPLACE TYPE  myType as object (
id number,rol varchar(16) );​

Then I have this function that returns an object of type myType

create or replace FUNCTION myFunction(...) RETURN myType IS
.... 
END;

On plsql I can access the attributes of the returned object just doing this:

var := myFunction(...);
dbms_output.put_line(var.rol);

But how can I have access to the object attributes from php using OCI8


Solution

First create a type of that object to be able to return it as a table.

CREATE TYPE tableType AS TABLE OF myType

Then, using Oracle's table() function you can handle the output as a normal select on PHP

select *
from   table(myFunction(...))

simple, huh? :)

(edited as requested for completeness)



Answered By - winkbrace
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing