[comp.databases] Comparing screen values in Oracle

egranthm@jackson.UUCP (Ewan Grantham) (07/08/88)

We are setting up a banking transaction form using SQL*Forms in
Oracle. In one of our triggers we are comparing one screen value to
another. Is there anyone out there who knows if Oracle permits this?
We seem to be having trouble with it, and would like to know if that's
the reason why.

Thanks,
Ewan Grantham

-- 
Ewan Grantham    (601) 354-6454 ext.358 
...!uunet!nuchat!amyerg!egranthm or 
{pyramid or bellcore or tness..}!swbatl!jackson!egranthm
I'm not responsible for my bosses, and vice-versa

leo@philmds.UUCP (Leo de Wit) (07/09/88)

In article <275@jackson.UUCP> egranthm@jackson.UUCP (Ewan Grantham) writes:
>We are setting up a banking transaction form using SQL*Forms in
>Oracle. In one of our triggers we are comparing one screen value to
>another. Is there anyone out there who knows if Oracle permits this?
>We seem to be having trouble with it, and would like to know if that's
>the reason why.

You should have mentioned the way in which you compare, because it
should of course work. Whatever may be the cause in your case, the
following works (assuming the two values are in one block called blk
and named val1 and val2 resp):

select 'x' from dual
where :blk.val1 = :blk.val2

The trigger fails if the values are different.

I think the trigger mechanism using SQL is quite powerful; I built an
entire application and didn't have to resort to host language user
exits.

        Leo.

mike@psldev.Dayton.NCR.COM (Mike Matsko) (07/14/88)

In article <275@jackson.UUCP> egranthm@jackson.UUCP (Ewan Grantham) writes:
>We are setting up a banking transaction form using SQL*Forms in
>Oracle. In one of our triggers we are comparing one screen value to
>another. Is there anyone out there who knows if Oracle permits this?
>We seem to be having trouble with it, and would like to know if that's
>the reason why.

I have had a similar problem when the fields were number fields.  It 
appears that SQL*Forms does string compares even on number fields.

If you have a block called blk and number fields called fld1 and fld2 and 
fld1 has the value 7 and fld2 has the value 11 then the statement

select 'x' from dual
where :blk.fld1 < :blk.fld2

will fail because the string '7 ' is greater than '11'.


To fix this do the following,

select 'x' from dual
where to_number(:blk.fld1) < to_number(:blk.fld2) 

This should properly do the number compare.  That's how it works on
our Oracle at least.  Sorry if a previous article without the ':blk'
references in the statements got into the world, I tried to cancel it.