当我尝试执行此sql语句时,我得到例外 -
java.sql.SQLException: ORA-06550: line 1, column 429:
PLS-00103: Encountered the symbol "/" The symbol "/" was ignored.
这是我正在执行的以下sql字符串 - 这个sql有什么问题吗?它将检查表是否存在,如果它存在,那么它将不会创建表,如果它不存在,那么它将创建一个表。
public static final String CREATE1 = "DECLARE " +
"t_count INTEGER; " +
"v_sql VARCHAR2(1000) := 'create table " +DATABASE_TABLE + " ( " +
"(ID number(10,0), " +
"CGUID VARCHAR(255), " +
"PGUID VARCHAR(255), " +
"SGUID VARCHAR(255), " +
"USERID VARCHAR(255), " +
"ULOC VARCHAR(255), " +
"SLOC VARCHAR(255), " +
"PLOC VARCHAR(255), " +
"ALOC VARCHAR(255), " +
"SITEID VARCHAR(255), " +
"PRIMARY KEY ( ID ))'; " +
"BEGIN " +
"SELECT COUNT(*) " +
"INTO t_count " +
"FROM user_tables " +
"WHERE table_name = '" +DATABASE_TABLE + "'; " +
"IF t_count = 0 THEN " +
"EXECUTE IMMEDIATE v_sql; " +
"END IF; " +
"END; ";
它将作为 -
打印在控制台上DECLARE t_count INTEGER; v_sql VARCHAR2(1000) := 'create table LnPData((ID number(10,0), CGUID VARCHAR(255), PGUID VARCHAR(255), SGUID VARCHAR(255), USERID VARCHAR(255), ULOC VARCHAR(255), SLOC VARCHAR(255), PLOC VARCHAR(255), ALOC VARCHAR(255), SITEID VARCHAR(255), PRIMARY KEY ( ID ))'; BEGIN SELECT COUNT(*) INTO t_count FROM user_tables WHERE table_name = 'LnPData'; IF t_count = 0 THEN EXECUTE IMMEDIATE v_sql; END IF; END;
答案 0 :(得分:0)
删除';'在你的END IF语句之后再次运行它。