问题
When I am trying to execute this sql statement, I am getting exception as-
java.sql.SQLException: ORA-06550: line 1, column 429:
PLS-00103: Encountered the symbol "/" The symbol "/" was ignored.
This is the below sql String that I am executing- Is there anything wrong with this sql? It will check whether table is there or not, if it is there then it will not create a table and if it is not there, then it will create a table.
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; ";
It is getting printed on the console as-
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;
回答1:
Remove ';' after your END IF statement and run it again.
来源:https://stackoverflow.com/questions/10771089/java-sql-sqlexception-ora-06550