function table
Hi experts
I want to know how to create a table function that returns the Recordset (empno, ename, sal + comm) of the emp table
I know that this can be done with simple SQL, but I want to learn to write the table function.
And how to call this function from another sql table.
Please help me...
The sample data is data.
EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
7369 SMITH COMMITTED 7902 17 DECEMBER 80 800 100 20
7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
Table function returns a collection of lines (a nested table or varray). You can choose from this collection, as if it were a database table by calling the function table inside of the TABLE
clause in a SELECT
statement. However, the use of the results of the function table based on table producing the entire collection (and remember, the collection is stored in memory) and then sending it only to the SQL statement. Table function in pipeline using PIPE ROW to route the data to the SQL statement as part of collection is produced. This SQL statement way working on this element table in function transformation pipeline while working to produce the next item in the collection. This improves performance and reduces the memory usage which can be even more important when the function produces collections of great footpring. RTFM in pipeline and functions using parallel Tableanyway.
SY.
Tags: Database
Similar Questions
-
Hi all
I am using Oracle 11g
I want to know in order to learn
What is the CURSOR in the function table.
What is its usefulness
Can someone explain to me.
SELECT x.*
(TABLE (package1.function1)
CURSOR (SELECT
t.*
OF test1 t))) x
Thank you
What is the CURSOR in the function table.
What is its usefulness
Can someone explain to me.
SELECT x.*
(TABLE (package1.function1)
CURSOR (SELECT
t.*
OF test1 t))) x
This slider is NOT 'in the function table. It is in the call to YOUR function named "packagae1.function1" and the function returns a collection. If it is the result of the collection of YOUR function call which is 'in the function table.
Your probable function takes a REF CURSOR as a parameter, so the code above uses the CURSOR operator to create a cursor from a subquery.
Your function then returns a collection and SCOREBOARD operator is used to make this collection available in SQL.
See FUNCTIONS TABLE in the Oracle documentation. A simple search for 'oracle 11g table function' returns the Oracle doc as the FIRST result listed:
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htm
This chapter describes the functions of table
. . .
Overview of the functions of table
Table functions are producing a set of lines (a nested table or a varray) that can be queried as a physical database table. You use a function table as the name of a database table, in the
FROM
clause of a query.A table function can take a set of input lines. A parameter of the input collection can be of a collection type or a
REF CURSOR
.. . .
Look at the examples 5-13 and 13-6, because they show the code for your EXACT example:
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htm#CIHEGADE
. . .
Example 13-6 How to use a function Table in pipeline with REF CURSOR Arguments
SELECT * FROM TABLE(StockPivot(CURSOR(SELECT * FROM StockTable)));
In the previous query, the function table in pipeline
StockPivot
retrieves the lines of theCURSOR
subquerySELECT * FROM StockTable
, performs the transformation and channels the results to the user in the form of table. The function produces two lines of output for each input line (items in the collection).Note that when a
CURSOR
subquery went from SQL for aREF CURSOR
argument of function as in the previous example, the referenced cursor is already open when the function begins to run.As the doc example, as in your example, a subquery of CURSOR to create a cursor to be used as a function parameter. Example 13 - 5 has the actual code for the function.
The documentation is your FRY - don't be afraid to use it.
If you try to learn something a good question to ask on the forums is: where can I get more information about the functions of the table (or other topic).
Then, we can direct you to the Oracle documentation that covers this topic.
-
Hello
I read conflicting information about the return type that has a table function must or may use.
First, I am a student of a book that says:
Function in pipeline returns the data types:
The main constraint for the pipeline functions, it is the return type must be a collection type autonomous which can be used in SQL - i.e. a VARRAY or table nested.
and then in the next sentence...
More precisely a pipeline function can return the following:
A stand-alone nested table or VARRAY, defined at the schema level.
A nested table or VARRAY that has been declared in a package type.
This seems to go against the first quoted sentence.
Now, before reading the above text I had done just my own test to see if a packed type would work because I thought I had read somewhere that it would not, and he does not (the test code and this output is at the end of this question). When I arrived in the text above, after my test, so I was naturally confused.
So, I'm going to PL/SQL reference that says:
RETURN data type
The data type of the value returned by a function table in pipeline must be a type collection defined either at the level of schema or within a package (therefore, it cannot be a type of associative array).
I tried to call a function that returns a collection of VARRAY type packaged in both SQL and PL/SQL (of course below is SQL all in any case) and no work.
Now I'm wondering what is a TABLE function must use a schema type and a function table in pipeline can use a packaged type? I see that I created and called a function table but examples of Oracle see the creation and use of a function table in pipeline.
Edit: I should add that I read the following sentence in the SF book on p609 in * table functions: "this type of nested table must be defined as an element of level diagram, because the SQL engine must be able to resolve a reference to a collection of this kind."
So that it begins to resemble table functions should return a schema type and pipelined table functions, perhaps because that they don't in fact return a collection, rather they return (RowSource) content, can use the schema types or types of packages. Is this correct?
Can someone clarify this for me please?
Thank you in advance,
J
CREATE OR REPLACE PACKAGE PKGP28M
VAT-type is varray (5) number;
END;
/
DISPLAY ERRORS
create or replace type VAT is varray (5) number;
/
display errors
create or replace function tabfunc1 return pkgp28m.vat as
numtab pkgp28m.vat:=pkgp28m.vat();
Start
numtab.extend (5);
because loop me in 1.5
numtab (i): = trunc (dbms_random. Value (1.5));
end loop;
Return numtab;
end;
/
display errors
create or replace function tabfunc2 as return VAT
numtab vat:=vat().
Start
numtab.extend (5);
because loop me in 1.5
numtab (i): = trunc (dbms_random. Value (1.5));
end loop;
Return numtab;
end;
/
display errors
exec dbms_output.put_line (' call tabfunc1 (returns the packaged type) :');)
Select * from table (tabfunc1)
/
exec dbms_output.put_line (' call tabfunc2 (returns the type of schema) :');)
Select * from table (tabfunc2)
/
declare
RC sys_refcursor;
number of v;
Start
dbms_output.put_line (' in anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type) :');)
Open rc to select table column_value (tabfunc1);
loop
extract the rc in v;
When the output rc % notfound;
dbms_output.put_line (' > ' | to_char (v));
end loop;
close the rc;
end;
/
declare
RC sys_refcursor;
number of v;
Start
dbms_output.put_line (' in anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema) :');)
Open rc to select table column_value (tabfunc2);
loop
extract the rc in v;
When the output rc % notfound;
dbms_output.put_line (' > ' | to_char (v));
end loop;
close the rc;
end;
/
Scott@ORCL > @C:\Users\J\Documents\SQL\test29.sql
Package created.
No errors.
Type of creation.
No errors.
The function is created.
No errors.
The function is created.
No errors.
the call of tabfunc1 (returns the packaged type):
PL/SQL procedure successfully completed.
Select * from table (tabfunc1)
*
ERROR on line 1:
ORA-00902: invalid data type
the call of tabfunc2 (returns the type of schema):
PL/SQL procedure successfully completed.
COLUMN_VALUE
------------
1
4
1
1
3
In anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type):
declare
*
ERROR on line 1:
ORA-00902: invalid data type
ORA-06512: at line 6
In anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema):
> 1
> 2
> 4
> 2
> 3
PL/SQL procedure successfully completed.
Post edited by: Jason_942375
But the compilation of the PIPELINED WILL CREATE the schematic function types automatically. And the TABLE function, applied to the PIPELINED function, use these types of hidden patterns.
-
How to model a view based on a function table
Hello
I want to model a view in SQL Developer Data Modeler which is based on a function of painting as:
table (function (a, b))
When the function is a function table in pipeline. How is that possible?
DM 3.3.0.734 SQL version
Best regards
JoopHello
In the Properties dialog box of the view that is displayed when you create the view, you can select the Report Builder queries (on the general page) button.
In the query designer, you can enter the query text in the box above the buttons OK and apply, cancel, for example
SELECT * FROM TABLE (FUNCTION (a, b))David
-
How do I get the output of a function table
Hi all
Kindly share your idea.
I need the outputs of a function table only.
Database version: oracle 10.1.0.2.0
login_details:
login_id branch_code
admin 1
Admin1 2
Test 1
user 1
I need output for the query function below.
Select login_id from login_details where branch_code = '1';
If I create a function:
FUNCTION to CREATE or REPLACE fn_get_login (pvBranch varchar2)
IS BACK SYS_REFCURSOR
REF_TEST SYS_REFCURSOR;
BEGIN
OPEN FOR REF_TEST
Login_id SELECT FROM login_details WHERE branch_code = pvBranch;
RETURN REF_TEST;
END;
/
Select * from login_master where login_id in (select fn_get_login('01') from double);
and get
ORA-00932: inconsistent data types: expected - got CURSER
Edited by: 887268 October 8, 2012 12:25You cannot use a Ref cursor in a table, because it isn't a result set of data, it's just a pointer to a request for enforcement.
{: identifier of the thread = 886365}
A ref cursor must be used if you want to refer the request to an external application.
Transfer data back to a function is to use a pipeline for example function
SQL> CREATE OR REPLACE TYPE num_descript AS OBJECT(num number, descript varchar2(30)) 2 / Type created. SQL> SQL> CREATE OR REPLACE TYPE tbl_num_descript AS TABLE OF num_descript 2 / Type created. SQL> SQL> SQL> CREATE OR REPLACE PACKAGE reftest AS 2 FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED; 3 END; 4 / Package created. SQL> SQL> CREATE OR REPLACE PACKAGE BODY reftest AS 2 FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED IS 3 v_obj num_descript := num_descript(NULL,NULL); 4 v_rc sys_refcursor; 5 BEGIN 6 IF p_choice = 1 THEN 7 OPEN v_rc FOR SELECT empno as num, ename as descript FROM emp; 8 ELSIF p_choice = 2 THEN 9 OPEN v_rc FOR SELECT deptno as num, dname as descript FROM dept; 10 END IF; 11 LOOP 12 FETCH v_rc INTO v_obj.num, v_obj.descript; 13 EXIT WHEN v_rc%NOTFOUND; 14 PIPE ROW(v_obj); 15 END LOOP; 16 CLOSE v_rc; 17 RETURN; 18 END; 19 END; 20 / Package body created. SQL> select * from table(reftest.pipedata(1)); NUM DESCRIPT ---------- ------------------------------ 7369 SMITH 7499 ALLEN 7521 WARD 7566 JONES 7654 MARTIN 7698 BLAKE 7782 CLARK 7788 SCOTT 7839 KING 7844 TURNER 7876 ADAMS 7900 JAMES 7902 FORD 7934 MILLER 14 rows selected. SQL> select * from table(reftest.pipedata(2)); NUM DESCRIPT ---------- ------------------------------ 10 ACCOUNTING 20 RESEARCH 30 SALES 40 OPERATIONS SQL>
but of course, it is wise to just use pure SQL that in order to mix the PL/SQL in queries in the form of best performance features.
Perhaps explain what problem you are trying to solve when trying to use a function, and we can advise you on the best options.
-
How can I call a function table in pipeline via DB link?
I am using a function table in pipeline defined in a remote DB (DB_A) of my DB in local (DB_B) via a link DB (DB_A_REMOTE).
The function table in pipeline is defined in a package with all the specifications of type he needs and works very well when she is called locally but when called it remotely fails
Here is an example configuration in DB_A:
In DB_B, I have the following configuration:connect scott/tiger create or replace package pkg as type rec is record ( dte date ); type rec_set is table of rec; function dts(p_eff_date date) return rec_set pipelined; function dt(p_eff_date date) return date; end; / create or replace PACKAGE BODY pkg AS function dts(p_eff_date date) return rec_set pipelined AS r rec; BEGIN r.dte := p_eff_date; pipe row(r); r.dte := r.dte+1; pipe row(r); RETURN; END dts; function dt(p_eff_date date) return date as begin return p_eff_date; end; END pkg; /
In DB_A, I can access the two PKG functions very wellcreate database link DB_A_REMOTE connect to Scott identified by tiger using 'DB_A'; create or replace synonym RPKG for PKG@DB_A_REMOTE;
However, in DB_B the I get the following:SQL> select pkg.dt(sysdate) from dual DJ.DT(SYSDATE) ---------------------- 21-SEP-2012 11:26:31 SQL> select * from table(pkg.dts(sysdate)) DTE ---------------------- 21-SEP-2012 11:26:31 22-SEP-2012 11:26:31 23-SEP-2012 11:26:31 24-SEP-2012 11:26:31
selection rpkg.dt shows I can get to the remote package and run functions in it, but the second line is where my problem.SQL> select rpkg.dt(sysdate) from dual RPKG.DT(SYSDATE) ---------------------- 21-SEP-2012 11:29:05 SQL> select * from table(rpkg.dts(sysdate)) Error starting at line 2 in command: select * from table(rpkg.dts(sysdate)) Error at Command Line:2 Column:20 Error report: SQL Error: ORA-06553: PLS-752: Table function DTS is in an inconsistent state. 06553. 00000 - "PLS-%s: %s" *Cause: *Action:
Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?
Published by: Sentinel on September 21, 2012 11:35Go! You have posted more than 1,000 times and know that you must provide your Oracle version 4-digit.
>
Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?
>
You can't - it is not supported.See the note under the PIPELINED clause in the declaration section of the definition of the doc of PL/SQL and function
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/function.htm
>
Note:You cannot run a function table in pipeline over a database link. The reason is that the return type of a function table in pipeline is a SQL type defined by the user, which can be used in a single database (as explained in the Guide of the Oracle object-relational database developer). Although the return type of a function table in pipeline may appear as a PL/SQL type, the database actually converts this PL/SQL type to a type defined by the corresponding SQL user.
>
Your code using PL/SQL types for these types are implicitly converted to the SQL type needed to access the service using SQL. But the SQL types have an OID (object ID) which is not recognized on the other server so that the other server is unable to create the appropriate type.If you click on the link provided to the other doc in this note, you will see that even though you can create a type and specify an OID you still won't be able to use it as you wish.
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11822/adobjbas.htm#ADOBJ7083
>
Restriction on the use of Types defined by the user with a remote databaseObjects or user-defined types (specifically, types declared with a SQL CREATE TYPE statement, as opposed to types declared in a PL/SQL package) are currently only useful in a single database. Oracle database limits the use of a link of database as follows:
Unable to connect to a remote database for select, insert, or update a type defined by the user or a REF object on a remote table.
You can use the CREATE TYPE statement with the Optional keyword OID to create an object identifier specified by the user (OID) that allows an object type for use in multiple databases. See the discussion on the attribution of an OID for a type of object in Oracle Database Data Cartridge Developer's Guide.
You cannot use the links from the database of the PL/SQL code to declare a local variable of a type defined by the remote user.
You cannot pass an argument value or return of type user defined in a PL/SQL remote procedure call.
-
Hello people,
I just want to know why I can't use indexed tables in the table as return type functions. For example when I write "pls_integer index" at the end of the holder_t code, table function does not work. I would like to know why? What are the differences?
create or replace
package my_pack
is
type holder_t is table of Hello % rowtype;
/ * When I type this table like this, type holder_t is table of the Hello % rowtype index by pls_integer; table function does not work * /.
type ref_cur_t is ref cursor
Hello return % rowtype;
end;
create or replace
function pipeline (SLEEP my_pack.ref_cur_t)
parallel_enable my_pack.holder_t return pipeline (partition SLEEP by any)
is
my_row Hello % rowtype;
holder hello_o: = hello_o (null, null);
Start
loop
When the exit SLEEP % notfound;
extract SLEEP them in my_row;
Holder.a: = my_row.a;
Holder.b: = my_row.b;
course of action (my_row);
end loop;
Close SLEEP;
return;
end;
Thank you.Polat says:
OK, but what are the differences with the type holder_t is table of Hello % rowtype and type holder_t table with % rowtype index by pls_integer Hello? I mean both of them are table, but if I then use as return type it gives an error, I am trying to understand this?Difference is
type holder_t is table of hello%rowtype index by pls_integer;
Is an associative array. Similar to a hash table. This is only one type of PL/SQL, SQL cannot be used.
This
type holder_t is table of hello%rowtype;
Is a nested table, similar to a set (or bag). This can be used in SQL, too.
Looking at the docs for functions in pipeline, type that see you back:
The data type of the value returned by a function table in pipeline must be a collection type defined at the schema or within a packet level (therefore, it cannot be a type of associative array).
The elements of the collection type should be given SQL type, not data types supported only by the PL/SQL (for example PLS_INTEGER and BOOLEAN).Looking for all ther son you have on this topic, you should certainly read and try under rest three different collection types offered:
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#LNPLS00501Concerning
Peter -
CREATE TABLE TXN ( SYS_ID NUMBER, TXN_CODE VARCHAR2(12), TXN_NO NUMBER ); SELECT SYS_ID,TXN_CODE, TXN_NO FROM TXN ORDER BY 1 CREATE OR REPLACE TYPE TXN AS OBJECT ( SYS_ID NUMBER(12), TXN_CODE VARCHAR2(12), TXN_NO NUMBER, ) CREATE OR REPLACE TYPE TXN_DATA AS TABLE OF TXN CREATE OR REPLACE PACKAGE PKG AS FUNCTION TXN(SYS_ID NUMBER) RETURN TXN_DATA PIPELINED; END; CREATE OR REPLACE PACKAGE BODY PKG AS FUNCTION TXN RETURN TXN_DATA PIPELINED IS BEGIN FOR I IN 1..NVL(SYS_ID,999999999) LOOP PIPE ROW(TXN(SYS_ID)); END LOOP; RETURN; END; END; I am getting the following errors while executing the package.. PLS-00201: Indentifier SYS_ID must be declared PLS-00323: subprogram or cursor TXN is declared in a package specification and must be defined in the package body Kindly suggest the solution ? Sanjay
user12957777 wrote:
I want to use the Pipelined function to write a single line instead of complex query query.Evil. This is done by using views. Tables not channelled burst.
The latter is mainly used for the transformation of data. Unfortunately, it seems to serve often stupid hacks. Hacks which decrease only scalability performance and limits.
Be very sure of the way in which a function table of pipeline works and what are its benefits, before using it.
-
Function table in pipeline and the key-preservation - (ORA-01779)
Hey oraclers,
If I had to use a function table in the pipeline to cover complex application logic, I rarely update a subset of...
(simplified example)
But when I try...create type derived_t as object ( key integer, value varchar2(100) ); create type derived_tc as table of result_t; create or replace function new_derivations( p_param varchar2 ) return derived_tc pipelined is l_derived derived_t; begin loop /* do stuff here */ ..... pipe row( l_derived ); end loop; return; end; / create table derivations as ( key integer primary key, value varchar2(100) ); insert into derivations select t.* from table( cast( new_derivations( 'test' ) as derived_tc ) ) t;
I get ORA-01779: cannot modify a column that is mapped to a table not preserved key...update ( select d.rowid, d.key, d.value, t.value new_value from derivations d, table( cast( new_derivations( 'test' ) as derived_tc ) ) t where d.key = t.key and d.key between :low_key and :high_key ) set value = new_value;
OK... so reading around us need to be able to tell Oracle that each row in the result set view is preserved key - the 'key' of derivations from the table column and the column "key" to the result of the function in the pipeline are unique (and compatible).
Is it possible to hint Oracle (11.2.0.2.0 on Windows) to achieve this?
Thanks muchly,.
Lachlan PittsYou can rewrite this kind of update in a MERGE statement statement, which I think does not suffer the problem you are experiencing:
merge into derivations d using (select t.key, t.value new_value from table( cast( new_derivations( 'test' ) as derived_tc ) ) t) s on (d.key = s.key and d.key between :low_key and :high_key) when matched then update set d.value = t.new_value
(Not checked for syntax errors)
You can also watch this:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:760068400346785797Published by: Toon Koppelaars February 8, 2011 05:40
-
Global functional table uses 2 x initialized space?
I had a thread going on the reduction of the memory allocation on our LabView RT system located here for reference http://forums.ni.com/ni/board/message?board.id=170&thread.id=413552 .
I use a global functional / Action engine to add to a U32 table that I'll be back to our FPGA PXI via DMA reads cards. In order to keep the determinism, for the first time this table through the AE to its maximum size (18Million). During my debugging process, I decided to run the 'Performance and Memory '. When I put the number of elements to initialize to 18,000,000 I expect the performance tool to show me that this VI takes over 18 000 000 * 4 bytes = 72Mbyte. However, after this VI running by clicking on the button instant I see this VI meet twice as many 144Mbyte, extactly!
Then I ran the tool to 'See the distributions of buffer' and with 'Tables' checked, I see a black dot on the table to initialize primitive and a black point on the passage of the leftmost register. By clicking on the button "help" in this tool I see it say under the table section "to avoid abuse of global and local variables when working with arrays. Reading of a global or local variable causes LabVIEW to generate a copy of the data. "This must be what happens now, but how am I supposed to store these data with the flexibility of an adverse event and do not have an extra copy floating around?
Here is the part pertient EI for your reference:
Hello
When you use the function "Initialize the array", you create an additional table. Use the function "Remodeler Array" reuse the already existing table. See attachment.
-
Hello
I want to create a table of contents in my E-Learning-project because the automatically generated TOC of Adobe Captivate 7 includes all the features I need to check for example chapters which are the groups in the film strip.
I use master slides in my project.
The table of contents, I need must be designed and programmed as follows:1 intro / title slides
9 chapters
The progress of the work - 3 status - all chapters should be moved by symbols in the table of contents
Symbol 1: chapter has not yet begun (just an empty box)
Side 2: chapter is work in progress (a square with a green triangle inside)
Side 3: chapter is finished that means that all of the slides in this chapter are read (the square is filled with a green square)All the chapters and Points to the table of contents must be clickable (links) maybe with a mouse over effect (change in colour of mouse) and should start to the first slide of this chapter.
The chapter which is open must be written in bold with one blue color, others who are not open to be written in the normal font with a black color
I think it's a little complex, but solutionable.
I think I need to create three symbols of the buttons form, advanced actions that tend to fade and fade out named symbols.
Is there someone who can describe the process of creation? Where should I place all the functions, actions and so on? On the slide master?
Thank you for the answers!
The only thing I can say about it is that I build it in Flash, so it could be dynamic and reusable.
If you take the time to build a PC inside it only works for one project. Certainly you would have a base to work from, but for a another edition project wouldn't be fun.
If you need HTML5, I think it would be much more difficult to build a dynamic table of contents.
-
Select local (tmp) Table in function->; Table not found
Hello
I want to create a cursor that selects from a Table that does not exist in the database.
I have create this table in local table (what is that called? nested table?).
Not shown in the code but I want to fill this local array later.
After completing my cursor is going to use this full table.
When trying to launch I get the error Table or view does not exist in the 'FROM T1 TempTab_var;"my slider.
This is my simplified code:
CREATE OR REPLACE FUNCTION PC_RL_MTA_PMT RETURN PC_RL_MTA_TYPE_PMT IS result_out PC_RL_MTA_TYPE_PMT; TYPE TempTab_record_type IS RECORD (ID int); TYPE TempTab_type IS TABLE OF TempTab_record_type INDEX BY BINARY_INTEGER; TempTab_var TempTab_type; CURSOR TempCursor3_var IS SELECT ID AS ID_var FROM TempTab_var T1; BEGIN RETURN result_out; END PC_RL_MTA_PMT;
Any ideas what is wrong?
Thank you very much in advance.
And another example of my library of examples, just for you troubleshoot...
SQL > CREATE or REPLACE TYPE AS OBJECT num_descript (num number, descript varchar2 (30))
2.Type of creation.
SQL > CREATE or REPLACE TYPE tbl_num_descript AS TABLE OF THE num_descript
2.Type of creation.
SQL > CREATE or REPLACE PACKAGE AS-reftest
2 FUNCTION pipedata (number p_choice) tbl_num_descript RETURN PIPELINED;
3 END;
4.Package created.
SQL > CREATE or REPLACE PACKAGE BODY AS-reftest
2 FUNCTION pipedata (number p_choice) tbl_num_descript RETURN PIPELINED IS
3 v_obj num_descript: = num_descript (NULL, NULL);
4 v_rc sys_refcursor;
5 BEGIN
6. IF p_choice = 1 THEN
7 v_rc OPEN to SELECT empno as num, ename like descript FROM emp;
8 ELSIF p_choice = 2 THEN
9 OPEN v_rc to SELECT deptno as num, dname as descript OF THE Department;
10 END IF;
11 LOOP
12 FETCH v_rc INTO v_obj.num, v_obj.descript;
EXIT 13 WHEN v_rc % NOTFOUND;
14 PIPE ROW (v_obj);
15 END LOOP;
16 v_rc NARROW;
RETURN 17;
18 END;
END 19;
20.Package body created.
SQL > select * from table (reftest.pipedata (1));
DESCRIPT NUM
---------- ------------------------------
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
KING 7839
7844 TURNER
7876 ADAMS
JAMES 7900
7902 FORD
7934 MILLER14 selected lines.
SQL > select * from table (reftest.pipedata (2));
DESCRIPT NUM
---------- ------------------------------
10 ACCOUNTING
SEARCH 20
30 SALES
40 OPERATIONS -
Question about function table in pipeline
I did an object:
Then I did an object table:CREATE TYPE FML_DAT_ITEMS_OBJ AS OBJECT ("F0" varchar2(4000), ...
Everything is fine!create or replace type fml_dat_items_ftab is table of FML_DAT_ITEMS_OBJ
Now, I want to do the function pipeline:
Published by: Walter on 14.05.2013 05:29create or replace FUNCTION get_fml_items_dat (pfml_nr in number) return fml_dat_items_ftab pipelined as out_rec FML_DAT_ITEMS_OBJ := FML_DAT_ITEMS_OBJ() ; begin select item_dat into out_rec."F0" from fml_dat_items where fml_nr = pfml_nr and item_nr= 0.00; pipe row (????); -- HOW can I pipe the object to the function result set?
Hello
Try this:
create or replace type FML_DAT_ITEMS_OBJ AS OBJECT ( f_name varchar2(20) ,l_name varchar2(20) ) ; create or replace type fml_dat_items_ftab as table of FML_DAT_ITEMS_OBJ ; select * from table(fml_dat_items_ftab(FML_DAT_ITEMS_OBJ('peter', 'zwan') ,FML_DAT_ITEMS_OBJ('peter', 'zwan') ) ) ; F_NAME L_NAME -------------------- -------------------- peter zwan peter zwan create or replace FUNCTION get_fml_items_dat (pfml_nr in number) return fml_dat_items_ftab pipelined as -- out_rec FML_DAT_ITEMS_OBJ := FML_DAT_ITEMS_OBJ() ; out_rec FML_DAT_ITEMS_OBJ ; begin select FML_DAT_ITEMS_OBJ('peter', 'zwan') into out_rec from dual; for i in 1 .. pfml_nr loop pipe row (out_rec); end loop; end get_fml_items_dat; / select * from table(get_fml_items_dat(2)) ; F_NAME L_NAME -------------------- -------------------- peter zwan peter zwan
Hope this helps,
Kind regards
Peter
-
From a function table: invalid data type error
Hello
I'm a ORA-00902: invalid data type error when I try to call the function from a select statement below. Here, I am leaving an array from a function.
create or replace package pkg10 as type tabletype1 is table of table1%rowtype index by binary_integer; function func1 return tabletype1; end pkg10;
create or replace package body pkg10 as function func1 return tabletype1 is v_tab1 tabletype1; idx integer; begin idx := 1; for i in (select * from table1) loop v_tab1(idx).name1 := i.name1; v_tab1(idx).key := i.key; idx := idx+1; end loop; return v_tab1; end func1; end pkg10;
Please point out to me where I'm wrong.select * from table(pkg10.func1);
Thank youSathya Vamsi says:
HelloI'm a ORA-00902: invalid data type error when I try to call the function from a select statement below. Here, I am leaving an array from a function.
create or replace package pkg10 as type tabletype1 is table of table1%rowtype index by binary_integer; function func1 return tabletype1; end pkg10;
create or replace package body pkg10 as function func1 return tabletype1 is v_tab1 tabletype1; idx integer; begin idx := 1; for i in (select * from table1) loop v_tab1(idx).name1 := i.name1; v_tab1(idx).key := i.key; idx := idx+1; end loop; return v_tab1; end func1; end pkg10;
select * from table(pkg10.func1);
Please point out to me where I'm wrong.
Thank you
you try to use a data type of PL/SQL as part of an SQL statement. is NOT authorized.
-
I have a series of buttons on the screen and they all have a kind of animation associated with them. All these buttons are in a symbol entitled "MainMenu" I would like to create a table and place all the button names in the array. When you press any button in the menu that all buttons will stop the animation, and then using a function.
I put this on the stage under the action of document.compositonReady...
var buttonReset is ['glassBTN', 'woodBTN', 'steelBTN', 'waterBTN'];.
{sym.resetGlobal = function ()}
for (i = 0; i < buttonReset.length; i ++) {}
sym.getSymbol("MainMenu").getSymbol [buttonReset [i]] ("off") .stop;
}
}
And it's on the button under the action of click...sym.getComposition () .getStage () .resetGlobal ();
When I use a table and just use it...
{sym.resetGlobal = function ()}
sym.getSymbol("MainMenu") .getSymbol ("steelBTN").stop("off");
sym.getSymbol("MainMenu") .getSymbol ("glassBTN").stop("off");
sym.getSymbol("MainMenu") .getSymbol ("woodBTN").stop("off");
sym.getSymbol("MainMenu") .getSymbol ("waterBTN").stop("off");
}
.. everything works so I think maybe I'm not create table properly in my first example? Any help would be appreciated.
Thanks in advance for the help.
In fact I could do this a little differently.
1. group your buttons in a div of group
2-using each() to access the buttons of your
example:
div group is called the buttons
var buttons = sym.$("buttons").children ();
var buttonReset is ['glassBTN', 'woodBTN', 'steelBTN', 'waterBTN'];.
$.each (buttons, function (i) {})
$(this) .one ("click", function() {}
sym.getSymbol("MainMenu") .getSymbol (buttonReset [i]).stop("off");
});
})
Maybe you are looking for
-
Is your system reserved Partition a drive C?
Hello (Which happened to me) I advise you to use a window for this xp CD. Your steps to install Windows xp but I find it easy to this because the lay out is clear and is easier to understand. And also I have tried with an CD of window Xp (Service Pac
-
How can I add narration on my project to the Director of windows with background instrumental music?
-
How to fix a 57F to Windows Update error code where 19 updates keep reappearing?
I use Vista SP2 on a 32-bit computer (4 GB RAM) and I wonder why I keep getting is repeated queries to run 19 windows updates which several times to return an 57F error code. My laptop shows on stopping down that updates have been applied, but on reb
-
Strange view Domain Join Sysprep problem 5.3.1.
I have a strange problem and I am pulling my hair out. I have a win7 machine pool is not join the domain at all when dial or redial. I use sysprep with a specification of customization that I have used for previous pools without problems. I did a
-
How to bring back the police Vladimir Script? I used to use this font in our logo & wish to continue in Photoshop, but it no longer.