BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Virga
Calcite | Level 5

Hello!

 

I need to create table in oracle database by using connect to oracle from SAS EG.

 

Proc sql;

connect to oracle as ora(PATH=ORAPATH USER=ORAUSER PASSWORD="ORAPASS");

  execute(

        CREATE TABLE SMS_INFO_CONTACT_HIST

       (App_id DECIMAL(16,0),

       Reg_id NUMBER(3),

       MSISDN VARCHAR(11),

       UCP_CONTACT_ID NUMBER(22,0),

       COALESCE_CONTACT_DTTM TIMESTAMP(0),

       camp_name VARCHAR(100),

       sender_name VARCHAR(50),

       contact_text VARCHAR(1024));

  create unique index UCP_CONTACT_ID on SMS_INFO_CONTACT_HIST (UCP_CONTACT_ID);

) by ora;

disconnect from ora;

quit;

 

But an error occurs.

SAS EG log:

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

 

Code works in PL SQL: 

    CREATE  TABLE SMS_INFO_CONTACT_HIST
         (App_id   DECIMAL(16,0),
          Reg_id    NUMBER(3),
          MSISDN VARCHAR(11),
          UCP_CONTACT_ID NUMBER(22,0),
          COALESCE_CONTACT_DTTM TIMESTAMP(0),
          camp_name VARCHAR(100),
          sender_name VARCHAR(50),
          contact_text VARCHAR(1024));

    create unique index UCP_CONTACT_ID on SMS_INFO_CONTACT_HIST (UCP_CONTACT_ID);

 

Can't understand, whats wrong. Maybe someone came across and can explain? I would really appreciate your help.

 

Thank You

1 ACCEPTED SOLUTION

Accepted Solutions
JBailey
Barite | Level 11

Hi @Virga ,

 

You have a couple of issues here. There is a ";" where there should not be and you need to add a second EXECUTE statement. 

 

I have tested this code and it works. 

 

Proc sql;
connect to oracle as ora(PATH=orapath USER=orauser PASSWORD="ORAPASS");
  execute(
        CREATE TABLE SMS_INFO_CONTACT_HIST
          (App_id DECIMAL(16,0),
           Reg_id NUMBER(3),
           MSISDN VARCHAR(11),
           UCP_CONTACT_ID NUMBER(22,0),
           COALESCE_CONTACT_DTTM TIMESTAMP(0),
           camp_name VARCHAR(100),
           sender_name VARCHAR(50),
           contact_text VARCHAR(1024)) -- removed a semicolon 

) by ora;
   execute (create unique index UCP_CONTACT_ID on SMS_INFO_CONTACT_HIST (UCP_CONTACT_ID)
) by ora;
disconnect from ora;
quit;

Good luck, if you need anything else, holler!

Best wishes,
Jeff

View solution in original post

3 REPLIES 3
JBailey
Barite | Level 11

Hi @Virga ,

 

You have a couple of issues here. There is a ";" where there should not be and you need to add a second EXECUTE statement. 

 

I have tested this code and it works. 

 

Proc sql;
connect to oracle as ora(PATH=orapath USER=orauser PASSWORD="ORAPASS");
  execute(
        CREATE TABLE SMS_INFO_CONTACT_HIST
          (App_id DECIMAL(16,0),
           Reg_id NUMBER(3),
           MSISDN VARCHAR(11),
           UCP_CONTACT_ID NUMBER(22,0),
           COALESCE_CONTACT_DTTM TIMESTAMP(0),
           camp_name VARCHAR(100),
           sender_name VARCHAR(50),
           contact_text VARCHAR(1024)) -- removed a semicolon 

) by ora;
   execute (create unique index UCP_CONTACT_ID on SMS_INFO_CONTACT_HIST (UCP_CONTACT_ID)
) by ora;
disconnect from ora;
quit;

Good luck, if you need anything else, holler!

Best wishes,
Jeff

Virga
Calcite | Level 5

@JBailey,

Amazing !! It worked ! )))

I understood about semicolons, thank you very much, Jeff ! 

Good luck you too! )


 

JBailey
Barite | Level 11

Hi @Virga 

 

I am happy it solved your problem. When you have more questions about using SAS with databases, feel free to include my username ( @JBailey ) in the post. The system will notify me.

If you don't mind, mark my previous post as the solution because it helps when others are searching for answers.

 

Best wishes,

Jeff

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 895 views
  • 3 likes
  • 2 in conversation