BookmarkSubscribeRSS Feed
nid197
Obsidian | Level 7
I have this sample code-i want to create a column in teradata table when data is updated.please help
I have triend using status='updated' in execute block but i am not able to update the table.

Proc sql,
Connect to tera,
%do i=1 to &cnt;
Execute(update &table
Set &colm=bquote('&&new&i)
&colm2=bquote('&&new2&i);
%end;
Quit;
3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You should do this on your database using triggers:

https://community.teradata.com/t5/Database/After-Insert-trigger/td-p/27510

 

Do not try to run one piece of software through another, use the software as given, its far far simpler and easier to manage.

The database connections are there to download and upload data to and from SAS/database, its not there for doing database tasks.

nid197
Obsidian | Level 7
But i am using various conditions to update a variable and i just want to check if the column i am targetting is being updated or not..for this i have to create a new column as a status of yes or no.can i do that?is it possible.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

No, what you are doing is using Macro, to generate a whole series of Base SAS code, which is converted to SQL, and then passed over to the Teradata database to execute.  As you can see that is four different peices of software.  To confound it further, your next question is how to check if the database - last one on the series of technologies - has completed the task.  To do that you would then need to read the data back off the database to see if it is correct.  Therefore, not just 4 technologies, but at least one write to the database, and one read from the database.  

As for "for this i have to create a new column as a status of yes or no.can i do that" - that very much depends, you are altering the table structure on the database, are you allowed/able to do such a thing?  I would have thought the database structure would be fixed?

Anyways, you would submit a alter table sql statement, something like:

proc sql;
...
execute('alter table... add status char(20);');
...
quit;

Then you could set that as part of your update statement.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 571 views
  • 0 likes
  • 2 in conversation