Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 28, 2012 01:32 PM by Ajay2707
Member
375 Points
1033 Posts
Aug 28, 2012 08:43 AM|LINK
i would like to ask about i have 4 parameter, and those 4 parameter is used to filter column if the parameter is not empty.
how can i join those 4 parameter as filter column if it has value(not empty), if empty, just ignore this filter in select clause.
for example
IN para_1
IN para_2
in para_3
IN para_4
in this case only 2 and 4 para. has value
select * from table_1 where col_a=para_2 and col_b=para_4
but how can i join the clause and execute sql in package. (pl/sql oracle)
string sql='select * from table_a where 1=1');
if(para_1<>'') then
string con=' and col_1='+para_1;
end if;
string sql=sql+con
execute(sql);
my logic like the above coding.
Contributor
4445 Points
858 Posts
Aug 28, 2012 01:32 PM|LINK
Hi Memeber,
simple.
select * from table_1 where col_a=para_2 and ( col_b=para_4 or para_4 is null)
-_-
Member
375 Points
1033 Posts
join clause in package oracle
Aug 28, 2012 08:43 AM|LINK
i would like to ask about i have 4 parameter, and those 4 parameter is used to filter column if the parameter is not empty.
how can i join those 4 parameter as filter column if it has value(not empty), if empty, just ignore this filter in select clause.
for example
IN para_1
IN para_2
in para_3
IN para_4
in this case only 2 and 4 para. has value
select * from table_1 where col_a=para_2 and col_b=para_4
but how can i join the clause and execute sql in package. (pl/sql oracle)
string sql='select * from table_a where 1=1');
if(para_1<>'') then
string con=' and col_1='+para_1;
end if;
string sql=sql+con
execute(sql);
my logic like the above coding.
Ajay2707
Contributor
4445 Points
858 Posts
Re: join clause in package oracle
Aug 28, 2012 01:32 PM|LINK
Hi Memeber,
simple.