User defined table types in Oracle -


first of working mssql. have stored procedure in mssql, need use in oracle , since absolutely new oracle have no idea @ how correct.

i needed use user defined table types in ms sql stored procedure because using "logical" tables in stored procedure, need pass them dynamic sql statement within procedure (using column names of "physical" tables variables/parameters).

i've started add oracle function in package made before function. looks like

type resultrec record (    [result columns]  );  type resulttable table of resultrec;  function myfunctionname([a lot parameters]) return resulttable pipelined; 

i described layout of tables (the user defined table types in mssql), want use within function in package header. far good, don't know have declare table variables or user defined table types. tried put them in package header, if trying use these tables in package body, describing function, oracle tells met, table or view not exist. tried describe tables within package body or in block of function, looks that:

function myfunctionname (    [myparameters] ) return resulttable pipelined rec resultrec;  type tablevariablea table of tablereca; type tablevariableb table of tablerecb;  begin    insert tablevariablea   select columna, columnb physicaltable where[...];    [a lot more do...] end; 

but in case oracle tells me, doesn't know table or view. tried few more things, @ end wasn't able tell oracle table should use... appreciate every hint, helps me understand how oracle works in case. lot!

you can't insert collection (e.g. pl/sql table). can use bulk collect syntax populate collection:

select columna, columnb bulk collect tablevariablea physicaltable [...]; 

however, might want check appropriate approach, since sql server , oracle differ quite bit. can't use pl/sql tables in plain sql (at least prior 12c), inside procedure, might need schema-level type rather pl/sql type, depends next. might not want collection @ all. trying convert t-sql straight pl/sql without understanding differences lead down wrong path - make sure understand actual requirement , find best oracle mechanism that.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -