Home » SQL & PL/SQL » SQL & PL/SQL » LONG Select statement
LONG Select statement [message #198315] Mon, 16 October 2006 09:40 Go to next message
shall42
Messages: 8
Registered: October 2006
Junior Member
Ques.(1) How do I create a Select statement based on the input
parameter?
Example
Create procedure myTest(myValue IN Number)
...
Begin
Select myFields
From myTable
IF myValue =1 Then
WHERE somecondition
ELSE
WHERE another condition
END IF;
==============================
I'm doing a conversion from Foxpro.
In FOxpro I would have
lcSql="Select myFields"
lcSql=lcSql+" FROM myTable"
IF myValue=1
lcSql=lcSql+" WHERE somecondition"
ELSE
lcSql=lcSql+" WHERE another condition"
ENDIF

TIA.
Re: LONG Select statement [message #198344 is a reply to message #198315] Mon, 16 October 2006 13:19 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You'll need to use dynamic SQL since your SQL is built at runtime. Also, be sure to either use bind variables, or application contexts to simulate bind variables - don't embed the literal search criteria in the SQL.

Right: last_name = :last_name
Wrong: last_name = 'Smith'
Previous Topic: co-related query
Next Topic: Database Auditing
Goto Forum:
  


Current Time: Wed Dec 07 10:40:17 CST 2016

Total time taken to generate the page: 0.08139 seconds