首页 > 解决方案 > PLSQL - ORA-01008 - 并非所有变量都绑定

问题描述

我正在尝试调用一个非常简单的 PLSQL 函数,但我猜不出我做错了什么:

CREATE OR REPLACE PACKAGE BODY KYC_OWN.KYCK_TEMP IS

FUNCTION PrintHelloWorld RETURN VARCHAR2 IS
BEGIN
  RETURN 'Hello World'; 
END printHelloWorld;

END KYCK_TEMP;

然后我这样调用函数:

call   KYC_OWN.KYCK_TEMP.PrintHelloWorld() INTO :x;

我想我需要在某处声明 x 变量,但是如何?

提前致谢

标签: sqloracleplsqlfunction-call

解决方案


你可以试试这个:

CREATE OR REPLACE PACKAGE BODY KYC_OWN.KYCK_TEMP IS

FUNCTION PrintHelloWorld RETURN VARCHAR2 IS
BEGIN
  RETURN ('Hello World'); 
END printHelloWorld;

END KYCK_TEMP;

或创建一个如下所示的变量并返回 g_helloworld

create or replace package constants as
g_helloworld constant varchar2(11) := 'Hello World';
function get_helloworld return varchar2;
end constants;

/
create or replace package body constants as
function get_helloworld return varchar2
is
begin
    return g_helloworld;
end get_helloworld;
end constants;

/


推荐阅读