delcare cursor testcur is select * from user_tables where tablename='TAB_NAME'; begin open test; if testcur%NOTFOUND then begin create table TAB_NAME(name varchar2(100)); end if; end;
delcare cursor testcur is select * from user_tables where tablename='TAB_NAME'; begin open test; if testcur%NOTFOUND then begin create table TAB_NAME(name varchar2(100)); end if; close testcur; end;
还有点错,应该是 OPEN TESTCUR不是OPEN TEST.
declare cursor testcur is select * from user_tables where tablename='TAB_NAME'; begin open TESTCUR; if testcur%NOTFOUND then begin create table TAB_NAME(name varchar2(100)); end if; close testcur; end;ORA-06550 第七行第一列: PLS-00103: 出现符号“CREATE"在需要下列之一时: begin case declare exit for goto if loop mod null pargma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << savepoint set sql execute commit forall merge pipe请问怎么解决?实在是第一次写PL/SQL麻烦了~!
写个过程:CREATE OR REPLACE PROCEDURE create_table (table_name IN VARCHAR2, column_names IN VARCHAR2) AS v_tblcount number; BEGIN SELECT count(1) into v_tblcount FROM USER_OBJECTS WHERE OBJECT_NAME = UPPER(table_name) AND OBJECT_TYPE = 'TABLE'; IF v_tblcount = 0 THEN EXECUTE IMMEDIATE 'CREATE TABLE ' || table_name || '(' || column_names || ')'; END IF; END;columns_name 格式: 'col1 date, col2 varchar2(10)'
declare cursor testcur is select table_name from user_tables where table_name='AA'; tname user_tables.table_name%type; begin open TESTCUR;fetch testcur into tname; if tname is null then begin execute immediate 'create table AA(name varchar2(100))'; end; end if; close testcur; end;
delcare
cursor testcur is select * from user_tables where tablename='TAB_NAME';
begin
open test;
if testcur%NOTFOUND then
begin
create table TAB_NAME(name varchar2(100));
end if;
end;
delcare
cursor testcur is select * from user_tables where tablename='TAB_NAME';
begin
open test;
if testcur%NOTFOUND then
begin
create table TAB_NAME(name varchar2(100));
end if;
close testcur;
end;
cursor testcur is select * from user_tables where tablename='TAB_NAME';
begin
open TESTCUR;
if testcur%NOTFOUND then
begin
create table TAB_NAME(name varchar2(100));
end if;
close testcur;
end;ORA-06550 第七行第一列:
PLS-00103: 出现符号“CREATE"在需要下列之一时:
begin case declare exit
for goto if loop mod null pargma raise return select update
while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
savepoint set sql execute commit forall merge pipe请问怎么解决?实在是第一次写PL/SQL麻烦了~!
EXECUTE IMMEDIATE 'create table TAB_NAME(name varchar2(100))';
AS
v_tblcount number;
BEGIN
SELECT count(1) into v_tblcount FROM USER_OBJECTS
WHERE OBJECT_NAME = UPPER(table_name) AND OBJECT_TYPE = 'TABLE';
IF v_tblcount = 0 THEN
EXECUTE IMMEDIATE 'CREATE TABLE ' || table_name || '(' || column_names || ')';
END IF;
END;columns_name 格式: 'col1 date, col2 varchar2(10)'
declare
cursor testcur is select table_name from user_tables where table_name='AA';
tname user_tables.table_name%type;
begin
open TESTCUR;fetch testcur into tname;
if tname is null then
begin
execute immediate 'create table AA(name varchar2(100))';
end;
end if;
close testcur;
end;