473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

stored procedures out parameter

5
Hi, i need to return the result of the query from this procedure, where can i store this data

Expand|Select|Wrap|Line Numbers
  1. create or replace PROCEDURE RELACIONA_DATOS(
  2.     p_CVE_TABLA IN NUMBER,
  3.     p_CVE_TIPO_DATOENT IN NUMBER,
  4.     p_res OUT ?????????????
  5. ) AS
  6.  
  7.   nom_atr_tbl RELACIONES.NOMBRE%TYPE;
  8.   NOM CAT_ATRIBUTO_TBL.NOMBRE_ATRIBUTO%TYPE;
  9.  
  10.  
  11. BEGIN
  12.   select r.NOMBRE,
  13.        (select NOMBRE_ATRIBUTO
  14.         FROM CAT_ATRIBUTO_TBL  CATTR
  15.         WHERE CATTR.CVE_ATRIBUTO = r.CVE_ATR_IND_REC) NOMBREBIO
  16.   INTO nom_atr_tbl, NOM ????????????????????????????????
  17.   FROM  CAT_ATRIBUTO_TBL c, RELACIONES r 
  18.   WHERE CVE_TABLA = p_CVE_TABLA
  19.   AND CVE_ATRIBUTO IN (SELECT CVE_ATRIBUTO
  20.                      FROM DATOENT_ATRIBUTO 
  21.                      WHERE CVE_DATOENT IN (SELECT CVE_DATOENT 
  22.                                            FROM DATO_ENTRADA
  23.                                            WHERE CVE_TIPO_DATOENT = p_CVE_TIPO_DATOENT)
  24.                      ) 
  25. AND c.CVE_ATRIBUTO = r.CVE_ATRIBUTO_TABLA_REQUERIDA;
  26. END RELACIONA_DATOS;

what i get from this query is

Expand|Select|Wrap|Line Numbers
  1. NOMBRE                  | NOMBREBIO
  2.  
  3. tipoDocProbClave     CVE_DOCTO_PROB
  4. curpDocumProbNum    | AN_NUM_ACTA
  5. tipoDocProbClave    | AN_FECHA_REG
  6. curpDocumProbNum    | AN_TOMO
  7. tipoDocProbClave    | AN_LIBRO
  8. curpDocumProbNum    | AN_FOJA
  9. tipoDocProbClave    | AN_ENTIDAD_REG
  10. curpDocumProbNum    | AN_ID_MUNICIPIO
  11. curpDocumProbNum    | AN_CRIP
Dec 5 '07 #1
4 2511
Dave44
153 100+
you have to decide what you are doing with the data. You can insert the rows from the query into a table or you can use a ref cursor etc ... there are many things you can do to get at the data.
Dec 5 '07 #2
Maikit
5
you have to decide what you are doing with the data. You can insert the rows from the query into a table or you can use a ref cursor etc ... there are many things you can do to get at the data.
How can i use a ref cursor, im new to this and im not sure how to use it, ive tried several things:

Expand|Select|Wrap|Line Numbers
  1. create or replace PROCEDURE RELACIONA_DATOS(
  2.     p_CVE_TABLA IN NUMBER,
  3.     p_CVE_TIPO_DATOENT IN NUMBER,
  4.     p_res OUT REL_EST%ROWTYPE
  5. ) AS
REL_EST is a table with the structure i want

I also tried this

Expand|Select|Wrap|Line Numbers
  1. PROCEDURE RELACIONA_DATOS(
  2.     p_CVE_TABLA IN NUMBER,
  3.     p_CVE_TIPO_DATOENT IN NUMBER,
  4.     p_res OUT cursor_type
  5. );
cursor type is a ref cursor declared in apackage but i cant get it to work...

any ideas?
Dec 5 '07 #3
Dave44
153 100+
what will be receiving the out parameter of type ref cursor? is it another pl/sql package/procedure or is it another language which can automatically determine the columns involved with the ref cursor (such as vb.net)? I ask this because if you use weakly typed ref cursors then you need to make sure that the calling procedure with the IN parameter of sys_refcursor has all the correct columns accounted for in the fetch.

an example of a out ref cursor can be found here:
http://www.psoug.org/reference/ref_cursors.html
Dec 5 '07 #4
amitpatel66
2,367 Expert 2GB
How can i use a ref cursor, im new to this and im not sure how to use it, ive tried several things:

Expand|Select|Wrap|Line Numbers
  1. create or replace PROCEDURE RELACIONA_DATOS(
  2.     p_CVE_TABLA IN NUMBER,
  3.     p_CVE_TIPO_DATOENT IN NUMBER,
  4.     p_res OUT REL_EST%ROWTYPE
  5. ) AS
REL_EST is a table with the structure i want

I also tried this

Expand|Select|Wrap|Line Numbers
  1. PROCEDURE RELACIONA_DATOS(
  2.     p_CVE_TABLA IN NUMBER,
  3.     p_CVE_TIPO_DATOENT IN NUMBER,
  4.     p_res OUT cursor_type
  5. );
cursor type is a ref cursor declared in apackage but i cant get it to work...

any ideas?
Can you POST your PACKAGE code for reference. Why is your cur_type not working:

check the below code for reference:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> create or replace package tttt AS
  3.   2  TYPE cur IS REF CURSOR;
  4.   3  PROCEDURE tttt1(a NUMBER, b OUT cur);
  5.   4  END tttt;
  6.   5  /
  7.  
  8. Package created.
  9.  
  10. SQL> create or replace package body tttt AS
  11.   2  PROCEDURE tttt1(a NUMBER, b OUT cur) IS
  12.   3  BEGIN
  13.   4  OPEN b FOR SELECT * FROM EMP where empno = a;
  14.   5  END tttt1;
  15.   6  end tttt;
  16.   7  /
  17.  
  18. Package body created.
  19.  
  20. SQL> ed
  21. Wrote file afiedt.buf
  22.  
  23.   1  declare
  24.   2  a SYS_REFCURSOR;
  25.   3  emp_rec EMP%ROWTYPE;
  26.   4  begin
  27.   5  tttt.tttt1(1,a);
  28.   6  LOOP
  29.   7  FETCH a INTO emp_rec;
  30.   8  EXIT WHEN a%NOTFOUND;
  31.   9  dbms_output.put_line(emp_Rec.ename||','||emp_rec.empno);
  32.  10  END LOOP;
  33.  11* end;
  34. SQL> /
  35. BOND,1
  36.  
  37. PL/SQL procedure successfully completed.
  38.  
  39.  
Dec 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Leon | last post by:
How can I code a stored procedure "within my codebehind page" that execute two or more stored procedures within a transaction? if so how would I pass values to each parameter? i.e. Begin Tran...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
2
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.