Home > database >  <new> Oracle stored procedure, compilation, normal call also normal, but is not the result out
<new> Oracle stored procedure, compilation, normal call also normal, but is not the result out

Time:09-27

Output - requirements: input the serial number of employees, employee wages, and department number
The create or replace procedure pro_find_by_student
(
- output parameters, the staff number, receive the passed parameter
P_s_id student. In s_id % type,
- returns the value of the output output parameters, name
P_s_name out student. S_name % type,
P_s_scor out student. S_scor % type
)
As
The begin
- according to the incoming number, return name and salary
The select s_name, s_scor into p_s_name, p_s_scor from student where s_id=p_s_id;
The end;

- the call
Declare
- must declare a variable to receive the output parameter
V_s_name STUDENT. S_NAME % type;
V_s_scor STUDENT. S_SCOR % type;
The begin
- call a stored procedure
Pro_find_by_student (12, v_s_name v_s_scor);
- the value returned by an output
DBMS_OUTPUT. PUT_LINE (' name: '| | v_s_name | |', achievement: '| | v_s_scor);
The end;

CodePudding user response:

CodePudding user response:

Pray god help me...

CodePudding user response:

Using SQL developer?

A DBMS window, try to open this,

CodePudding user response:

Where new said very meng force...

CodePudding user response:

CodePudding user response:

Oracle's return is not the grammar of the SQL SERVER (directly select a result set), is to use vernier returned,

CodePudding user response:

Now that you have written to the cursor variable, and then open the cursor, it is good to remove variable, suggest you use search a downstream target, you will know it soon

CodePudding user response:

The building Lord, stored procedure I tried no problem, the output value

CodePudding user response:

Do you take dbms_output. Disable

CodePudding user response:

SQL> The set serveroutput on
SQL> Declare
2 v_s_name student. S_name % type;
3 v_s_scor student. S_scor % type;
4
5 the begin
6 pro_find_by_student (13, v_s_name v_s_scor);
7 dbms_output. Put_line (' name: '| | v_s_name | |', achievement: '| | v_s_scor);
8 the end;
9/
Name: jack, grade: 100

PL/SQL procedure successfully completed,

SQL>

CodePudding user response:

Use dbms_output put_line need to be set in advance, the set serveroutput on the execution of this statement can see the output