Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SAS PROC SQL : Insert statement query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1458
Location: Azeroth

PostPosted: Sat Mar 03, 2012 12:12 pm    Post subject: SAS PROC SQL : Insert statement query.
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: 1458
Location: Azeroth

PostPosted: Tue Mar 06, 2012 1:16 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us