Re: [Q] Field formatting. How do you split one field to four.
Date: 1996/08/09
Message-ID: <4ugjhn$p1a_at_zimmer.CSUFresno.EDU>#1/1
In article <839418024.24575.0_at_eastman.demon.co.uk>,
<msoppitt_at_eastman.co.uk> wrote:
>Forms 4.5
>I have four fields, value 99 each and go to make one database field of
>ie 01||03 ||01||05 each set of two figures represent a description
>from an Lov (ie 4 diferent lovs make a discription that = A,B,C,D).
>How do i read the 8 numeric field from the database (ie on query) and
>split it into the four fields.
>I tried using a hidden box over the four 99 fields which would display
>for query mode and hide for insert but this is a bit messy.
>
>Any suggestions would be more than appreciated.
>Thanks, Michael
What you have done is about the only way, if you insist on the four 2-digit values being stored into one db column.
You need a hidden base-table item on your form to hold the 8-digit
number value. In a post-query
trigger, take this value and break it out into the 4 displayed
(non-base-table) items:
Declare Ch8 varchar2(8);
Begin
Ch8 := ltrim(to_char(:blk.Num_8,'99999999'));
:blk.Itm1 := substr(Ch8,1,2);
:blk.Itm2 := substr(Ch8,3,2); etc.
End;
Also be sure that the record status isn't changed from Query to Changed by the above code. If it is, set it back to Query.
In each of the 4 items' when-validate-item triggers, stuff the 2-digit
value back into the 8-digit item:
Declare Ch8 varchar2(8);
Begin
If length(nvl(:blk.Itm2,'00'))=2 then
Ch8 := ltrim(to_char(:blk.Num_8,'99999999')); Ch8 := substr(Ch8,1,2) || :blk.Itm2 || substr(Ch8,5,4); :blk.Num_8 := to_number(Ch8);
end if;
End;
(above example is for the second 2-digit item)
Regards,
Steve Cosner
Received on Fri Aug 09 1996 - 00:00:00 CEST