-- 创建存储器,表的id、 create or replace procedure create_table(i_id number,i_name varchar,i_sal number) as v_table varchar2(200) := 'emp_test'; -- 表名 v_count number(7); --判断表是否存在 1 表示存在 0表示不存在 begin --查询表是否存在,count(1)的值赋给 v_count select count(1) into v_count from user_tables where table_name = upper(v_table); --判断表是否存在。 if v_count = 0 then --创建表 execute immediate 'create table ' || v_table || '( id number(7), name varchar(200), sal number(7,2))'; --表存在 插入数据 elsif v_count = 1 then execute immediate 'insert into emp_test values(:1,:2,:3)' using i_id, i_name, i_sal; end if; commit; end; --测试 declare v_id number(7); v_name varchar(200); v_sal number(7,2); begin v_id :=&v_id; v_name :=&v_name; v_sal :=&v_sal; create_table(v_id,v_name,v_sal); end;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)