PL/SQL Colelction how to use in procedure
i am converting SQL Server stored procedure in oracle in which i have made use of TABLE variable but TABLE variable is not there is oracle i searched on Google instead of TABLE variable we can use of COLLECTIONS in PL/SQL
i could not find the syntax for using that i am giving you some lines please give the equivalent code for that
ALTER procedure usp_GetLLWardItemsReceived
p_ItemReceivedMstID int
as
----------declaring this first table variable @t1 --------------
Declare @t1 Table
WardItemDtl_ID int,
ItemID int,
ItemQty int,
WardID int,
WardTransID int
----------declaring this first table variable @t2 --------------
Declare @t2 Table
WardItemDtl_ID int,
ItemID int,
IssueItemQty int
----------inserting data into first table variable @t1--------------------------
insert into @t1(WardItemDtl_ID,WardTransID,ItemID,ItemQty,WardID)
select WardItemDtl_ID,WardTransID,wdDtl.ItemID
,Sum(ItemQty) ItemQty,ReceivedWardID from LL_WardItems_Details wdDtl
where isposted=0
group by wdDtl.ItemID,WardItemDtl_ID,ReceivedWardID,WardTransID
order by WardItemDtl_ID
----------inserting data into first table variable @t2--------------------------
insert into @t2(WardItemDtl_ID,ItemID,IssueItemQty)
select WardItemDtl_ID,ItemID,Sum(IssueItemQty)IssueItemQty from LL_PartyItems_Details
group by WardItemDtl_ID,ItemID order by WardItemDtl_ID
and some code here to do calculation then show to end user
please somebody helpme in this that how can i do this in PL/SQL collections or some alterntive
user21354 wrote:
thanks for your reply please give me some sort oh hint what or which alternative approach i can use to solve this problemPlease define the problem - it is a tad difficult to suggest an approach to a solution when the actual problem is unknown.
In general terms - there are very seldom need for temporary tables in Oracle. The feature is supported (called GTT or global temporary tables). It does not work like SQL-Server's temp table feature.
Collections in PL/SQL usually serve a single purpose only - reducing the context switching between the PL/SQL and SQL engines. A collection allows for a bigger size pipe to pass data between the two. Oppose to passing a single row at a time via a context switch.
The price for a collection is an increase is very expensive server memory called PGA. So there is a balance between reducing context switching at the expense of increased PGA consumption.
For this reason too, it is a very bad idea to use collections as an alternative to SQL tables and cache SQL data in collections. And this is essentially what your approach will result in - using PL/SQL collections like they are some kind of temporary SQL table.
You can crash the database server like that. I have seen this more than once. Oracle attempts to do as instructed (unless limits are imposed such as resource profiles). So if your PL/SQL attempts to create a 1GB size collection in PGA memory, Oracle will not tell you that it is a stupid thing to do. It will do as your code instructs - and in the process can totally exhaust every single bye of server memory. And this results in such severe swapping of memory pages between disk and RAM, that the entire server becomes unresponsive to such an extent that the sysadmin will not even be able to log into the server to correct the problem.
Similar Messages
-
HOW TO USE STORED PROCEDURES IN JASPERREPORTS(URJENT)
Hi,
i'm using jasperreports in struts based project. How to use stored procedures in jasperreports. pls send the solution urjent
Thanks in advance
rameshHi,
Refer the below link:
JDBC:
Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
/people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30 --> for jdbc receiver: file -JDBC
Stored Procedures-
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
http://www.ics.com/support/docs/dx/1.5/tut6.html
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
http://www.ics.com/support/docs/dx/1.5/tut6.html
http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
http://www.sqlteam.com/article/stored-procedures-an-overview
HI in the message mapping structure u need to specify the different action and also u need to specify the procedure name.
refer the below link which has all the associated action
http://help.sap.com/saphelp_nw04s/helpdata/en/22/b4d13b633f7748b4d34f3191529946/frameset.htm
Chirag -
How to use Stored Procedures in JDBC sender side and receiver side
Hello,
Can anyone explain how to use stored procedures in configuring the scenario using JDBC adapter at bothe sides sender nad receiver..
Thanks,
SooryaHi,
Refer the below link:
JDBC:
Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
/people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30 --> for jdbc receiver: file -JDBC
Stored Procedures-
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
http://www.ics.com/support/docs/dx/1.5/tut6.html
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
http://www.ics.com/support/docs/dx/1.5/tut6.html
http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
http://www.sqlteam.com/article/stored-procedures-an-overview
HI in the message mapping structure u need to specify the different action and also u need to specify the procedure name.
refer the below link which has all the associated action
http://help.sap.com/saphelp_nw04s/helpdata/en/22/b4d13b633f7748b4d34f3191529946/frameset.htm
Chirag -
How to use Stored Procedure Call in Sender JDBC adapter
Hi All,
Could someone send me a blog on how to use Stored Procedure call in Sender JDBC adapter?
XierHi Xler
refer these links
/people/yining.mao/blog/2006/09/13/tips-and-tutorial-for-sender-jdbc-adapter
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
Also, you can check Sriram's blog for executing Stored Procedures,
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
/people/jegathees.waran/blog/2007/03/02/oracle-table-functions-and-jdbc-sender-adapter
This blog might be helpfull on stored procedures for JDBC
JDBC Stored Procedures
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
Please go through these threads and see if it helps...
Re: How to execute Stored Procedure?
Re: Problem with JDBC stored procedure
Thnaks !! -
How to use Stored Procedures in form 6i Blocks
Dear Friends,
I would like to know how to use Stored Procedures while creating blocks in Data Block Wizard in forms 6i application.
Please send me sample code of stored procedure.
Regards,
Khader.The Data Block Wizard is not for creating stored procedures. It will allow you to use a stored procedure in your form. See the help documentation for how to use the wizard.
Here's an example of a simple procedure. If you search the database forum or the web, you will find many examples.
CREATE OR REPLACE PROCEDURE procedure_name (value OUT NUMBER ) AS
BEGIN
SELECT COUNT(*) INTO value
FROM your_table;
END;
Message was edited by:
Mark Roberts -
How to use stored procedures in DIAdem and Can the stored procedures be used to return values?
Can anyone please tell me how to use stored procedures in diadem and to return values from it. Its really important, can you please answer it at the earliest.
Thanks In advance
spiyaHi Spria,
I'm very sorry for the mix-up, I thought Allen was going to answer you back with the particulars that we found out. Check out the attached Word document and the below tidbits:
The built-in DIAdem ODBC functions {SQL_...()} can only call stored functions, which return a scaler result {found then in SQL_Result(1,1)}. The syntax for this with an ORACLE db is
"select function(parameters) from package"
...where package defaults to "dual" if you don't use your own package.
There might be exceptions to that though, and the syntax will be different for other databases. Note that stored ORACLE procedures can NOT be called from the ODBC functions, instead you must use either ADO function calls in the DIA
dem VBScript or the OO4O COM wrapper that ORACLE provides (this is described in further detail in the below Word document).
Hope this helps,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
Attachments:
Calling_ORACLE_Stored_Procedures_from_DIAdem.doc 28 KB -
Where we use the window class in the sql and how to use it
where we use the window class in the sql and how to use it
http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions004.htm#SQLRF06174
Regards
Etbin -
How to use 'oprofc' procedure?
How to use 'oprofc procedure'?
I don't find this program in JDEVELOPER2.0 directory.
is it necessary to launch 'oprofc' to use some oracle-specific
features (form exemple: CLOB)
nullDavid,
Please also see my reply to your other query about SQLJ and
CLOBs. It is my understanding that this script is only necessary
for command line SQLJ operations, and I don't believe it is still
used with 8.1.
Because JDeveloper handles the SQLJ translation for you, we do
not provide the command line utilities. They should be available
with either your server installation or the Oracle Client
distribution if you would like to use them.
-L
David DUPONT (guest) wrote:
: How to use 'oprofc procedure'?
: I don't find this program in JDEVELOPER2.0 directory.
: is it necessary to launch 'oprofc' to use some oracle-specific
: features (form exemple: CLOB)
null -
How to Use the Procedures in a Sql Query
Hi Friends,
Can anyone help me out whether can we use the procedure in the sql query..
if yes help me out with an example
my requirement is
i have one sql query .. in which i need to use the procedure which returns multiple values... how can i overcome it,can anyone help me out for this..
for your reference i am pasting the sql query
SELECT paf.person_id
FROM per_all_assignments_f paf START WITH paf.person_id = p_person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
CONNECT BY PRIOR paf.supervisor_id = paf.person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
and paf.person_id not in (>>>I HAVE TO USE THE PROCEDURE HERE<<<<);
Thanks in advanceWe never saw your procedure, but maybe you could wrap it in a function
SQL> create or replace procedure get_members(in_something IN number, out_members OUT sys_refcursor)
is
begin
open out_members for
'select level member_id from dual connect by level <= :num' using in_something;
end get_members;
Procedure created.
SQL> create or replace type numbers as table of number;
Type created.
SQL> create or replace function members(in_something IN number)
return numbers
as
member_cur sys_refcursor;
members numbers;
begin
get_members(in_something, member_cur);
fetch member_cur bulk collect into members;
close member_cur;
return members;
end;
Function created.
SQL> select * from table(members(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.Variant on same using piplined function
SQL> create or replace function members_piped(in_something IN number)
return numbers pipelined
as
member_cur sys_refcursor;
rec number;
begin
get_members(in_something, member_cur);
loop
fetch member_cur into rec;
exit when member_cur%notfound;
pipe row(rec);
end loop;
close member_cur;
return;
end;
Function created.
SQL> select * from table(members_piped(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.
SQL> drop function members_piped;
Function dropped.
SQL> drop function members;
Function dropped.
SQL> drop type numbers;
Type dropped.
SQL> drop procedure get_members;
Procedure droppedEdit:
Sorry Blu, had not seen you already posted similar thing
Edited by: Peter on Jan 27, 2011 5:38 AM -
How to use dbo procedure to execute for different schema?
I am using SQL Server 2008 R2, I have a schema [dbo],
and in that schema, I have created a stored procedure dbo.GetAccount:
CREATE PROCEDURE dbo.GetAccount
AS
BEGIN
select * from tblAccountNet
END
GO
Then, I have created a schema [ABC] with
user named UserABC.
Now, I would like to login with UserABC and
execute dbo.GetAccount for
schema [ABC] to
get all user of it and don't want to change code of dbo.GetAccount.
So, how can I do?
Thanks for your help.Thank you everyone.
But, I don't want to change procedure dbo.GetAccount because in face, I have more 100 procedures. I think of two solutions:
1. Create another stored procedure in
[dbo] schema, and use it to read all other procedure to list all table used in procedure and assign them with schema
[ABC]
2. Create
a stored procedure to change schema of all table in every procedure
But I really don't know how to do it. Please help me.
Thanks so much. -
How to use this procedure.
hellow everyone.
i created the following procedure in sql> but now i want to use in form,plz how to use the following procedure in form?
SQL> DECLARE
2 v_Calc NUMBER := 0;
3 BEGIN
4 WHILE v_Calc <= 10 LOOP
5 v_Calc := v_Calc + 1;
6 DBMS_OUTPUT.PUT_LINE('The value of v_Calc is ' || v_Calc);
7 END LOOP;
8 END;
9 /
MehwishMehwish,
Check the parameter p_hiredate. Now it is treated as IN parameter. And in the procedure, its an OUT parameter. So change the procedure declaration line from
create or replace procedure emp_query(p_deptno in number, p_empno in out number, p_ename in out varchar2, p_job out varchar2, p_hiredate date, p_sal out number) isto
create or replace procedure emp_query(p_deptno in number, p_empno in out number, p_ename in out varchar2, p_job out varchar2, p_hiredate out date, p_sal out number) isAnd to call the procedure try,
DECLARE
Num_p_empno number;
Str_p_ename varchar2;
Str_p_job varchar2;
Dt_p_hiredate date;
Num_p_sal number;
BEGIN
Num_p_empno := <value_for_parameter>;
Str_p_ename := <value_for_parameter>;
emp_query(<p_deptno_value>, Num_p_empno, Str_p_ename, Str_p_job, Dt_p_hiredate, Num_p_sal);
END;Regards,
Manu.
Edited by: Manu. on Jul 27, 2010 1:54 PM -
How to use the procedure column in reports
Hi all
How to call the procedure in reports as source.. If possible how to use columns of procedure in the layout column of report????Hi,
Your query is not clear.
1. In subject are you asking total column.
A. Edit pivot view and go to Rows and click Total BY option here you can find option like (none,before,after) the you can select after it will display total all culms.
2. I want use the columnC in columnD ? -- Am not understand.
A. What my understand is you want to see the report only C and D values only.
If it is correct we can apply filter in report level click column filed and apply not equal to A then it will show only C and D only.
If it is wrong pleas post me correct one with example. Will try to help out this.
I am not sure this is what your looking so far.
Award points it is useful.
Thanks,
Satya -
How to use Stored Procedure in RPD
In the physical layer we have a option for procedure when we select a tables general tab.I created the procedure
but i am not able to retrieve values in the Dashboard.
Could anyone help me with this as how to use procedure.Oracle stored procedure don't return recordssets. You have to put the result of the stored procedure in a global temp table and reference the rpd to that table. the execution of the stored procedure can be triggerd form the "execute before query" part in the connection pool.
regards
John
http://obiee101.blogspot.com/ -
How to use ODI procedures into a ODI variable
Hi,
I have the below condition
select c1 from table where c1>#ODIVAR1 and use the output of this query in a variable to define the package flow
If output=0 package flow goes as XXX
else
flow goes as YYY.
So please suggest how to use a ODI variable to capture the procedures putput and use it in package flow in this case.
Thanks,
Naveen.Step1 . Refresh the variable in the package, which have this query select c1 from table where c1>#ODIVAR1
Step2. Evaluate above variable (operator = , value 0 )
Step 3. If true Package flow xxx , else false yyy
Please close the thread once you get the required flow. -
How to use functions/procedures like wwv_flow_sw_api
Hello,
I want to use functions/procedures like wwv_flow_sw_api.check_priv(:P4_SCHEMA) in a process, but I get the error "identifier wwv_flow_sw_api.check_priv(:P4_SCHEMA); must be declared".
How can I access these functions?
Thank you,
KirstenHi Jari,
my problem is, that I need to replicate the exact feature of Query Builder page in my
application (see thread Re: How to create Query Builder page in application
So I imported the page 1002 and tried to make it working.
Do you know any solution?
Than you,
Kirsten
Maybe you are looking for
-
Screen sharing and file sharing not working on LAN
This is not a Mavericks specific problem since it existed before I upgraded to Mavericks. I have a LAN that consists of 3 MBPs and 1 MacPro. Local screen sharing and file sharing works fine on all of these computers except for one MBP. From this MB
-
How to Restore from Time Machine in Single-user mode?
Hi there, I am trying to fix a Macbook Pro that has had its /private folder trashed and emptied. Obviously it won't boot unless you you boot in to Single User mode and I'm wondering if its possible to do a Time Machine restore from the terminal, I wo
-
My safari wont open it keeps saying it quit unexpectedly
My safari wont open. when i press the icon a message pops up and says it quit unexpectedly. we keep pressing the icon and the message keeps popping up. weve tried everything. also we just got it back from apple, they've replaced our hardware but all
-
No accounting document getting posted in J2I8
hI, When I am trying to transfer captital credit in J2I8 no posting is happening. System is showing the message for updating the accounting document. But no accounting document is getting generated. This is evident from list of accounting document &
-
I don't know how often I have repaired my permissions now, both from my running OS and from the Leopard DVD - but they are not correct. I still can't delete files in my documents folder without identifying as admin, replace apps etc. etc. I get endle