I'm trying to write a deployment script to run with SQL*Plus in a CI/CD pipeline but I can't find my way around what seems to be a very basic issue.
Here's a shortened version of the script release.sql:
DECLARE
vnum NUMBER;
BEGIN
SELECT COUNT(tname) INTO vnum FROM tab WHERE tname = 'DA_VERSION';
IF vnum = 0 THEN -- run create scripts
@ddl/da_001.sql
@ddl/da_002.sql
@dml/version.sql -- set initial version
END IF;
END;
da_001.sql looks like this:
CREATE TABLE TABLE_NAME
(
COLUMN1 NUMBER NOT NULL
, CONSTRAINT TABLE_NAME_PK PRIMARY KEY
(
COLUMN1
)
ENABLE
);
When I run
sqlplus.exe connection_string @release.sql
I get
CREATE TABLE DA_PRODUCTS * ERROR at line 6: ORA-06550: line 6, column 1: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:...
So it doesn't like the CREATE statement at the beginning of da_001.sql but I don't know why. What am I missing here?
CREATE
keyword. You'll needexecute immediate
or a different approach. – William Robertson Jul 22 '20 at 21:04@
is asqlplus
command, not a SQL or even PL/SQL command. It can only be used on thesqlplus
command line. PL/SQL code is run on the server without any notion about which client tool is used to call it or even access to the files on the client. – a_horse_with_no_name Jul 23 '20 at 6:14CREATE TABLE
is part of teh PLSQL block. – TenG Jul 23 '20 at 11:12