这是我的程序:
create or replace procedure emp_lookup
(empno IN emp55.empno%TYPE,
salary OUT emp55.sal%TYPE,
empname OUT emp55.ename%TYPE)
is
begin
select sal , ename INTO salary, empname
from emp55
where empno=empno;
EXCEPTION WHEN NO_DATA_FOUND THEN empname:='null';
salary:=-1;
END;
这是主叫代码:
SET SERVEROUTPUT ON
DECLARE
employee_name emp55.ename%TYPE;
employee_salary emp55.sal%TYPE;
BEGIN
emp_lookup (3244,salary,empname);
END;
/
执行时会出现此错误:
Error starting at line : 3 in command -
DECLARE
employee_name emp55.ename%TYPE;
employee_salary emp55.sal%TYPE;
BEGIN
emp_lookup (3244,salary,empname);
END;
Error report -
ORA-06550: line 5, column 20:
PLS-00201: identifier 'SALARY' must be declared
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored
它成功运行但我执行时
execute emp_lookup (3346, salary, empname);
显示此错误:
Error starting at line : 16 in command -
BEGIN emp_lookup (3346, salary, empname); END;
Error report -
ORA-06550: line 1, column 27:
PLS-00201: identifier 'SALARY' must be declared
ORA-06550: line 1, column 54:
PL/SQL: Statement ignored
答案 0 :(得分:0)
您可以在调用时使用绑定变量作为OUT
参数传递。
VARIABLE sal NUMBER
VARIABLE name VARCHAR2(20)
execute emp_lookup (3346, :sal, :name)
如果从PL / SQL块中调用该过程,则应在调用之前正确声明OUT
个变量。
DECLARE
salary emp55.sal%TYPE;
empname emp55.ename%TYPE;
BEGIN
emp_lookup (3346, salary, empname);
END;
/
答案 1 :(得分:0)
let express = require('express');
let app = express();
// Define the port to run on
app.set('port', 3000);
// Listen for requests
let server = app.listen(app.get('port'), onHttpConnection);
function onHttpConnection(req, res){
console.log("starting on " + server.address().port);
}
app.use(express.static('public'));
答案 2 :(得分:0)
<强>第一强> 更正您的过程代码(更改输入变量的名称)
需要进行此更正,因为您的where
子句(where empno=empno;
)始终为true
,因此表格的每一行都将被返回 - 这显然不是您的初衷。
create or replace procedure emp_lookup
(in_empno IN emp55.empno%TYPE,
salary OUT emp55.sal%TYPE,
empname OUT emp55.ename%TYPE)
IS
begin
select sal , ename INTO salary, empname
from emp55
where empno=in_empno;
EXCEPTION WHEN NO_DATA_FOUND THEN empname:='null';
salary:=-1;
END;
<强> Secod 强> 运行如下:
DECLARE
employee_name emp55.ename%TYPE;
employee_salary emp55.sal%TYPE;
BEGIN
emp_lookup (3244,employee_salary ,employee_name);
dbms_output.put_line(employee_name || ' ' || employee_salary);
END;
答案 3 :(得分:0)
你必须申报工资&#39;是:即
SET SERVEROUTPUT ON
DECLARE
empname emp55.ename%TYPE;
salary emp55.sal%TYPE;
BEGIN
emp_lookup (3244,salary,empname);
END;
/
否则,
SET SERVEROUTPUT ON
DECLARE
employee_name emp55.ename%TYPE;
employee_salary emp55.sal%TYPE;
BEGIN
emp_lookup (3244,employee_salary ,employee_name );
END;
/
我估计,上述任何解决方案都可以解决您的问题。