Home > database >  Novice stored procedures problem
Novice stored procedures problem

Time:09-30

1.
The select servid into aa from tablea a where Anderson, d='111';
Aa is found out '222'

Select * from tableb b where b.i d=aa; - perform error, is wrong
Select * from tableb b where b.i d='222'; - perform success

2. If the stored procedure finally returns a result set, how to implement
The select Anderson d, a.n ame from tablea where Anderson, d='
Id, name the result is multiple records

CodePudding user response:

Select * from tableb b where b.i d=aa; - perform error, is wrong

Stored procedure inside don't let this query directly, you can insert into the select...

CodePudding user response:

That how to invoke, aa value must be a query results before value, how to use the insert into the select, can provide a complete statement

CodePudding user response:

. If a stored procedure finally returns a result set, how to implement

Use cursor, then dbms_output. Put_line printed
 declare 
- the type definition
Cursor c_job
Is
The select empno, ename, job, sal
The from emp
where job='MANAGER';
- define a cursor variable v_cinfo c_emp % ROWTYPE, the type of cursor c_emp a row in the data type
C_row c_job % rowtype;
The begin
For c_row c_job in loop
dbms_output.put_line(c_row.empno||'-'||c_row.ename||'-'||c_row.job||'-'||c_row.sal);
end loop;
end;
  • Related