gpt4 book ai didi

sequence - Sybase序列

转载 作者:行者123 更新时间:2023-12-02 01:47:39 24 4
gpt4 key购买 nike

我正在 sybase 中创建一个序列,但出现异常,有人可以帮忙吗?

CREATE OR REPLACE SEQUENCE dbo.event_id_sequence
START WITH 100
INCREMENT BY 1
MINVALUE 100
NO MAXVALUE
NO CACHE
NO CYCLE
go

GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID maintenance
GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID readonly
GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID reports
go

异常(exception):

[Error] Script lines: 1-14 ------------------------- Incorrect syntax near the keyword 'REPLACE'. Msg: 156, Level: 15, State: 2 [Executed: 7/7/14 2:06:02 PM EDT ] [Execution: 0/ms]

[Error] Script lines: 15-19 ------------------------ Incorrect syntax near 'USAGE'. Msg: 102, Level: 15, State: 84

[Error] Script lines: 15-19 ------------------------ Incorrect syntax near 'USAGE'. Msg: 102, Level: 15, State: 84

[Error] Script lines: 15-19 ------------------------ Incorrect syntax near 'USAGE'. Msg: 102, Level: 15, State: 84

[执行时间:美国东部时间 2014 年 7 月 7 日下午 2:06:02] [执行时间:0/毫秒]

最佳答案

Sybase ASE 没有序列,您找到的代码可能是从 Sybase IQ 或可能的 SQL Anywhere 中提取的。

您应该考虑使用 IDENTITY columns 而不是使用 sequence相反。

如果这不符合您的需求,Sybase suggests许多其他方法可能会为您提供您正在寻找的东西。

Methods:

Methods which can be used to produce a monotonic series are:

Max Plus One

Enhanced Max Plus One

Next Key Table

Identity Property

所有这些都在链接文档中有详细说明。

我还建议在 Migration from Oracle to ASE 上查看本演示文稿的第 20 页来自 SAP Techwave。有一些关于如何使用序列表/过程模拟 SEQUENCE 的示例代码。

CREATE TABLE my_seq (seq int) 
go
//initialize the sequence
INSERT INTO my_seq select 0
go
CREATE PROCEDURE get_seq (@seq int OUTPUT)
AS UPDATE my_seq SET seq = seq+1
SELECT @seq = seq FROM my_seq
go
// execute the sp to get the next sequence number
DECLARE @seq int
EXEC get_seq @seq OUTPUT
INSERT INTO m_table VALUES (@seq,..)
go

过时的链接 - http://www.sybase.com/detail?id=860

关于sequence - Sybase序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24616967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com