IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SAS PROC SQL : Insert statement query.


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Sat Mar 03, 2012 12:12 pm
Reply with quote

Hi,
We have a SAS PROC SQL table like below, with one column
Code:
Table : dreams
Var1

 1
 2
 3
 4
 5


The requirement is to enforce a integrity constraint on the table, so that the value of any new row inserted can only be max(var1) + 1.
i.e. For the above shown table, the table has to accept only insert statement only if Var1 = 6. Subsequent insert statement has to accept only Var1 = 7.

Code:
proc sql;                                           
create table dreams (var1 num);                     
insert into dreams                                   
set var1 = 1                                         
set var1 = 2                                         
set var1 = 3                                         
set var1 = 4                                         
set var1 = 5                                         
;                                                   
quit;                 
                             
proc sql;                                           
alter table dreams                                   
add constraint cons_var1 check(SOME CONDITION REQUIRED?);
quit;                                               


Could you please let me know how we can do this, or any other alternative method of achieving this.

Thanks,
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Mar 06, 2012 1:16 pm
Reply with quote

Looks like this is not possible directly with constraints :S icon_confused.gif
Constraint ensures that a specific set or range of values are the only values in a column. It can also check the validity of a value in one column based
on a value in another column within the same row.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:

Back to Top