在大多数asp.net应用程序中通常都有包含过滤器的页面(通常有5个或更多标准,EX:filtr by:lastname,firstname,date等)。
主要处理TSQL(SQL Server 2000/2005)。我会在我的程序中处理标准,例如:
PARAMETERS Param1 VARCHAR(32), Param2 INT;
SELECT columns FROM table WHERE
([Param1] IS NULL OR column1 = [Param1])
AND
([Param2] IS NULL OR column2 = [Param2])
有人可以告诉我PL / SQL如何处理可选参数,谢谢
答案 0 :(得分:1)
例如:
create or replace procedure optPar(a in number, b in number := null, c number := 999) is
begin
dbms_output.put_line(a || ', ' || b || ', ' || c);
end;
该过程需要a
参数:
SQL> exec optPar();
BEGIN optPar(); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'OPTPAR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
您可以省略b, c
:
SQL> exec optPar(1);
1, , 999
PL/SQL procedure successfully completed.
SQL> exec optPar(1, 2);
1, 2, 999
PL/SQL procedure successfully completed.
SQL> exec optPar(1, 2, 3);
1, 2, 3
PL/SQL procedure successfully completed.
在这种情况下,显式传递参数比没有可选参数更重要,以便轻松了解您为每个参数赋予的值:
SQL> exec optPar( a=> 1, c=> 3);
1, , 3
PL/SQL procedure successfully completed.