[英]Calling user defined functions with Create Table in PostgreSql
在PostgreSQL中創建表時調用用戶定義的函數時出現錯誤
功能是:
CREATE OR REPLACE FUNCTION nextval_special()
RETURNS text AS
SELECT 'T'||to_char(nextval('entity_collector_team_team_code_seq'), 'FM10000')
LANGUAGE sql VOLATILE
COST 100;
表是:
CREATE TABLE testtable1
(
id integer,
teamcode AS (dbo.nextval_special())
)
我收到以下錯誤:
錯誤:“ AS”處或附近的語法錯誤
第4行:團隊代碼AS(dbo.nextval_special())
entity_collector_team_team_code_seq它的序列會生成類似1的序列號。創建表后,我期望按序列本身輸出為T10001和T10002。
提前致謝
Postgres沒有計算列。
您可能打算為該列分配一個默認值:
CREATE TABLE testtable1
(
id integer,
teamcode text not null default dbo.nextval_special()
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.