Re: [SQL] Explicite typecasting of functions

2002-08-15 Thread Richard Huxton
On Thursday 15 Aug 2002 8:13 am, Andreas Tille wrote: > On Wed, 14 Aug 2002, Tom Lane wrote: > > CREATE TABLE without mentioning the default > > CREATE FUNCTION > > ALTER TABLE ... SET DEFAULT > > > > Note however that pg_dump is not bright enough to deduce that you did > > this. It w

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Andreas Tille
On Wed, 14 Aug 2002, Tom Lane wrote: > I concur with Richard that Andreas needs to solve a different problem, > but just for the record, the way you could do it is > > CREATE TABLE without mentioning the default > > CREATE FUNCTION > > ALTER TABLE ... SET DEFAULT > > Note howeve

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Andreas Tille
On Wed, 14 Aug 2002 Richard Huxton wrote: > > CREATE TABLE Items ( > > Idint DEFAULT NextItem() > > > CREATE FUNCTION NextItem() RETURNS INT4 > > AS 'select max(Id)+1 from Items where Id < 100;' > > LANGUAGE 'sql'; > > >ERROR: Relation "items" does not exist > > > > Any hin

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > On Wednesday 14 Aug 2002 10:30 am, Andreas Tille wrote: >> Any hint to solve this kind of chicken-egg-problem? > Your solution is not safe anyway - you could end up with two processes trying > to insert the next value. I concur with Richard that Andre

Re: [SQL] Explicite typecasting of functions

2002-08-14 Thread Richard Huxton
On Wednesday 14 Aug 2002 10:30 am, Andreas Tille wrote: > 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 > 100 and other. If I want to create a new Id in the "lower region" > I tried the foll

[SQL] Explicite typecasting of functions

2002-08-14 Thread Andreas Tille
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 100 and other. If I want to create a new Id in the "lower region" I tried the following (simplified example): CREATE TABLE Items ( Idint DEFA