drop table if exists test cascade;
create table test(id int, name varchar);
drop sequence seq_test_id;
create sequence seq_test_id ;
CREATE OR REPLACE procedure func_test(v_name varchar)
AS
DECLARE
v_id int;
BEGIN
v_id:=seq_test_id.nextval;
insert into test values(v_id,v_name);
select v_id;
END;
/
select * from test ;
call func_test('a');
select * from test ;
call func_test('b');
select * from test ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
实际操作
SQL> select * from test ;
SQL>
call func_test('a');
LINEID v_id
---------- -----------
1 1
SQL> select * from test ;
LINEID id name
---------- ----------- ----
1 1 a
SQL> call func_test('b');
LINEID v_id
---------- -----------
1 2
SQL> select * from test ;
LINEID id name
---------- ----------- ----
1 1 a
2 2 b
SQL>