CREATE FUNCTION MS.RENODE
(NODECODE VARCHAR(10) )
RETURNS VARCHAR(10)
LANGUAGE SQL
NO EXTERNAL ACTION f1:
BEGIN ATOMIC
DECLARE V_FCODE VARCHAR(2);
DECLARE V_LCODE VARCHAR(8);
SET V_FCODE =SUBSTR(NODECODE,1,2);
SET LASTCODE = SUBSTR(NODECODE,3,8);
IF(V_FCODE ='00') THEN SET V_FCODE = '07';
ELSEIF(V_FCODE ='01') THEN SET V_FCODE = '08';
END IF;
RETURN V_FCODE||V_LCODE;
END;
以@为终结符号,就不会出现这种问题了
end@
然后在执行的时候用db2 -td@ -f xxx.sql 就ok了。
另外在执行新建表xxx.sql的时候,执行db2 -tvf crtdb.sql
出现end of file reached while reading the command
解决办法
[db2instl@localhost DB] file crtdb.sql
crtdb.sql:ISO-8859 text,with CRLF line terminators
[db2instl@localhost DB] dos2unix crtdb.sql
dos2unix:converting file crtdb.sql to UNIX format ...