带有IN,OUT参数的PL / SQL过程

时间:2015-04-07 04:48:49

标签: plsql

表架构

jobs(v_id, v_name, v_salary)

我想在v_name参数

中显示传递v_salary的{​​{1}}和id
IN

错误找不到预期的create or replace procedure jobs_select( id IN jobs.v_id%TYPE, position OUT jobs.v_position%TYPE, salary OUT jobs.v_salary%TYPE ) IS BEGIN select v_position into position, v_salary into salary from jobs where v_id = id; dbms_output.put_line('Position: ' || position || ' Salary: ' || salary); END; /

1 个答案:

答案 0 :(得分:2)

现在编辑的select语句中存在错误,请检查以下内容:

    create or replace procedure jobs_select(
        id      IN  jobs.v_id%TYPE,
        position    OUT jobs.v_position%TYPE,
        salary  OUT jobs.v_salary%TYPE
    )
    IS
    BEGIN
        select v_position, v_salary into
             position, salary
            from jobs where v_id = id;

        dbms_output.put_line('Position: ' || position 

    || ' Salary: ' || salary);
    END;
    /

    -- And executed it like this:

    set serveroutput on;
    Declare
    v_id Number := 9999;
    v_name varchar2(100);
    v_salary number;
    Begin
    jobs_select(v_id, v_name, v_salary);
    end;
/