Thanks Chuck, now the SQL statements don't change DDS in any way...right?
-----Original Message-----
From: CRPence <CRPbottle@xxxxxxxxx>
To: midrange-l <midrange-l@xxxxxxxxxxxx>
Sent: Tue, Feb 14, 2012 3:34 pm
Subject: Re: fields in a PF
On 14-Feb-2012 12:13 , fbocch2595@xxxxxxx wrote:
if I add a new field to a PF, is there a way the system can assign a
unique value to the new field without updating the field within the
program code? I've been told it can so I figured if anyone would
know how it would be you folks.
If an SQL TABLE is OK, then review this scenario:
<code>
/* setup; i.e. presumes existing PF is TABLE ID */
create table id (c char, d dec)
;
insert into id values(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)
; -- 5 rows inserted in ID in LIB
/* action: have database assign a unique value to the */
/* new\added column for all existing rows */
alter table id
add column i int not null generated always as identity
( start with 0 increment by 1 cycle)
add constraint id_i_pk primary key (i)
; -- ALTER completed for table ID in LIB
/* review the effect of the action */
select * from id
; -- report from the SELECT follows:
....+....1....+....2....+.
C D I
0 0 0
1 1 1
2 2 2
3 3 3
4 4 4
******** End of data ********
</code>
Regards, Chuck
-
his is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
o post a message email: MIDRANGE-L@xxxxxxxxxxxx
o subscribe, unsubscribe, or change list options,
isit:
http://lists.midrange.com/mailman/listinfo/midrange-l
r email: MIDRANGE-L-request@xxxxxxxxxxxx
efore posting, please take a moment to review the archives
t
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.