Ask a Question related to Coldfusion Database Access, Design and Development.
-
reenaroy #1
sql server equivalent procedure in Oracle
Hi I am a Coldfusion + Sql Server Programmer. Now I am working with Oracle
which is new to me.
I want to know how to create multiple recorset through oracle procedure
eqiuvalent to SQL server procedure:
create procedure test
(
@id number
)
as
select * from table1 where id=@id
select * from table2 where id=@id
select * from table3 where id=@id
CF code to call sql server procedure is
<cfstoredproc procedure = " test" dataSource = "#datasource#" username =
"#dbaccount#" password = "#dbpassword#">
<cfprocparam type = "IN" CFSQLType = CF_SQL_number dbvarname="@ID" value =
"#ID#">
<cfprocresult name = "rs1" recordset="1">
<cfprocresult name = "rs2" recordset="2">
<cfprocresult name = "rs3" recordset="3">
</cfstoredproc>
reenaroy Guest
-
Does MySQL have a Stored Procedure equivalent?
I've only used ASP and MS SQL Server before but I want to learn PHP and MySQL. Does MySQL have an equivalent of Microsoft's Stored Procedures (i.e.... -
How to do equivalent to Crypt:CBC of Perl in Oracle pl/sql
Look on CPAN for extproc-perl. Install (or have your DBA install); enjoy. nataraj wrote: -- Ron Reidy Oracle DBA -
Oracle/SQL Server and Informix Equivalent Command
UNLOAD TO '/home/datadump/tablename.dmp' SELECT cField1, '~', cField2, (...) FROM sourcetable ?!! -----Original Message----- From: Ray M ... -
Oracle RowNum Equivalent
Hello, I'm looking for an equivalent of the Oracle RowNum function in SQL Server, or some other method of solving this problem. In the DDL below... -
Is there any equivalent of Sql Server's temporary table in Oracle
On Thu, 05 Dec 2002, gamaz@eathlink.net wrote: Let Oracle do the temporary set building. You code the join. -- Galen Boyer -
CF_Oracle #2
Re: sql server equivalent procedure in Oracle
Use 3 stored procedures for each table and run them consequently or
create one PL/SQL procedure using IF THEN structure (one for each table) and
pass additional IN parameter from CF page on which value condition will be
based. In cf run this procedure 3 times with values of new parameter values
you need.
CF_Oracle Guest
-
CF_Oracle #3
Re: sql server equivalent procedure in Oracle
Simplified code (more elegant solution) of Oracle stored procedure:
CREATE OR REPLACE PROCEDURE test(p_ID IN NUMBER, p_table_name IN VARCHAR) AS
BEGIN
SELECT * FROM p_table_name
WHERE iID = p_id
END;
In calling page:
<cfstoredproc procedure = " test" dataSource = "#datasource#" username =
"#dbaccount#" password = "#dbpassword#">
<cfprocparam type = "IN" CFSQLType = CF_SQL_number
variable = "p_ID"
value = "#p_ID#">
<cfprocparam type = "IN" CFSQLType = CF_SQL_varchar
variable = "p_table_name"
value = "#p_table_name#">
</cfstoredproc>
CF_Oracle Guest
-
paross1 #4
Re: sql server equivalent procedure in Oracle
You need to use reference cursors in your stored procedure to pass your results
back. Since you have to declare the reference cursor as a REF CURSOR, you need
to declare it in a PL/SQL package specification, and your stored procedures
need to be in a PL/SQL package. I have attached an example of the package and
package spec declaration, with the procedure declaration as well.
You can use the same ColdFusion code that you posted.
Phil
CREATE OR REPLACE PACKAGE test_pkg IS
TYPE ref_cur_type
IS REF CURSOR;
PROCEDURE test_sp (in_id IN NUMBER, out_res1 OUT ref_cur_type,
out_res2 OUT ref_cur_type,out_res3 OUT ref_cur_type);
END test_pkg;
/
CREATE OR REPLACE PACKAGE BODY test_pkg IS
PROCEDURE test_sp (in_id IN NUMBER, out_res1 OUT ref_cur_type,
out_res2 OUT ref_cur_type,out_res3 OUT ref_cur_type)
IS
BEGIN
OPEN out_res1
FOR
SELECT *
FROM table1
WHERE id=in_id;
OPEN out_res2
FOR
SELECT *
FROM table2
WHERE id=in_id;
OPEN out_res3
FOR
SELECT *
FROM table3
WHERE id=in_id;
END test_sp;
END test_pkg;
/
paross1 Guest
-
reenaroy #5
Re: sql server equivalent procedure in Oracle
Thanks Paross,
you are right. Procedure is working perfectly.
Only one thing I want to add.
It should be resultset in place of recordset in these lines
<cfprocresult name = "rs1" recordset="1">
<cfprocresult name = "rs1" recordset="1">
<cfprocresult name = "rs1" recordset="1">
I know this was my fault :(
reenaroy Guest



Reply With Quote

