Bulk Fetch stored procedure.
I am new to the oracle world.
Does any one have a very good, but simple example of a bulk fetch that show the creation of the container variable?
SQL> declare
2 /* Declare index-by table of records type */
3 type emp_rec_tab is table of emp%rowtype index by binary_integer;
4
5 /* Declare table variable*/
6 emptab emp_rec_tab;
7
8 /* Declare REF CURSOR variable using SYS_REFCURSOR declaration
9 in 9i and above */
10 rcur sys_refcursor;
11
12 /* Declare ordinar cursor */
13 cursor ocur is select * from emp;
14
15 begin
16
17 /* bulk fetch using implicit cursor */
18 select * bulk collect into emptab from emp;
19 dbms_output.put_line( SQL%ROWCOUNT || ' rows fetched at once from implicit cursor');
20 dbms_output.put_line('---------------------------------------------');
21
22 /* bulk fetch from Ordinar cursor */
23 open ocur;
24 fetch ocur bulk collect into emptab;
25 dbms_output.put_line( ocur%ROWCOUNT || ' rows fetched at once from ordinar cursor');
26 dbms_output.put_line('---------------------------------------------');
27 close ocur;
28
29 /* bulk fetch from Ordinar cursor using LIMIT clause */
30 open ocur;
31 loop
32 fetch ocur bulk collect into emptab limit 4;
33 dbms_output.put_line(
34 emptab.count ||
35 ' rows fetched at one iteration from ordinar cursor using limit');
36 exit when ocur%notfound;
37 end loop;
38 close ocur;
39 dbms_output.put_line('---------------------------------------------');
40
41 /* bulk fetch from ref cursor */
42 open rcur for select * from emp;
43 fetch rcur bulk collect into emptab;
44 dbms_output.put_line( rcur%ROWCOUNT || ' rows fetched at once from ref cursor');
45 dbms_output.put_line('---------------------------------------------');
46 close rcur;
47
48 /* bulk fetch from ref cursor using LIMIT clause */
49 open rcur for select * from emp;
50 loop
51 fetch rcur bulk collect into emptab limit 4;
52 dbms_output.put_line( emptab.count ||
53 ' rows fetched at one iteration from ref cursor using limit');
54 exit when rcur%notfound;
55 end loop;
56 close rcur;
57 dbms_output.put_line('---------------------------------------------');
58
59 /* bulk fetch using execute immediate */
60 execute immediate 'select * from emp' bulk collect into emptab;
61 dbms_output.put_line( SQL%ROWCOUNT || ' rows fetched using execute immediate');
62 dbms_output.put_line('---------------------------------------------');
63
64 end;
65 /
14 rows fetched at once from implicit cursor
14 rows fetched at once from ordinar cursor
4 rows fetched at one iteration from ordinar cursor using limit
4 rows fetched at one iteration from ordinar cursor using limit
4 rows fetched at one iteration from ordinar cursor using limit
2 rows fetched at one iteration from ordinar cursor using limit
14 rows fetched at once from ref cursor
4 rows fetched at one iteration from ref cursor using limit
4 rows fetched at one iteration from ref cursor using limit
4 rows fetched at one iteration from ref cursor using limit
2 rows fetched at one iteration from ref cursor using limit
14 rows fetched using execute immediate
 
PL/SQL procedure successfully completed.Rgds.
Similar Messages
-
Error while fetching Stored procedure from JDev DB Adapter
Hello
I am facing a problem while configuring stored procedures from Jdeveloper using DB Adapter. I am using Sql Server 2005 as my database,Jdeveloper version is 10.1.3.1.Bpel Version is 10.1.3.3. Connection to the Sqlserver 2005 database is fine, but it shows only views and tables. I get the following error message when I try to add the sql stored procedure call
"An error occured while obtaining the database schemas.Verify that the database connection is valid , and is supported"
Can someone help me please.
Thanks,
Phani
Edited by: Phani on Oct 28, 2008 11:30 AMI think you have two problems here. First, JDeveloper 10.1.3.1 doesn't support SQL Server stored procedures. There is a command-line utility that you can use to generate the required BPEL artifacts (WSDL and XSD). Second, you're using a 10.1.3.1 design-time with a 10.1.3.3 runtime. These are not compatible so you will likely run into namespace issues when you try to run your BPEL processes. You should upgrade your JDeveloper to 10.1.3.3. JDeveloper will support third-party databases in 11.1.1 including SQL Server 2005 (but not 2000), IBM DB2 v8.x and v9.x, DB2 AS/400, and MySQL. JDeveloper will support MySQL v5.2.6 and above because the INFORMATION_SCHEMA.PARAMETERS table was added at that time. The PARAMETERS table does not exist in MySQL versions prior to v5.2.6 so you will have to use the command-line utility.
-
How to fetch oracle process id from a stored procedure.
Hi,
I want to fetch the oracle process id from within a stored procedure.
I know that the one way to do this is using the v$process view. But, a grant has to be given to the user on this table. Due to the strict policies at my workplace, I do not have the permission to do this, nor can i ask anyone to give the grant. But, i need the oracle pid very much.
Is there an alternate way to get the oracle process id from within the stored procedure (without using the v$process view, like we have sys_context() to fetch session id without using v$session) ?
Any help would be appreciated.
Thanks,
APHi,
The point is i do not want to use v$process ( or v_$process) ,because i can not give the select grant to the user on this view. ( As i need to fetch it from a stored procedure, not from the SQL prompt).
Rahul , your query is correct. It fetches the values ( though i needed oracle process id not unix pid ; i would get it through p.pid), but i need an alternate approach to this.
Is there an alternate approach which would enable me to fetch the oracle process id ( without using any of the V$ - system views) ? Does Oracle has such a feature /approach ?
-AP -
How to fetch data to APEX Report using stored procedure?
hi all,
i am making a report in APEX. user selects two dates and clicks GO button - i have a Stored Procedure linked to that result region so Stored Procedure gets called.
my stored procedure does the following -
using specified dates (IN) i do query and put data into a table (this table has been created only for this report) -
i want to show all these data i entered into the table on my APEX report in the same procedure call. can i use ref cursor to return? how to do that?
currently, i use another button in APEX which basically fetches all data from table. basically, user clicks one button to generate report and then another button to get report. which is not desirable at all :(
i m using APEX 3.1.2.00.02 and Oracle 10 database.
pls let me know if you need further clarification of the problem. thanks in advance.
regards,
probashi
Edited by: porobashi on May 19, 2009 2:53 PMThanks Tony.
I am not sure what you meant by >> change the report to be based off of a query returning sql statement, no need to keep that table around.... >>
Here's my stored procedure
create or replace
PROCEDURE ABC_PROC (
START_DATE IN DATE,
END_DATE IN DATE
AS
RULE_REC MTG_OFFICER_FORECAST%ROWTYPE;
TYPE REF_CURSOR IS REF CURSOR;
TCUR REF_CURSOR;
BEGIN
DELETE FROM ABC_REPORT;
OPEN TCUR FOR
SELECT ABC_FORECAST.*
from MTG_OFFICER_FORECAST , MTG_USERS
WHERE MTG_OFFICER_FORECAST.NBR_OFFICER = MTG_USERS.NBR_OFFICER AND
MTG_OFFICER_FORECAST.NBR_INSTITUTION = MTG_USERS.NBR_INSTITUTION;
LOOP
FETCH TCUR INTO RULE_REC;
EXIT WHEN TCUR%NOTFOUND;
INSERT INTO ABC_REPORT( NBR_OFFICER, OFFICER_NAME, FORECAST_NBR_LOANS, FORECAST_LOAN_AMT, FORECAST_FEES,
ACTUAL_NBR_LOANS, ACTUAL_LOAN_AMT, ACTUAL_FEES, RATIO_NBR_LOANS, RATIO_LOAN_AMT, RATIO_FEES, NBR_INSTITUTE )
VALUES ( RULE_REC.NBR_OFFICER, RULE_REC.NAME_LOAN_OFFICER, RULE_REC.NBR_LOANS, RULE_REC.AMT_LOAN, RULE_REC.AMT_FEES,
ACTUAL_NBR_LOANS, ACTUAL_LOAN_AMOUNT, ACTUAL_FEES, SUCCESS_RATIOS_NBR_LOANS_PERC, SUCCESS_RATIOS_LOAN_AMT_PERC, SUCCESS_RATIOS_FEES_PERC, RULE_REC.NBR_INSTITUTION );
END LOOP;
CLOSE TCUR;
END ABC_PROC;
Thanks,
Probashi
Edited by: porobashi on Jun 2, 2009 11:43 AM -
Calling Stored procedure which uses Bulk Collect
Hi All, I have Oracle stored procedure which uses Bulk Collect and returns table type parameter as output. Can anyone please help me how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. (I am successfully able to call using MS ODBC driver, but I want to use OraOLEDB driver.)
861412 wrote:
how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. This forum deals with the server-side languages SQL and PL/SQL.
Your question deals with the client side and Visual Basic language. -
Performance to fetch result set from stored procedure.
I read some of related threads, but couldn't find any good suggestions about the performance issue to fetch the result set from a stored procedure.
Here is my case:
I have a stored procedure which will return 2,030,000 rows. When I run the select part only in the dbartisan, it takes about 3 minutes, so I know it's not query problem. But when I call the stored procedure in DBArtisan in following way:
declare cr SYS_REFCURSOR;
firstname char(20);
lastname char(20);
street char(40);
city char(20);
STATE varchar2(2);
begin DISPLAY_ADDRESS(cr);
DBMS_OUTPUT.ENABLE(null);
LOOP
FETCH cr INTO firstname,lastname,street, city, state;
EXIT WHEN cr%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( firstname||','|| lastname||','|| street||',' ||city||',' ||STATE);
END LOOP;
CLOSE cr;
end;
It will take about 100 minutes. When I used DBI fetchrow_array in perl code, it took about same amount of time. However, same stored procedure in sybase without using cursor, and same perl code, it only takes 12 minutes to display all results. We assume oracle has better performance. So what could be the problem here?
The perl code:
my $dbh = DBI->connect($databaseserver, $dbuser, $dbpassword,
{ 'AutoCommit' => 0,'RaiseError' => 1, 'PrintError' => 0 })
or die "couldn't connect to database: " . DBI->errstr;
open OUTPUTFILE, ">$temp_output_path";
my $rc;
my $sql="BEGIN DISPLAY_ADDRESS(:rc); END;";
my $sth = $dbh->prepare($sql) or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->bind_param_inout(':rc', \$rc, 0, { ora_type=> ORA_RSET });
$sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
while($address_info=$rc->fetchrow_arrayref()){
my ($firstname, $lastname, $street, $city, $STATE) = @$address_info;
print OUTPUTFILE $firstname."|".$lastname."|".$street."|".$city."|".$STATE;
$dbh->commit();
$dbh->disconnect();
close OUTPUTFILE;
Thanks!
rulinThanks for you reply!
1) The stored procedure has head
CREATE OR REPLACE PROCEDURE X_OWNER.DISPLAY_ADDRESS
cv_1 IN OUT SYS_REFCURSOR
AS
err_msg VARCHAR2(100);
BEGIN
--Adaptive Server has expanded all '*' elements in the following statement
OPEN cv_1 FOR
Select ...
commit;
EXCEPTION
WHEN OTHERS THEN
err_msg := SQLERRM;
dbms_output.put_line (err_msg);
ROLLBACK;
END;
If I only run select .. in DBArtisan, it display all 2030,000 rows in 3:44 minutes
2) But when call stored procedure, it will take 80-100 minutes .
3) The stored procedure is translated from sybase using migration tools, it's very simple, in sybase it just
CREATE PROCEDURE X_OWNER.DISPLAY_ADDRESS
AS
BEGIN
select ..
The select part is exact same.
4) The perl code is almost exact same, except the query sql:
sybase verson: my $sql ="exec DISPLAY_ADDRESS";
and no need bind the cursor parameter.
This is batch job, we create a file with all information, and ftp to clients everynight.
Thanks!
Rulin -
URGENT : Return Bulk data from Stored Procedure
Hi,
Tell me, how do I return a bulk of data which
does not exist in the data base
but is concluded while the Stored Procedure is executed
from the Stored procedure
to the C++ program.
For Example:
Table ABC
Field1 Field2 Field3
A 1 3
B 1 5
C 2 10
Table DEF
Field1 Field2 Field3
D 10 24
E 3 16
F 8 19
SP_TESTING
Depending on the values in both the tables
for some range of conditions,
a conclusion X is derived for each range value of the
condition range.
Now I need to return this bulk of data X with the
condition they belong to
back to the C++ code calling it....
NOTE : A stored procedure is requited as there is a lot
of processing
required before we conclude the result X for each value
in the condition range.
If I execute this code from C++ instead of Stored
procedure
it is very slow and speed is a prime requirement of my
system.
Also i'm not using any MFC class to access database.
I'm using ConnectionPtr, RecordsetPtr and _CommandPtr
from msado15.dll for database access...
One solution to this could be use of Temp tables.
As this process is used by a lot of different stored
procedures having a common
temp table to all will need something like 50 NUMERIC
fields, 50 VARCHAR fields
and so on, which doesn't seem like a very good solution
to this problem.
Sounds like something I would have done while in school,
implement a dumb solution.
So, please suggest me a solution as to how do I return
bulk data in the form
of recordsets from stored procedure.
Regards
ShrutiUse Out parameter mode
SQL> CREATE OR REPLACE procedure a1 (x OUT NUMBER, y OUT NUMBER) AS
2 BEGIN
3 x:= 1;
4 y:= 2;
5 END;
6 .
SQL> /
Procedure created.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 a NUMBER :=3;
3 b NUMBER :=4;
4 BEGIN
5 a1 (a,b);
6 DBMS_OUTPUT.PUT_LINE( 'a = ' || a );
7 dbms_output.put_line( 'b = ' || b );
8 END;
9 .
SQL> /
a = 1
b = 2
PL/SQL procedure successfully completed.By default parameters are copied to the OUT parameter mode .
COPY hint in PLSQL don’t send a pointer to calling program unit but NOCOPY
does.
Khurram -
Bulk insert using stored procedure or trigger
Hi ,
I have to insert around 40,000 rows in a table querying other database using database link.
Please advice whether I do using stored procedure or trigger.
Thanks.Here is a basic benchmark that illustrates the difference between maximising SQL, or doing it in PL/SQL instead.
Care needs to be taken with such a benchmark in order for physical I/O not to negatively impact a test, and then have no impact in the second test as that data read from disk now sits in the cache.
So I ran it a couple of times in order to "warm up" the cache. I also put the maximise-SQL test first in order to show that it is still faster, despite any physical I/O it may do (which will likely be faster logical I/O with the second test).
Run on Oracle XE 10.2.0.1.
SQL> drop table my_objects_copy purge;
Table dropped.
SQL> create table my_objects_copy as select * from all_objects;
Table created.
SQL>
SQL> set timing on
SQL> begin
2 delete from my_objects_copy;
3
4 insert into my_objects_copy
5 select * from all_objects;
6
7 commit;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.11
SQL> set timing off
SQL>
SQL> drop table my_objects_copy purge;
Table dropped.
SQL> create table my_objects_copy as select * from all_objects;
Table created.
SQL>
SQL> set timing on
SQL> declare
2 cursor c is select * from all_objects;
3 objRow ALL_OBJECTS%ROWTYPE;
4 begin
5 delete from my_objects_copy;
6
7 open c;
8 loop
9 fetch c into objRow;
10 exit when c%NOTFOUND;
11
12 insert into my_objects_copy
13 values objRow;
14
15 end loop;
16 commit;
17 end;
18 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.21
SQL>
The cursor-fetch-loop is almost 3 times slower. The more rows there are to process, the slower the cursor-fetch-loop will become, as it will create more and more context switching and copying data between the SQL and PL engines and back. -
Tsql stored procedure bulk insert
Hi,
The following code works perfectly:
cfquery datasource="#SESSION.DSN#">
BULK INSERT dbo.Syndicated
FROM '#selectedfile#'
WITH
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW = 2
</cfquery>
I created this stored procedure:
CREATE
PROCEDURE dbo.uspInsertSyndicatedRecords@selectedfile
varchar(2000)
AS
BEGIN
BULK INSERT Syndicated
FROM '@selectedfile'
WITH
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW = 2
END
I'm getting an error: The file "@selectedfile" does not exist.
Anyone know if there are issues with the file path in a stored procedure. #selectedfile# = C:\ColdFusion8\wwwroot\cfdocs\mis35\luxury.csv
Thanks!
cfwildUnfortunately, dynamic queries don't work within TSQL - meaning you can't substibute table and column names with variables. You can only use variables for the comparison values or select values.
However, you can create a variable, build the SQL statement in that variable and execute it:
DECLARE @SQLString VARCHAR(max)
SET @SQLString = 'SQL Start ....' + @MyVar + ' .... SQLEnd'
EXEC(@SQLString)
Now, if the variable being concatinated is not a string, you will need to cast/convert it to string, which just adds tons of fun to the equation.
Hope this helps! -
How to fetch %ROWTYPE OUT param of a stored procedure from Java program?
I have a stored procedure that has IN / OUT parameter as table_name%ROWTYPE.
From a java program how can I access this ROWTYPE variable?
I tried all possible documentation and none of the explains whether or not this is supported.
My use case expect exactly 1 record from the procedure and we would prefer not to use REF CURSOR.
Is there a way to achieve this? If so, can someone help me with it by posting the sample code to achieve this?
I tried all the possible OracleTypes to register the OutParameter and they all fail.
Looks like there isn't any equivalent of %ROWTYPE in OracleTypes either.
If you need, I can post my sample procedure that uses %ROWTYPE as OUT parameter.
I really appreciate your help in this regard.
- KarthikHi,
If "returning only 1 record" the showstopper for not using Ref Cursor, you might want to reconsider because as you probably know, the ref cursor is only a pointer and requires additional step to retrieve the data.
Kuassi -
Bulk Insert Through Stored Procedure performance issue
Hello,
i am new to oracle. i am writing a stored procedure through which i want to insert 1 billion record in a table. but it takes days to insert it . please tell me how can i improve performance of my stored procedure. because same stored procedure when i convert it into sql server in take 24 - 30 min to insert 1 billion record.
Code of my stored procedure are as follows :
create or replace PROCEDURE bspGenerateHSCode(
mLoc_id IN INT,
HSCodeStart IN VARCHAR2,
HSCodeEnd IN VARCHAR2,
mRqstId IN INT,
total_count IN INT,
Status OUT INT)
AS
ExitFlag INT;
row_count INT;
mBatchStart NUMBER;
mBatchEnd NUMBER;
mStartSqnc NUMBER;
mEndSqnc NUMBER;
mHSCode VARCHAR2(500);
HSStartStr VARCHAR2(500);
BEGIN
SELECT COUNT(*) INTO row_count FROM goap_eal_allocation
WHERE hs_code_start = HSCodeStart
AND hs_code_end = HSCodeEnd
AND loc_id = mLoc_id
AND processed = 0;
IF row_count > 0 THEN
SELECT CAST ( REVERSE(substr(REVERSE(HSCodeStart), 1, instr(REVERSE(HSCodeStart), ',') -1)) AS NUMBER) INTO mStartSqnc FROM DUAL;
SELECT CAST ( REVERSE(substr(REVERSE(HSCodeEnd), 1, instr(REVERSE(HSCodeEnd), ',') -1)) AS NUMBER) INTO mEndSqnc FROM DUAL;
SELECT CAST( REVERSE(substr( REVERSE(HSCodeStart), instr(REVERSE(HSCodeStart), ','))) AS VARCHAR2(500) ) INTO HSStartStr FROM DUAL;
mBatchStart := mStartSqnc;
DBMS_OUTPUT.PUT_LINE('start batch ' || mBatchStart);
LOOP
mBatchEnd := mBatchStart + 5000;
IF mBatchEnd > mEndSqnc THEN
mBatchEnd := mEndSqnc + 1;
END IF;
DBMS_OUTPUT.PUT_LINE('End batch ' || mBatchEnd);
LOOP
mHSCode := HSStartStr || mBatchStart;
mBatchStart := mBatchStart + 1;
INSERT INTO goap_eal_register(id, hs_code, loc_id, status_id, synced)
SELECT CASE WHEN MAX(id) > 0 THEN (MAX(id) + 1) ELSE 1 END AS id ,
mHSCode, mLoc_id, 6, 1 FROM goap_eal_register;
EXIT WHEN mBatchStart = mBatchEnd;
END LOOP;
COMMIT;
EXIT WHEN mBatchStart = mEndSqnc +1;
END LOOP;
UPDATE goap_eal_allocation SET processed = 1
WHERE hs_code_start = HSCodeStart
AND hs_code_end = HSCodeEnd
AND loc_id = mLoc_id;
COMMIT;
Status := 1;
ELSE
Status := 0;
END IF;
END;
ThanksPlease edit your post and add \ on the line before and the line after the code to preserve formattingsee how this looks?
Also, when you basically just want to RETURN without doing any work then your first test should just RETURN if you don't want to do any work.
Instead of what your code does:IF row_count > 0 THEN
. . . a whole lot of code that is hard to read or understand
COMMIT;
Status := 1;
ELSE
Status := 0;
END IF;
Test the condition to determine when you do NOT want proceed and just return.IF row_count = 0 THEN
Status := 0;
RETURN;
END IF;
-- now NONE of the following code needs to be indented - you won't get here unless you really want to execute it.
. . . break the code into separate steps and add a one line comment before each step that says what that step does.
COMMIT;
Status := 1; -
SQL SERVER BULK FETCH AND INSERT/UPDATE?
Hi All,
I am currently working with C and SQL Server 2012. My requirement is to Bulk fetch the records and Insert/Update the same in the other table with some business logic?
How do i do this?
Thanks in Advance.
Regards
Yogesh.B> is there a possibility that I can do a bulk fetch and place it in an array, even inside a stored procedure ?
You can use Temporary tables or Table variables and have them indexes as well
>After I have processed my records, tell me a way that I will NOT go, RECORD by RECORD basis, even inside a stored procedure ?
As i said earlier, you can perform UPDATE these temporary tables or table variables and finally INSERT/ UPDATE your base table
>Arrays are used just to minimize the traffic between the server and the program area. They are used for efficient processing.
In your case you will first have to populate the array (Using some of your queries from the server) which means you will first load the arrary, do some updates, and then send them back to server therefore
network engagement
So I just gave you some thoughts I feel could be useful for your implementation, like we say, there are many ways so pick the one that works good for you in the long run with good scalability
Good Luck! Please Mark This As Answer if it solved your issue. Please Vote This As Helpful if it helps to solve your issue -
How to use Stored Procedures with SQLServer2005 and WAS 6.x
Hi All
I've got a problem, during the call to a StoredProcedure in SQLServer i've get the next message:
Exception : com.microsoft.sqlserver.jdbc.SQLServerException: Fetch size cannot be negative
The stored procedure is working correctly if I run my process out of WAS 6.x but if I get a connection from the pool the process don't work.
Help please, thanks.Your procedure has a single OUT parameter ... and yet it appears you are trying to stuff something into it ... that is never going to work. Additionally everything else about your stored procedure would have gotten you a FAIL grade were you been in my beginning PL/SQL class.
The syntax, a cursor loop, is obsolete and has been for more than 10 years.
The formatting and use of case makes even the few lines written hard to read.
And either no commit ever takes place or you are trying to do incremental commits in origseq: Both of which are bad practice.
This code should use BULK COLLECT to collect all relevant records into an array and then pass the array to origseq ... no loops ... and end with a commit.
Demo here: http://www.morganslibrary.org/reference/array_processing.html -
Hi,
I have a query like this,
select email as vEmail from users where id in (217211,217521,217641)
Now this query returns 3 email id's. I have to loop through the vEmail and assign them to different local variables in stored procedures.
like email for 217211 is stored in vEmail1
217521 in vEmail2
217641 in vEmail3
Can somehow help me in this looping?Hi,
Do you really need them in 3 separate variables, like vemail1, vemail2 and vemail3?
Would you be just as happy if they were in 3 separate members of a collection: vemail(1), vemal(2) and vemail(3)? If so, use BULK COLLECT. It will be a lot more efficient (though, if you're only fetching 3 rows, that won't amount to much).
The PL/SQL manual has a nice example:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/tuning.htm#sthref1474 -
Executing the stored procedure with output which is a collection of objects
Hello,
I have the objects and collection of objects within an objects as below:
CREATE OR REPLACE TYPE SHARE_OUTST_T
AS OBJECT
SHR_OUTST_AMT number
CREATE OR REPLACE TYPE SECURITY_T
AS OBJECT
VOTE_PER_SHR number
, CUSIP varchar2(12)
, EXCHANGE varchar2(10)
, IV_TYPE_CD varchar2(10)
, SEC_TICKER_SYMB varchar2(20)
CREATE OR REPLACE TYPE ALTERNATE_ID_T
AS OBJECT
( ALT_ID_TYPE varchar2(20)
CREATE OR REPLACE TYPE ISSUE_MAINT_VERSION_T
AS OBJECT
IM_KEY_ID number
, IM_VER_NUM number
, EFF_TMSTMP timestamp
, EXP_TMSTMP timestamp
, NEXT_REVIEW_TMSTMP timestamp
, APPR_STATUS_REF_ID number
, VOTE number
, ADD_USR_ID varchar2(20)
, ADD_TMSTMP timestamp
, UPD_USR_ID varchar2(20)
, UPD_TMSTMP timestamp
, LOCK_LEVEL_NUM number
, ACTION VARCHAR2(1)
CREATE OR REPLACE TYPE ISSUE_SHARE_MAINT_T
AS OBJECT
IM_KEY_ID number
, IM_VER_NUM number
, SHR_OUTST_AMT number
, CURR_OUTST_AMT number
, ADD_USR_ID varchar2(20)
, ADD_TMSTMP timestamp
, UPD_USR_ID varchar2(20)
, UPD_TMSTMP timestamp
, LOCK_LEVEL_NUM number
, ACTION VARCHAR2(1)
CREATE OR REPLACE TYPE ISSUE_MAINT_COMMENT_T
AS OBJECT
IM_KEY_ID number
, IM_VER_NUM number
, COMMENT_TXT varchar2(400)
, ADD_USR_ID varchar2(20)
, ADD_TMSTMP timestamp
, UPD_USR_ID varchar2(20)
, UPD_TMSTMP timestamp
, LOCK_LEVEL_NUM number
, ACTION VARCHAR2(1)
CREATE OR REPLACE TYPE ISSUE_MAINT_COMMENT_COL_T AS TABLE OF ISSUE_MAINT_COMMENT_T;
CREATE OR REPLACE TYPE ISSUE_VERSION_T
AS OBJECT
SHARE_OUTST SHARE_OUTST_T
, SECURITY SECURITY_T
, ALTERNATE_ID ALTERNATE_ID_T
, ISSUER ISSUER_T
, ISSUE_MAINT_VERSION ISSUE_MAINT_VERSION_T
, ISSUE_SHARE_MAINT ISSUE_SHARE_MAINT_T
, ISSUE_MAINT_COMMENT_COL ISSUE_MAINT_COMMENT_T
CREATE OR REPLACE TYPE ISSUE_VERSION_COL_T AS TABLE OF ISSUE_VERSION_T;
And the stored procedure as :
=======================================
PROCEDURE get_all_issue_version_col
( pv_issue_version_col OUT issue_version_col_t
AS
CURSOR cur_issue_version
IS
SELECT
issue_version_t (
SHARE_OUTST_T (so.shr_outst_amt )
, SECURITY_T ( s.vote_per_shr
, s.sec_cusip
, s.PRI_MKT_EXCH_CD
, s.IV_TYPE_CD
, s.SEC_TICKER_SYMB )
, ALTERNATE_ID_T (a.ALT_ID_TYPE)
, ISSUER_T (i.ISSR_ID )
, ISSUE_MAINT_VERSION_T (imv.im_key_id
, imv.im_ver_num
, imv.eff_tmstmp
, imv.exp_tmstmp
, imv.next_review_tmstmp
, imv.appr_status_ref_id
, imv.vote
, imv.add_usr_id
, imv.add_tmstmp
, imv.upd_usr_id
, imv.upd_tmstmp
, imv.lock_level_num
, NULL )
, ISSUE_SHARE_MAINT_T (ism.im_key_id
, ism.im_ver_num
, ism.shr_outst_amt
, ism.curr_outst_amt
, ism.add_usr_id
, ism.add_tmstmp
, ism.upd_usr_id
, ism.upd_tmstmp
, ism.lock_level_num
, NULL)
, ISSUE_MAINT_COMMENT_T(imc.im_key_id
, imc.im_ver_num
, imc.comment_txt
, imc.add_usr_id
, imc.add_tmstmp
, imc.upd_usr_id
, imc.upd_tmstmp
, imc.lock_level_num
, NULL )
FROM
share_outst so
, security s
, alternate_id a
, issuer i
, issue_maintenance_version imv
, issue_share_maintenance ism
, issue_maintenance_comment imc
WHERE
s.sec_key_id = so.SEC_KEY_ID
and s.SEC_KEY_ID = a.SEC_KEY_ID
and s.MSTR_ISSR_KEY_ID = i.ISSR_KEY_ID
and s.SEC_CUSIP = imv.SEC_CUSIP (+)
and s.SEC_CUSIP = ism.SEC_CUSIP (+)
and imv.IM_KEY_ID = imc.IM_KEY_ID (+);
BEGIN
OPEN cur_issue_version ;
FETCH cur_issue_version BULK COLLECT INTO pv_issue_version_col ;
CLOSE cur_issue_version ;
END ;
PROCEDURE get_all_issue_col_v1
( pv_issue_version_col OUT NOCOPY issue_version_col_t
, pv_row_count IN number
, pv_issuer_id IN VARCHAR2
AS
CURSOR cur_issue_version
IS
SELECT
issue_version_t (
SHARE_OUTST_T (so.shr_outst_amt )
, SECURITY_T ( s.vote_per_shr
, s.sec_cusip
, s.PRI_MKT_EXCH_CD
, s.IV_TYPE_CD
, s.SEC_TICKER_SYMB )
, ALTERNATE_ID_T (a.ALT_ID_TYPE)
, ISSUER_T (i.ISSR_ID )
, ISSUE_MAINT_VERSION_T (imv.im_key_id
, imv.im_ver_num
, imv.eff_tmstmp
, imv.exp_tmstmp
, imv.next_review_tmstmp
, imv.appr_status_ref_id
, imv.vote
, imv.add_usr_id
, imv.add_tmstmp
, imv.upd_usr_id
, imv.upd_tmstmp
, imv.lock_level_num
, NULL )
, ISSUE_SHARE_MAINT_T (ism.im_key_id
, ism.im_ver_num
, ism.shr_outst_amt
, ism.curr_outst_amt
, ism.add_usr_id
, ism.add_tmstmp
, ism.upd_usr_id
, ism.upd_tmstmp
, ism.lock_level_num
, NULL)
, ISSUE_MAINT_COMMENT_T(imc.im_key_id
, imc.im_ver_num
, imc.comment_txt
, imc.add_usr_id
, imc.add_tmstmp
, imc.upd_usr_id
, imc.upd_tmstmp
, imc.lock_level_num
, NULL )
FROM
share_outst so
, security s
, alternate_id a
, issuer i
, issue_maintenance_version imv
, issue_share_maintenance ism
, issue_maintenance_comment imc
WHERE
s.sec_key_id = so.SEC_KEY_ID
and s.SEC_KEY_ID = a.SEC_KEY_ID
and s.MSTR_ISSR_KEY_ID = i.ISSR_KEY_ID
and s.SEC_CUSIP = imv.SEC_CUSIP (+)
and s.SEC_CUSIP = ism.SEC_CUSIP (+)
and imv.IM_KEY_ID = imc.IM_KEY_ID (+);
BEGIN
OPEN cur_issue_version ;
FETCH cur_issue_version BULK COLLECT INTO pv_issue_version_col ;
CLOSE cur_issue_version ;
END ;
====================
When I execute this stored procedure thru rapid sql, I get error
Error: ORA-06550: line 1, column 21:
PLS-00306: wrong number or types of arguments in call to 'GET_ALL_ISSUE_VERSION_COL'
ORA-06550: line 1, column 21:
PL/SQL: Statement ignored, Batch 1 Line 1 Col 21
What is that I am missing?
Any help would be greatly appreciated.I've never tried Rapid SQL, but my guess is that you can't pass objects through it. I'd write a test case on the server and try it there. It looks like it should work but I didn't build a test case. If it works on the server but not in the tool, it's like the tool. OCI8 doesn't support passing instantiated objects.
Maybe you are looking for
-
Several music albums listed in my IPhone 5 music library are listed multiple times, but each one only has a portion of the songs listed. How can I combine them to make one album?
-
How to run SmartCard Application on PC
hi, i want to know how to convert class file into a CAP file and how to run on PC a smartCard Application. when i use converter use from command prompt then it will ask the AID how i get the AID at Conversion time. pls tell me the procedure for Conve
-
Ordering slideshows by file name or date?
I've seen several posts about this but no one has come up with a solution on how to order iDVD slideshows by something other than random criteria. Importing into iPhoto is really not an option for me because it introduces a 3rd step (I eschew iPhoto
-
How to design a "white" background in "black and white" ad on pink newsprint?
Long-time Indesigner here, but I have never had this dilemma before. Am designing a "black and white" newpaper ad for a major paper that has a pink section, i.e. it prints on pink newsprint. So I know this is black ink only, hence the "black and whit
-
Changing all photos in event to SAME date
I have many photos in an event that have a variety of dates. I would like to change all photos to the SAME date. All I can figure out to do is change the first photo, but then all of the other photos are time-shifted and still have different dates.