免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2760 | 回复: 5
打印 上一主题 下一主题

自定义函数中为何不能用SQENCE? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-23 09:49 |只看该作者 |倒序浏览
create function Tp.GENERAL_IDKEY()
returns bigint
READS SQL DATA        
NO EXTERNAL ACTION
NOT DETERMINISTIC
return (nextval for TP.IDKey_Squ)@
  

-----------------------------------------------

DB21034E  该命令被当作 SQL
语句来处理,因为它不是有效的“命令行处理器”命令。在 SQL 处理期间,它返回:
SQL0348N  在此上下文中不能指定 "NEXTVAL FOR TP.IDKEY_SQU"。  LINE NUMBER=1.
SQLSTATE=428F9

论坛徽章:
0
2 [报告]
发表于 2005-11-23 09:50 |只看该作者
create sequence TP.IDKey_Squ start with 1 increment by 1@

论坛徽章:
0
3 [报告]
发表于 2005-11-23 09:53 |只看该作者

看了这个还是不明白

SQL0348
Message Text: &1 expression not used correctly.
Cause Text: The &1 sequence expression for &2 in &3 is not allowed. A NEXT VALUE or PREVIOUS VALUE sequence expression cannot be specified:
In a CREATE VIEW statement.
In a CREATE FUNCTION statement.
In a CHECK constraint.
In a CREATE TABLE or ALTER TABLE statement that uses a select-statement to define the table. A PREVIOUS VALUE expression cannot be specified in a CREATE TRIGGER statement. A NEXT VALUE expression can only be specified:
In the SELECT clause of the outermost SELECT. It cannot be used if the outermost SELECT uses the DISTINCT keyword, contains a GROUP BY or ORDER BY clause, or is part of a fullselect. It cannot be used in a CASE expression.
In the SELECT clause of the outermost SELECT of a common table expression. It cannot be used if the outermost SELECT uses the DISTINCT keyword, contains a GROUP BY or ORDER BY clause, or is part of a fullselect.
As an expression in the SET clause of an UPDATE. It cannot be used in a subselect in the SET clause of an UPDATE.
As an INSERT value in either the VALUES clause or in the SELECT clause of the fullselect.
As a value in a SET or VALUES statement.

Recovery Text: Remove the NEXT VALUE or PREVIOUS VALUE expression.
SQLCODE or SQLCODEs: -348
SQLSTATE or SQLSTATEs: 428F9

论坛徽章:
0
4 [报告]
发表于 2005-11-23 09:59 |只看该作者

原因是什么,为什么函数不能用?

原因是什么,为什么函数不能用?


他到底干了什么?

论坛徽章:
0
5 [报告]
发表于 2005-11-23 12:02 |只看该作者
你得先创建sequence

论坛徽章:
0
6 [报告]
发表于 2006-05-11 17:37 |只看该作者
触发器中碰到了同样的问题,奇怪的是相同的语句在linux下的数据库上可以通过,在windows平台下的就是不行,也报的这个错误,无语啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP