oracle—pl/sql输出问题

hec6srdp  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(277)

我在oraclesqldeveloper中创建了这个过程。

CREATE OR REPLACE PROCEDURE CUST_NAME_LIMIT(
I_CUSTOMER_NUM IN CUSTOMER.CUSTOMER_NUM%TYPE,
I_CUSTOMER_NAME OUT CUSTOMER.CUSTOMER_NAME%TYPE,
I_CREDIT_LIMIT OUT CUSTOMER.CREDIT_LIMIT%TYPE)
AS
BEGIN
SELECT CUSTOMER_NAME, CREDIT_LIMIT
INTO
I_CUSTOMER_NAME, I_CREDIT_LIMIT
FROM
CUSTOMER
WHERE
CUSTOMER_NAME = I_CUSTOMER_NAME;
DBMS_OUTPUT.PUT_LINE(I_CUSTOMER_NAME);
DBMS_OUTPUT.PUT_LINE(I_CREDIT_LIMIT);
END;

当我试图用下面这个显示输出时,我得到一个错误

BEGIN
CUST_NAME_LIMIT('126');
END;

它应该能生产7500个玩具

cpjpxq1n

cpjpxq1n1#

除非你告诉我们你犯了什么错误,而不是让我们猜。但是嘿,这样更有趣!
当你宣布接受一个程序时 IN 还有两个 OUT 参数:

create or replace procedure cust_name_limit(
  i_customer_num in customer.customer_num%type,
  i_customer_name out customer.customer_name%type,
  i_credit_limit out customer.credit_limit%type)
as
begin
  select customer_name, credit_limit
  into i_customer_name, i_credit_limit
  from customer
  where customer_name = i_customer_name;
end;

您在调用它时也必须这样做:

declare
  l_custname customer.customer_name%type;
  l_credlim  customer.credit_limit%type;
begin
  CUST_NAME_LIMIT('126', l_custname, l_credlim);

  dbms_output.put_line(l_custname ||' - '|| l_credlim);
end;
/

在程序中显示结果没有多大意义;一旦它返回值就这样做。

相关问题