涛哥,涛哥,求助

lilei0303 tooi 数据维护  2014-01-14 01:08:05
<![CDATA[
CREATE OR REPLACE FUNCTION test(code bigint) RETURNS setof zh_cn."Region" AS

$BODY$
DECLARE
rec zh_cn."Region"%rowtype;
BEGIN
IF code > 1000 THEN

FOR rec IN SELECT "Code", "Name" FROM zh_cn."Region" WHERE SUBSTR(CAST("Code" AS text),1,4) = CAST(code AS TEXT)
and CAST("Code" AS TEXT) != CONCAT(CAST(code AS TEXT),'00')
LOOP
RETURN NEXT rec;
END LOOP;

ELSEIF code > 100 and code < 1000 THEN

FOR rec IN SELECT "Code", "Name" FROM zh_cn."Region" WHERE SUBSTR(CAST("Code" AS text),1,3) = CAST(code AS TEXT)
and CAST("Code" AS TEXT) != CONCAT(CAST(code AS TEXT),'000')
LOOP
RETURN NEXT rec;
END LOOP;

ELSEIF code > 10 and code < 100 THEN

FOR rec IN SELECT "Code", "Name" FROM zh_cn."Region" WHERE SUBSTR(CAST("Code" AS text),1,2) = CAST(code AS TEXT)
and CAST("Code" AS TEXT) != CONCAT(CAST(code AS TEXT),'0000')
LOOP
RETURN NEXT rec;
END LOOP;
END IF;

END;
$BODY$
LANGUAGE 'plpgsql';

SELECT test(#{code});
]]>
在使用mybatis框架时,select部分写了一个过程,涛哥帮忙下,我这边总是报空指针异常,我估计可能是过程有问题,求指教
...全文
64 点赞 收藏 2
写回复
2 条回复
懒得去死 2014年01月17日
涛哥是谁????
回复 点赞
lilei0303 2014年01月15日
怎么没人啊,郁闷
回复 点赞
发动态
发帖子
PostgreSQL
创建于2012-11-23

290

社区成员

1284

社区内容

PostgreSQL相关内容讨论
社区公告
暂无公告