Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1532
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: 1532
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 query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us