BookmarkSubscribeRSS Feed
RatoVampiro
SAS Employee

Hi all.
 
I tryng execute on teradata a Insert procedure from SAS, but i receive a strange error .
I need execute:


proc sql;
connect to teradata as tera (user=xxxxx password=xxxxx database='ZZZ' tdpid='db1xxxxh.xxx.xxxxx.xxx' MODE=TERADATA );
execute (
    INSERT INTO D_REL_PDD_V.VW_RTDM_SOLICITACAO
            (OID_RTDM_SOLICITACAO, NOM_FLUXO, NOM_TIPO, NOM_SUBTIPO, COD_AGENCIA)
    SELECT
            OID_RTDM_SOLICITACAO,
            NOM_FLUXO,
            NOM_TIPO,
            NOM_SUBTIPO,
            COD_AGENCIA
    FROM
            WORK.TESTE_TERA)
by tera;
execute (commit) by tera;
disconnect from tera;
quit;

 
This is a error:
ERROR: Teradata execute: Syntax error, expected something like a name or a Unicode delimited identifier or an 'UDFCALLNAME' keyword
       or '(' between the 'FROM' keyword and the 'WORK' keyword.
======================================================
 
Any ideas?
tks a lot!!!

4 REPLIES 4
Tom
Super User Tom
Super User

The EXECUTE ()  BY connection_name  statement means what it sounds like. You can only place code that the remote database can execute.  In particular the Teradata server knows nothing about your SAS work library.

 

If you want to insert data into a Teradata table from a SAS dataset then I would recommend making a libref that points to the Teradata database you are writing to and then just write the INSERT statement in PROC SQL (without the EXECUTE() statement). Or better still just use normal SAS statements instead of using PROC SQL at all.

 

libname TERA teradata
  user=xxxxx password=xxxxx
  database='D_REL_PDD_V'
  tdpid='db1xxxxh.xxx.xxxxx.xxx'
  MODE=TERADATA 
;

proc append
    data=work.teste_tera
    base=tera.VW_RTDM_SOLICITACAO
;
run;

 

RatoVampiro
SAS Employee

Hi Tom. Tks by your help.

 

By libref, i have success.

But in my insert i need concatenate two fields with legth of 32k and by libref this not work.

Cause this i need to run insert by EXECUTE().

Tom
Super User Tom
Super User

Upload the data first and then use EXECUTE () BY to do the concatenation.

 

%let username=XXXX;

libname TDWORK teradata
  user=&USERNAME password=xxxxx
  database=&USERNAME
  tdpid='db1xxxxh.xxx.xxxxx.xxx'
  MODE=TERADATA 
  CONNECTION=GLOBAL
  DBMSTEMP=yes
;

proc sql noprint ;
    connect to teradata  as tera
( user=&USERNAME password=xxxxx
  database=&USERNAME
  tdpid='db1xxxxh.xxx.xxxxx.xxx'
  MODE=TERADATA 
  CONNECTION=GLOBAL
) ;
  create table TDWORK.TESTE_TERA as 
     select * from work.teste_tera
  ;
  execute (
    INSERT INTO D_REL_PDD_V.VW_RTDM_SOLICITACAO
            (OID_RTDM_SOLICITACAO, NOM_FLUXO, NOM_TIPO, NOM_SUBTIPO, COD_AGENCIA)
    SELECT
            OID_RTDM_SOLICITACAO,
            NOM_FLUXO,
            NOM_TIPO,
            NOM_SUBTIPO,
            COD_AGENCIA
    FROM
            TESTE_TERA
   ) by TERA;
   drop table tdwork.teste_tera ;
quit;
RatoVampiro
SAS Employee

Hi Tom!

 

The solution work!!

 

Tks!!!!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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