两个很简单的FUNCTION
/*创建存在方法,用于数据导入用*/
CREATE OR REPLACE FUNCTION EXISTS_ECGDATA (IN_SQL IN VARCHAR2)
RETURN NUMBER
IS
V_SQL VARCHAR2(4000);
V_CNT NUMBER(1);
BEGIN
V_SQL := 'SELECT COUNT(*) FROM DUAL WHERE EXISTS ('|| IN_SQL ||')';
EXECUTE IMMEDIATE V_SQL INTO V_CNT;
RETURN(V_CNT);
END;
/*创建NewID()方法*/
CREATE OR REPLACE FUNCTION CREATEGUID
RETURN varchar2
is
guid varchar(64);
begin
guid := SYS_GUID();
return
substr(guid,1,8)||''-''||substr(guid,9,4)||
''-''||substr(guid,13,4)||''-''||substr(guid,17,4)
||''-''||substr(guid,21,12);
end CREATEGUID;
为什么这样放一起执行,只生成EXISTS_ECGDATA,而且编译是错误的?
------解决方案--------------------
我执行了一下,不会啊。如果你在命令行执行请稍微修改一下:
CREATE OR REPLACE FUNCTION EXISTS_ECGDATA (IN_SQL IN VARCHAR2)
RETURN NUMBER
IS
V_SQL VARCHAR2(4000);
V_CNT NUMBER(1);
BEGIN
V_SQL := 'SELECT COUNT(*) FROM DUAL WHERE EXISTS ('
------解决方案--------------------
IN_SQL
------解决方案--------------------
')';
EXECUTE IMMEDIATE V_SQL INTO V_CNT;
RETURN(V_CNT);
END;
/
/*创建NewID()方法*/
CREATE OR REPLACE FUNCTION CREATEGUID
RETURN varchar2
is
guid varchar(64);
begin
guid := SYS_GUID();
return
substr(guid,1,8)
------解决方案--------------------
''-''
------解决方案--------------------
substr(guid,9,4)
------解决方案--------------------
''-''
------解决方案--------------------
substr(guid,13,4)
------解决方案--------------------
''-''
------解决方案--------------------
substr(guid,17,4)
------解决方案--------------------
''-''
------解决方案--------------------
substr(guid,21,12);
end CREATEGUID;
/
------解决方案--------------------
楼上说的不错,命令行方式,改成/