BookmarkSubscribeRSS Feed
Obsidian | Level 7

Inserting records into Oracle database using SQL passthrough query doesn’t shows the number of records inserted to the table.


Am using SQL passthrough query for inserting records to the DB table in Prod SQL.

The macro code is being included in the parent code that is scheduled for processing. When I run manually the macro code in SAS EG, I can see the number of records inserted in the table.

But when running in the include code in the parent code together, it doesn’t shows any logs messages on how many records are inserted in the oracle table.


In SAS EG – can see –

ORACLE: 0 rows inserted/updated/deleted. 153 1556630270 no_name 0 SQL (2)


While running in the parent code –  cannot see the records inserted in the oracle table as in below log. Already using %PUT &SQLXRC. &SQLXMSG. ; and this only shows 0 as return code is zero with no error message –




MPRINT(EXECUTESEQUERY):   CONNECT TO oracle ( path=xxx authdomain="xx") ;

MPRINT(EXECUTESEQUERY):   execute ( INSERT INTO tablename ( col1, col2 ) select

  1. app_transaction_key, T. scrub_key, sum(T.flag) as override_type from ( select a.app_transaction_key, b.scrub_key, 1 as flag from

schema.v_transaction_current a, schema.master b where trunc(a.s_effective_from) > '30-APR-2019' and

b.query_group_key = 80 and WAREHOUSE_CODE='PPP' AND CUSTOMER_NAME='SAN' union Select a.app_transaction_key, a.scrub_key, -1 as

flag from schema.v_transaction_current c, schema.v_tran_current a, schema.master b where

c.app_transaction_key=a.app_transaction_key and b.scrub_key = a.scrub_key and trunc(c.s_effective_from) > '30-APR-2019' and

b.query_group_key = 80 ) t group by T.app_transaction_key, T.scrub_key ) by oracle ;


MPRINT(EXECUTESEQUERY):   Disconnect from oracle;


NOTE: PROCEDURE SQL used (Total process time):

Super User Tom
Super User

Are you asking what ORACLE code you can use to mimic the SAS feature that displays the number of records inserted?

You might just try counting number of observations before and after the insert.

Obsidian | Level 7

Thanks for your reply


Yes, want to know what macro variables or code can help me know how many rows were inserted in the table using SAS SQL pass through query.

as we can do that count of rows after and before, but that is again going to add processing time.
Is there a way we can know from logs that how many rows were inserted like we get when we use libname statement or when we run it as a simple code and not include as sas code in another SAS Code.


Pyrite | Level 9

Hi ssaha OBSIDIAN,


You can enable the sastrace from options tab, for the specific transformation if the code is running under DI Studio or else if it's running in BASE then you can pass the below option just right above the passthrough step.


options sastrace=',,,d' sastraceloc=saslog nostsuffix;


The log will give you some information like this:

ORACLE: 158 rows inserted/updated/deleted.


Thanks and have a great day ahead.





Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1 like
  • 3 in conversation