Explicite typecasting of functions - Mailing list pgsql-sql

From Andreas Tille
Subject Explicite typecasting of functions
Date
Msg-id Pine.LNX.4.44.0208141123010.8253-100000@wr-linux02.rki.ivbb.bund.de
Whole thread Raw
Responses Re: Explicite typecasting of functions  (Richard Huxton <dev@archonet.com>)
List pgsql-sql
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.



pgsql-sql by date:

Previous
From: "philip johnson"
Date:
Subject: Re: pgsql-sql@postgresql.org
Next
From: Richard Huxton
Date:
Subject: Re: concurrent connections is worse than serialization?