Passing the column name on Where condition based on input parameter
924460Apr 20 2013 — edited Apr 21 2013Hi,
I am using Oracle10g. Following are my table schema.
Table Name : Codes
Columns( ID, Level0, Level1,Level2)
View Name : SampleView
I have a scenario : A parameter will be passed to my view from C# application. I need to cut the last 4 places of the parameter and need to check 4 conditions as follows :
1. IF last 4 places of parameter contains the value as "AMPD" then pass level0 column on where condition.
Sample code : A123XPAMPD
Expeted Result: Select * from Codes where Level0 ='A123XPAMPD'
2. IF last 4 places of parameter contains the value as "Alpha numeric" then pass level1 column on where condition.
Sample code : A123XPAA00
Expeted Result: Select * from Codes where Level1 ='A123XPAA00'
3. IF last 4 places of parameter contains the value as 0000 then pass level1 column on where condition.
Sample code : A123XP0000
Expeted Result: Select * from Codes where Level1 ='A123XP0000'
4. IF last 4 places of parameter contains the value as (cannot be all 0's) and cannot contain "Alphabets" then pass level2 column on where condition.
Sample code : A123XP1001
Expeted Result: Select * from Codes where Level2 ='A123XP1001'
Could any one please help me on writing this logic inside the view.
Thanks in advance.