T-SQL的写法:
USE AdventureWorks;
GO
CREATE PROCEDURE FindEmployee @EmpLName varchar(20)
AS
SELECT @EmpLName = RTRIM(@EmpLName) + '%';
SELECT c.FirstName, c.LastName, a.City
FROM Person.Contact c JOIN Person.Address a ON c.ContactID = a.AddressID
WHERE c.LastName LIKE @EmpLName;
GO
EXEC FindEmployee @EmpLName = 'Barb';
PL/SQL的写法:
create or replace procedure Query_By_Key
(
p_key1 in varchar2,
p_key2 in varchar2,
p_cursor out JN_TABLE.JN_CTable
)*
as
str_Sql varchar2(500):=' select * from TableA' ||
' where pname like :v_key1 and pname like :v_key2 ' ;
begin
open p_cursor for str_Sql using '%' || p_key1|| '%' , '%'|| p_key2||'%';
end Query_By_Key;