DECLARE
SEQ NUMBER;
BEGIN
INSERT INTO TEST111 VALUES(TEST111_S1.NEXTVAL,'AAA2')
RETURNING A1 INTO SEQ;
DBMS_OUTPUT.PUT_LINE(SEQ);
END;
DECLARE
SEQ NUMBER;
BEGIN
INSERT INTO TEST111 VALUES(TEST111_S1.NEXTVAL,'AAA3');
SELECT TEST111_S1.CURRVAL INTO SEQ FROM DUAL;
COMMIT;
DBMS_OUTPUT.PUT_LINE(SEQ);
END;
DECLARE
TYPE table_type IS TABLE OF column_name%TYPE;
v_tab table_type;
BEGIN
UPDATE table_name
SET expr1
RETURNING column_name BULK COLLECT INTO v_tab;
FOR i IN v_tab.first .. v_tab.last LOOP
DBMS_OUTPUT.put_line( l_tab(i));
END LOOP;
COMMIT;
END;
create or replace procedure p_stu_info(s_id number, s_name varchar2) is
v_name varchar2(10);
v_age number;
v_ErrMsg varchar2(200);
begin
execute immediate 'select name,age from student_test where id=:1 and name=:2'
using s_id, s_name
returning into v_name, v_age;
dbms_output.put_line(v_name || '的年龄为:' || to_char(v_age));
exception
when others then
v_ErrMsg := SUBSTRB(SQLERRM, 1, 200);
dbms_output.put_line('找不到相应学生');
end p_stu_info;
改成下面这样就ok了:
create or replace procedure p_stu_info(s_id number, s_name varchar2) is
v_name varchar2(10);
v_age number;
v_ErrMsg varchar2(200);
begin
execute immediate 'select name,age from student_test where id=:1 and name=:2'
into v_name, v_age
using s_id, s_name;
dbms_output.put_line(v_name || '的年龄为:' || to_char(v_age));
exception
when others then
v_ErrMsg := SUBSTRB(SQLERRM, 1, 200);
dbms_output.put_line('找不到相应学生,错误原因:'||v_ErrMsg);
end p_stu_info;