简体   繁体   中英

Stored Procedure Select

Well, i've been trying to built a SP in order to help me get all the fields from a table called TIKEt here is my table TIKET:

TABLE TIKET: 
IDTIKET    TYPE NUMBER
NOMBRE   TYPE VARCHAR2
EDITORIAL TYPE VARCHAR2
AUTOR  TYPE VARCHAR2
EDICION  TYPE VARCHAR2
PRECIO  TYPE NUMBER
CANTIDAD TYPE NUMBER,
FECHA  TYPE DATE default sysdate
NOMBRE_USER  TYPE VARCHAR2

and here it's my SP code:

`create or replace procedure get_tiket
(
 idtiket_ out number,
 nombres_ out varchar2,
 editorial_ out varchar2,
 autor_ out varchar2,
 edicion_ out varchar2,
 precio_ out number,
 cantidad_ out number,
 fecha_ out date,
 nombre_user_ in varchar2
)
is 
begin
select idtiket, nombre, editorial, autor, edicion, precio, cantidad, fecha into idtiket_, nombres_, editorial_, autor_, edicion_, precio_, cantidad_, fecha_ from tiket
where nombre_user=nombre_user_;
end;

/`

When i run this code in SQLPLus says: "Procedure Created" which i think means it's ok right? But when i called this Sp: exec get_tiket('ale'); it gives me this error:

call get_tiket('ale');

ERROR at line 1:

ORA-06553: PLS-306: wrong number or types of arguments in call to 'GET_TIKET'

What i want is to get all the fields from table TIKET depending on the user i need! Please thanks for your help ahead!

You have bunch of out parameters in stored procedure, and you have to pass them as well :

DECLARE idtiket number;
-- other variables
BEGIN
  EXEC get_tiket(idtiket, ..... 'ale');
END; 

Also, I guess function will work better than procedure in this case...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM