Search code examples
oracle-databasesasddl

SAS pass through to Oracle to alter table


I am trying to use SAS pass through facility to alter an Oracle table and got this error:

ORACLE execute error: ORA-01735: invalid ALTER TABLE option.

Below is my code. Anybody knows what's wrong with my code? Thanks a lot in advance!

PROC SQL;

CONNECT TO oracle (user="myuserid" password="mypswd" path = "mypath") ;

EXECUTE 
(
  ALTER TABLE myschema.mytable
  ADD CONSTRAINT mytable_pk PRIMARY KEY (col_1, col_2, col_3);

) BY oracle;

QUIT;

Solution

  • Remove ; before ) BY oracle; at the end of EXECUTE statement and make :

    EXECUTE ( ALTER TABLE myschema.mytable ADD CONSTRAINT mytable_pk 
              PRIMARY KEY (col_1, col_2, col_3) ) BY oracle;
    

    to suppress the error.