Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ucsdhub!hp-sdd!ncr-sd!ncrlnk!ncrday!psldev!mike
From: mike@psldev.Dayton.NCR.COM (Mike Matsko)
Newsgroups: comp.databases
Subject: Re: Comparing screen values in Oracle
Keywords: Oracle SQL*forms
Message-ID: <325@psldev.Dayton.NCR.COM>
Date: 13 Jul 88 19:25:45 GMT
References: <275@jackson.UUCP>
Reply-To: mike@psldev.Dayton.NCR.COM (Mike Matsko)
Organization: Systems Engineering - Retail
Lines: 26

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.