BookmarkSubscribeRSS Feed
jfd
Calcite | Level 5 jfd
Calcite | Level 5

SQL code_1:

 

proc sql;

connect to oracle (user="xxxxx" pw="%superq(ex_pw)" path="&ex_path");

execute (ALTER SESSION SET CURRENT_SCHEMA=HCCLNW;)by ORACLE;

DISCONNECT from ORACLE;

run;

 

result_1:

ERROR: ORACLE execute error: ORA-00922: missing or invalid option.

 

SQL code_2:

proc sql;

connect to oracle (user="xxxxx" pw="%superq(ex_pw)" path="&ex_path");

execute (EXEC ALTER SESSION SET CURRENT_SCHEMA=HCCLNW;)by ORACLE;

DISCONNECT from ORACLE;

run;

Result_2:

ERROR: ORACLE execute error: ORA-06550: line 1, column 8:PLS-00103: Encountered the symbol "ALTER" when expecting one of the

following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an

identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock

insert open rollback savepoint set sql execute commit forall merge pipe purgeThe symbol "update was inserted before

"ALTER" to continue.ORA-06550: line 1, column 49:PLS-00103: Encountered the symbol ";" when expecting one of the

following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while

with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch

lock insert open rollback savepoint set sql execute commit forall merge pipe purgeThe symbol "exit" was substituted

for ";" to continue..

 

ANY IDEAs?

Thanks.

 

6 REPLIES 6
LinusH
Tourmaline | Level 20
Why can't you set the appropriate schema in the connect statement directly?
Data never sleeps
jfd
Calcite | Level 5 jfd
Calcite | Level 5
It does not work that way in a SAS pass_througth to Oracle. I did try it...
Tom
Super User Tom
Super User

Are you sure the schema exists? 

Does the ALTER command work when using some other tool to connect to your Oracle database?

See if it helps to add semi-colon to the Oracle command?

 

proc sql;
  connect to oracle (user="xxxxx" pw="%superq(ex_pw)" path="&ex_path");
  execute 
    (ALTER SESSION SET CURRENT_SCHEMA=HCCLNW ; )
  by ORACLE;
  DISCONNECT from ORACLE;
quit;

 

jfd
Calcite | Level 5 jfd
Calcite | Level 5

Thank you for the response.  The schema is right. It doe not require to have a semi-colon at the end of the Oracle command. Strange enough.

 

Thanks.

currymj
Calcite | Level 5

Did you ever find a solution? I am struggling to find one.

_KM
Calcite | Level 5 _KM
Calcite | Level 5

here's example of alter session that did not error. 

 

 

Proc sql;

      Connect to oracle as oraconnect (user="&ora_userid" password="&ora_pw" path=Prod connection=global);

   Execute by oraconnect(ALTER SESSION set "_push_join_predicate"=false);

    Create table……

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 5175 views
  • 0 likes
  • 5 in conversation