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: 1474
Location: Chennai

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: 1474
Location: Chennai

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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm


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