Home » SQL & PL/SQL » SQL & PL/SQL » Simple Question about sql
Simple Question about sql [message #20177] Fri, 03 May 2002 16:04 Go to next message
shreya
Messages: 15
Registered: March 2001
Junior Member
Hi,

My query is like this.

SELECT a.invoice_id,
a.amount,b.amount
FROM invoice@x1 a,
invoice@x2 b
WHERE a.invoice_id(+) = b.invoice_id
AND ABS(a.amount-b.amount) /
DECODE(a.amount,0,1,a.amount)
>= &tolerance

I am having a problem.

When tolerance=0, then it should be >tolerance.
When tolerance=1, then it should be >=tolerance.
When tolerance is between 0 and 1, either >tolerance or >=tolerance works.

If u know workaround for this solution, please let me know. I will be very thankful to u.

Regards,
Shashank.
Re: Simple Question about sql [message #20178 is a reply to message #20177] Fri, 03 May 2002 16:55 Go to previous messageGo to next message
uma
Messages: 67
Registered: May 2001
Member
You can use " if then else" by using a CASE statement.

Syntax is like this

(CASE WHEN (TOLERANCE=0) THEN CONDN1
ELSE (CASE WHEN TOLERANCE =1 THEN CONDN2
ELSE ..(SO ON)..... END) END)

I have not given the complete query for you but you can try by using the above syntax.

I hope it helps,

Thx
Uma
Re: Simple Question about sql [message #20185 is a reply to message #20177] Mon, 06 May 2002 00:05 Go to previous messageGo to next message
tk
Messages: 6
Registered: May 2002
Junior Member
if ur select query is a part of PL/SQL SP/func then u can use if then else to form the query string n then execute it using the EXECUTE stmnt
Re: Simple Question about sql [message #20199 is a reply to message #20177] Mon, 06 May 2002 10:14 Go to previous message
shashank
Messages: 6
Registered: May 2002
Junior Member
Hi,

Could u show me how can i do that with PL/SQL?
If u can send a code snippet that would be great.

Thanx,
Shashank.
Previous Topic: Re: update multiple fields
Next Topic: Saving records selected by a lov
Goto Forum:
  


Current Time: Thu Apr 25 16:11:29 CDT 2024