create or replace procedure SP_name(name in VARCHAR2,money out number) is
begin
select sal into money from emp where ename=name; --Oracle自带的表,输入员工名字,求出工资
end SP_name;请问如何执行这个存储过程?
或者存储过程可能就写错了
begin
select sal into money from emp where ename=name; --Oracle自带的表,输入员工名字,求出工资
end SP_name;请问如何执行这个存储过程?
或者存储过程可能就写错了
GO
IF OBJECT_ID ( 'HumanResources.usp_GetEmployees', 'P' ) IS NOT NULL
DROP PROCEDURE HumanResources.usp_GetEmployees;
GO
CREATE PROCEDURE HumanResources.usp_GetEmployees
@lastname varchar(40),
@firstname varchar(20)
AS
SELECT LastName, FirstName, JobTitle, Department
FROM HumanResources.vEmployeeDepartment
WHERE FirstName = @firstname AND LastName = @lastname;
GO参考执行的时候
exec 存储过程名称
create procedure SP_name
@name varchar(50)
as
begin
select sal from emp where @name=name; --Oracle自带的表,输入员工名字,求出工资
end
GO
IF OBJECT_ID ( 'Production.usp_GetList', 'P' ) IS NOT NULL
DROP PROCEDURE Production.usp_GetList;
GO
CREATE PROCEDURE Production.usp_GetList @product varchar(40)
, @maxprice money
, @compareprice money OUTPUT
, @listprice money OUT
AS
SELECT p.name AS Product, p.ListPrice AS 'List Price'
FROM Production.Product p
JOIN Production.ProductSubcategory s
ON p.ProductSubcategoryID = s.ProductSubcategoryID
WHERE s.name LIKE @product AND p.ListPrice < @maxprice;
-- Populate the output variable @listprice.
SET @listprice = (SELECT MAX(p.ListPrice)
FROM Production.Product p
JOIN Production.ProductSubcategory s
ON p.ProductSubcategoryID = s.ProductSubcategoryID
WHERE s.name LIKE @product AND p.ListPrice < @maxprice);
-- Populate the output variable @compareprice.
SET @compareprice = @maxprice;
GO带有输出参数的,参考看看。
exec sp_name 并给@name赋值
return void
as
begin
SELECT vname into v_name from tttt where id=v_id;
return;
end;
create or replace function getOut()
return varchar(50)
as
declare v_name varchar(50);
begin
perform testOut(560736,v_name);
return v_name;
end;select getOut()