如何在此过程中应用参数?
如何在此过程中应用 IN 参数作为 my_email 和 OUT 参数作为 my_salary:
CREATE OR REPLACE PROCEDURE FYI_CENTER AS
my_email employees.email%TYPE; -- **IN Parameter**
my_salary employees.salary%TYPE; -- **OUT Parameter**
BEGIN
SELECT email, salary INTO my_email, my_salary
FROM employees WHERE employee_id = 101;
DBMS_OUTPUT.PUT_LINE('My email = ' || my_email);
DBMS_OUTPUT.PUT_LINE('My salary = ' || my_salary);
END;
How do I apply IN parameter as my_email and OUT as my_salary in this procedure:
CREATE OR REPLACE PROCEDURE FYI_CENTER AS
my_email employees.email%TYPE; -- **IN Parameter**
my_salary employees.salary%TYPE; -- **OUT Parameter**
BEGIN
SELECT email, salary INTO my_email, my_salary
FROM employees WHERE employee_id = 101;
DBMS_OUTPUT.PUT_LINE('My email = ' || my_email);
DBMS_OUTPUT.PUT_LINE('My salary = ' || my_salary);
END;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法将值返回到 IN 参数中。我怀疑你想要的是一个像这样的通用程序:
...然后你可以这样调用:
You can't return a value into an IN parameter. What I suspect you want is a general purpose procedure like this:
... which you can then call like this:
您设置 IN 参数并将 OUT 参数添加为变量,如下所示:
You set the IN parameter and add the OUT parameter as a variable like this:
IN 和 OUT 相对于什么?目前两者都不是参数。看起来更像是您希望这两个参数都是 OUT 参数,而员工 ID 是 IN 参数,例如:
... 您可以这样调用:
您无法指定过程中的输入和输出变量(`%TYPE'),只是通用格式类型。正如托尼指出的,您可以将过程声明为:
IN and OUT relative to what? Neither is a parameter at the moment. It looks more like you want both of those to be OUT parameters, and the employee ID to be an IN parameter, something like:
... which you call call something like:
You can't specify the exact format of the input and output variables (`%TYPE') in a procedure, just the generic format type.As Tony pointed out, you could declare the procedure as: