BookmarkSubscribeRSS Feed
siruvuri
Calcite | Level 5

 

I tried calling the stored procedure from Teradata to SAS. But I was getting an error as Invalid session mode. Can anyone help me with this error?

 

Below is the code and error:

 
 
proc sql;
connect to teradata as tera(user = testuser pass= testpass tpid="XXXXX" connection=global);
 Create table work.sasresult as
         Select * from connection to tera(call dbname.spname('2016-01-15','2016-01-30','IND',?,?));
disconnect from tera;
quit;
 
 
ERROR: Teradata prepare: Invalid Session Mode for procedure execution. SQL statement was Call dbname.spname('2016-01-15','2016-01-30','IND',?,?);
 
 
Any suggestions or guidance would be greatly appreciated.
 
Thank you.

 

 

2 REPLIES 2
DaveBirch
Obsidian | Level 7

To use a Teradata Stored Procedure (or any DBMS Stored Procedure) you need to do it as a CALL EXECUTE, and the results would be a Teradata temporary table (or Global Temporary table, or some kind of scratch table).  You would then use Create table work.sasresult as  Select * from connection  ... to read that table into SAS.

BonnieS100
Calcite | Level 5

proc sql;

   connect to TERADATA

   (

       SERVER=ABCDE AUTHDOMAIN="ABC12345"

   );

 

 

   CREATE TABLE WORK.ABCD_AP_LDC_010_V AS  ----<<< CREATES A WORK.TABLE IN SAS

   select *

   from connection to TERADATA

   (

       SELECT * FROM TERADATA_SCHEMA.ABCD_AP_LDC_010_V

 

   );

   execute (commit) by TERADATA; 

 

 

   execute (

    CREATE VOLATILE TABLE ABCD_AP_LDC_010_V AS  ----<<< CREATES A VOLATILE TEMPORARY TABLE IN TERADATA 

      (SELECT TOP 5 AB_ID

      FROM

    TERADATA_SCHEMA.ABCD_AP_LDC_010_V) WITH DATA

      ON COMMIT PRESERVE ROWS

    ) by TERADATA;

   execute (commit) by TERADATA;

 

   execute(TERADATA_SCHEMA.STORED_PROCESS(PARAMETERS));  -----<<< TO EXECUTE A STORED PROCESS/MACRO 

   disconnect from TERADATA;

   quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1633 views
  • 1 like
  • 3 in conversation