Hello,
I want to insert new data into a table with increasing data set ids.
The table has two separate "regions" of data: Those with Ids below
1000000 and other. If I want to create a new Id in the "lower region"
I tried the following (simplified example):
CREATE TABLE Items ( Id int DEFAULT NextItem()
) ;
/* ERROR: Function 'nextitem()' does not existUnable to identify a function that satisfies the given argument
typesYoumay need to add explicit typecasts*/
CREATE FUNCTION NextItem() RETURNS INT4 AS 'select max(Id)+1 from Items where Id < 1000000;' LANGUAGE 'sql';
I did not found any trace of documentation how to do an explicit typecast
for the function. Defining the function first fails because:
ERROR: Relation "items" does not exist
Any hint to solve this kind of chicken-egg-problem?
Kind regards
Andreas.