对 apex 5.0 中的元素使用验证函数
use a validation function for an element in apex 5.0
我正在尝试对 APEX 5.0 中的应用程序项目实施验证。我正在使用 PL/SQL 函数返回一个布尔值
begin
if exists (select id_referencia
from items
where id_referencia = :P2_REFERENCIA)
then
return true;
else
return false;
end if;
end;
当我提交页面时,出现以下错误
ORA-06550: line 2, column 4: PLS-00204: function or pseudo-column
'EXISTS' may be used inside a SQL statement only ORA-06550: line 2,
column 1: PL/SQL: Statement ignored
if exists
是无效的 PL/SQL 语法。
您可以 count(*)
代替
declare
l_cnt integer;
begin
select count(*)
into l_cnt
from items
where id_referencia = :P2_REFERENCIA;
if( l_cnt >= 1 )
then
return true;
else
return false;
end if;
end;
如果你真的想做一个 exists
,你会做这样的事情。假设 id_referencia
是 table 的主键,我不知道您为什么要这样做。但是你可以
declare
l_exists integer;
begin
begin
select 1
into l_exists
from dual
where exists( select 1
from items
where id_referencia = :P2_REFERENCIA );
exception
when no_data_found
then
l_exists := 0;
end;
if( l_exists = 1 )
then
return true;
else
return false;
end if;
end;
如果你想在返回 BOOLEAN 的 PL/SQL 函数中使用 EXISTS,试试这个
DECLARE
v_exist NUMBER;
BEGIN
SELECT 1
INTO v_exist
FROM DUAL WHERE EXISTS (select id_referencia
from items
where id_referencia = :P2_REFERENCIA)
IF v_exist IS NOT NULL
THEN
RETURN true;
ELSE
RETURN false;
END IF;
END;
我正在尝试对 APEX 5.0 中的应用程序项目实施验证。我正在使用 PL/SQL 函数返回一个布尔值
begin
if exists (select id_referencia
from items
where id_referencia = :P2_REFERENCIA)
then
return true;
else
return false;
end if;
end;
当我提交页面时,出现以下错误
ORA-06550: line 2, column 4: PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL statement only ORA-06550: line 2, column 1: PL/SQL: Statement ignored
if exists
是无效的 PL/SQL 语法。
您可以 count(*)
代替
declare
l_cnt integer;
begin
select count(*)
into l_cnt
from items
where id_referencia = :P2_REFERENCIA;
if( l_cnt >= 1 )
then
return true;
else
return false;
end if;
end;
如果你真的想做一个 exists
,你会做这样的事情。假设 id_referencia
是 table 的主键,我不知道您为什么要这样做。但是你可以
declare
l_exists integer;
begin
begin
select 1
into l_exists
from dual
where exists( select 1
from items
where id_referencia = :P2_REFERENCIA );
exception
when no_data_found
then
l_exists := 0;
end;
if( l_exists = 1 )
then
return true;
else
return false;
end if;
end;
如果你想在返回 BOOLEAN 的 PL/SQL 函数中使用 EXISTS,试试这个
DECLARE
v_exist NUMBER;
BEGIN
SELECT 1
INTO v_exist
FROM DUAL WHERE EXISTS (select id_referencia
from items
where id_referencia = :P2_REFERENCIA)
IF v_exist IS NOT NULL
THEN
RETURN true;
ELSE
RETURN false;
END IF;
END;