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

Hi

I have the code shown below that puts an error in the log like this:

 

 delete from work._temp1 where a = 10
 -1
 ERROR: Error during execute of SQL statement: delete from work._temp1 where a = 10
 NOTE: Execution succeeded. No rows affected.

I can see it happens because I try to delete a record not found in the table. In the real case that I develop, this will certainly be the case from time to time. Is there any way I can avoid sas creating the ERROR:

If I do the same in PROC SQL, no ERROR appears in the log. 

 

data _temp1;
a=100;
run;

proc ds2 libs=work;
data _null_;
method run();
	declare varchar(500) sql;
	declare varchar (20) t;
	declare varchar(20) l;
	declare  varchar(5) n;
	declare int rc;
	t = '_temp1';
	l='work';
	n='10';
	sql = cat('delete from ',l, '.',t, ' where a = 10');
	put sql;	
	rc = sqlexec(sql);
	put rc ;
end;
enddata;
run;
quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Same here.

 

I have no workaround (option SCOND=NONE seems ineffective), but would report it to tech support as a bug. 

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Same here.

 

I have no workaround (option SCOND=NONE seems ineffective), but would report it to tech support as a bug. 

ChrisNZ
Tourmaline | Level 20

There one workaround of course, but it can be very expensive in the absence of an index: run a few macros lines to test that a record exists before calling the delete statement. 

b1958
Fluorite | Level 6

SAS support knew about the problem. There exists a feature request for getting this fixed.

 

SAS support recommended using the SQLSTMT package. 

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!

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
  • 718 views
  • 0 likes
  • 2 in conversation