像这样的sql语句写成存储过程怎么写?
sql =" select tab1,tab2,tab3 from table where 1=1 ";
if (con1 == "")
{
sql += " and tab1 = '"+con1 +"' ;
}
if (con2 == "")
{
sql += " and tab2 = '"+con2 +"' ;
}
关键是条件怎么写
sql =" select tab1,tab2,tab3 from table where 1=1 ";
if (con1 == "")
{
sql += " and tab1 = '"+con1 +"' ;
}
if (con2 == "")
{
sql += " and tab2 = '"+con2 +"' ;
}
关键是条件怎么写
if conn1 is not null then
sql:=sql||' and tab1 = '''||con1 ||''' ;
end if;if conn2 is not null then
sql:=sql||' and tab2 = '''||con2 ||''' ;
end if;...
if conn1 is not null then
sql:=sql||' and tab1 = '''||con1 ||'''' ;
end if;if conn2 is not null then
sql:=sql||' and tab2 = '''||con2 ||'''' ;
end if;...