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: 1521
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: 1521
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 Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts LIBDEF not working in called proc packerm CLIST & REXX 0 Fri Sep 15, 2017 7:22 pm
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am

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