db2look 导出的函数 function 无法执行,谁能看看是怎么回事

SET CURRENT SCHEMA = "F12SITST";
SET CURRENT PATH = "SYSIBM","SYSFUN","SYSPROC","F12SITST";
CREATE FUNCTION F12SITST.F_LOT_TYPE (IN_LOT_ID VARCHAR(64) ) RETURNS CHARACTER(16)
LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA STATIC DISPATCH CALLED ON
NULL INPUT EXTERNAL ACTION INHERIT SPECIAL REGISTERS BEGIN ATOMIC return
with tmp(first,second,third) as ( select substr(IN_LOT_ID,locate('.',IN_LOT_ID)+1,1
), substr(IN_LOT_ID,locate('.',IN_LOT_ID)+2,1 ), substr(IN_LOT_ID,locate('.',IN_LOT_ID)+3,1
) from sysibm.sysdummy1 ) select (case when first='0' and second='0' and
third='0' then 'PARENT' when first>='A' and first<='Z' and second='0' and
third='0' then 'SPLIT' when second>='A' and second<='Z' and third>='1'
and third<='9' then 'AUTOSPLIT' when second>='0' and second<='9' and third>='A'
and third<='Z' then 'REWORK' else 'UNKNOWN' end) as lot_type from tmp;
END;
参与8

7同行回答

linux123linux123数据库管理员郑州银行
这是什么道理,为什么要加个--这呢显示全部
这是什么道理,为什么要加个--这呢收起
互联网服务 · 2011-12-14
浏览1105
drdb2drdb2系统工程师se
回复 6# telnet4730 实战中学来的:)To avoid confusion, 不过我建议用@结尾, for example....END@when you run the script, do:db2 -td@ -vf scriptname显示全部
回复 6# telnet4730

实战中学来的:)

To avoid confusion, 不过我建议用@结尾, for example
....
END@

when you run the script, do:

db2 -td@ -vf scriptname收起
互联网服务 · 2011-11-28
浏览1085
telnet4730telnet4730课题专家组数据库运维工程师光大证券
这是什么道理,为什么要加个--这呢显示全部
这是什么道理,为什么要加个--这呢收起
证券 · 2011-11-28
浏览1087
weiruan85weiruan85数据库管理员ibm
db2inpe@dmsrvr:~> db2 -tvf test.sqlwith tmp(first,second,third) as ( select substr(ID,locate('.',ID)+1,1), substr(ID,locate('.',ID)+2,1 ), substr(ID,locate('.',ID)+3,1) from test ) select ( case when first='0' and second='0' and third='0' then 'PAREN...显示全部
db2inpe@dmsrvr:~> db2 -tvf test.sql
with tmp(first,second,third) as ( select substr(ID,locate('.',ID)+1,1), substr(ID,locate('.',ID)+2,1 ), substr(ID,locate('.',ID)+3,1) from test ) select ( case when first='0' and second='0' and third='0' then 'PARENT' when first>='A' and first<='Z' and second='0' and third='0' then 'SPLIT' when second>='A' and second<='Z' and third>='1' and third<='9' then 'AUTOSPLIT' when second>='0' and second<='9' and third>='A' and third<='Z' then 'REWORK' else 'UNKNOWN' end ) as lot_type from tmp

LOT_TYPE
---------

  0 record(s) selected.


db2inpe@dmsrvr:~> vi test.sql
db2inpe@dmsrvr:~> db2 -tvf test.sql
~ SET CURRENT SCHEMA = "F12SITST"
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0007N  The character "~" following "BEGIN-OF-STATEMENT" is not valid.
SQLSTATE=42601

SET CURRENT PATH = "SYSIBM","SYSFUN","SYSPROC","F12SITST"
DB20000I  The SQL command completed successfully.

CREATE FUNCTION F12SITST.F_LOT_TYPE (ID VARCHAR(64) ) RETURNS CHARACTER(16)
LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA STATIC DISPATCH CALLED ON
NULL INPUT EXTERNAL ACTION INHERIT SPECIAL REGISTERS BEGIN ATOMIC return
with tmp(first,second,third) as ( select substr(ID,locate('.',ID)+1,1
), substr(ID,locate('.',ID)+2,1 ), substr(ID,locate('.',ID)+3,1
) from test ) select  ( case when first='0' and second='0' and
third='0' then 'PARENT' when first>='A' and first<='Z' and second='0' and
third='0' then 'SPLIT' when second>='A' and second<='Z' and third>='1'
and third<='9' then 'AUTOSPLIT' when second>='0' and second<='9' and third>='A'
and third<='Z' then 'REWORK' else 'UNKNOWN' end ) as xx  from tmp
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "from tmp" was found following "UNKNOWN' end )
as xx".  Expected tokens may include:  "".  LINE NUMBER=10.
SQLSTATE=42601


函数里边这么写有问题,貌似不支持吧。最好查infocenter确认下收起
政府机关 · 2011-11-28
浏览1065
drdb2drdb2系统工程师se
error message 是什么显示全部
error message 是什么收起
互联网服务 · 2011-11-27
浏览1081
telnet4730telnet4730课题专家组数据库运维工程师光大证券
补充一下db2的版本是db2v8显示全部
补充一下db2的版本是db2v8收起
证券 · 2011-11-27
浏览1115
drdb2drdb2系统工程师se
你一定是把“--”编辑掉了。CREATE FUNCTION F12SITST.F_LOT_TYPE (IN_LOT_ID VARCHAR(64) ) RETURNS CHARACTER(16)LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA STATIC DISPATCH CALLED ONNULL INPUT EXTERNAL ACTION INHERIT SPECIAL REGISTERS BEGIN ATOMIC retur...显示全部
你一定是把“--”编辑掉了。
CREATE FUNCTION F12SITST.F_LOT_TYPE (IN_LOT_ID VARCHAR(64) ) RETURNS CHARACTER(1
6)
LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA STATIC DISPATCH CALLED ON
NULL INPUT EXTERNAL ACTION INHERIT SPECIAL REGISTERS BEGIN ATOMIC return
with tmp(first,second,third) as ( select substr(IN_LOT_ID,locate('.',IN_LOT_ID)+
1,1
), substr(IN_LOT_ID,locate('.',IN_LOT_ID)+2,1 ), substr(IN_LOT_ID,locate('.',IN_
LOT_ID)+3,1
) from sysibm.sysdummy1 ) select (case when first='0' and second='0' and
third='0' then 'PARENT' when first>='A' and first<='Z' and second='0' and
third='0' then 'SPLIT' when second>='A' and second<='Z' and third>='1'
and third<='9' then 'AUTOSPLIT' when second>='0' and second<='9' and third>='A'
and third<='Z' then 'REWORK' else 'UNKNOWN' end) as lot_type from tmp;--
END;
DB20000I  The SQL command completed successfully.收起
互联网服务 · 2011-11-27
浏览1075

提问者

telnet4730
数据库运维工程师光大证券

相关问题

相关资料

相关文章

问题状态

  • 发布时间:2011-11-27
  • 关注会员:1 人
  • 问题浏览:6096
  • 最近回答:2011-12-14
  • X社区推广