Re: [SQL] Returning a set of dates

2011-06-11 Thread C. Bensend
> http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING > >CREATE OR REPLACE FUNCTION public.next_bill_date(d date, period >interval, > i interval) > RETURNS SETOF date > AS $function$ > DECLARE > max_date date; > due_date date; > BE

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Leif Biberg Kristensen
I've written a blog post which I hope may be helpful to others in a similar situation: Thanks to Guillaume Lelarge, Tom Lane, and Andreas Kretschmer. You guys are great. regards, Leif http://code.google.com/p/yggdrasil-genealogy/ -- Sent via pgsql-sql mail

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Leif Biberg Kristensen
On Saturday 11. June 2011 17.23.40 Andreas Kretschmer wrote: > Leif Biberg Kristensen wrote: > > Can anybody tell me why this doesn't work? > > > > pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT > > MAX(source_id) FROM sources); > > ERROR: syntax error at or near "(" > > LINE

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Leif Biberg Kristensen
On Saturday 11. June 2011 17.14.21 Tom Lane wrote: > Guillaume Lelarge writes: > > On Sat, 2011-06-11 at 17:01 +0200, Leif Biberg Kristensen wrote: > >> Can anybody tell me why this doesn't work? > >> pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT > >> MAX(source_id) FROM sourc

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Andreas Kretschmer
Leif Biberg Kristensen wrote: > Can anybody tell me why this doesn't work? > > pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT > MAX(source_id) FROM sources); > ERROR: syntax error at or near "(" > LINE 1: CREATE SEQUENCE sources_source_id_seq START WITH (SELECT MAX... >

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Tom Lane
Guillaume Lelarge writes: > On Sat, 2011-06-11 at 17:01 +0200, Leif Biberg Kristensen wrote: >> Can anybody tell me why this doesn't work? >> pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT >> MAX(source_id) FROM sources); >> ERROR: syntax error at or near "(" > Because it's

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Guillaume Lelarge
On Sat, 2011-06-11 at 17:01 +0200, Leif Biberg Kristensen wrote: > Can anybody tell me why this doesn't work? > Because it's not supported. The START clause expects a value, not a subquery. > pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT > MAX(source_id) FROM sources); > ER

[SQL] Subselects not allowed?

2011-06-11 Thread Leif Biberg Kristensen
Can anybody tell me why this doesn't work? pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT MAX(source_id) FROM sources); ERROR: syntax error at or near "(" LINE 1: CREATE SEQUENCE sources_source_id_seq START WITH (SELECT MAX...

Re: [SQL] ANY for Array value check

2011-06-11 Thread Jasen Betts
On 2011-06-10, Emi Lu wrote: > Good morning, > > String array compare command, I forgot how to do it. > > E.g., > create table z_drop(id varchar[]); > insert into z_drop values('{"a1", "a2", "b1", "b2", "b3"}'); > > I'd like to do: > > select * from z_drop where id = any('a1', 'b1'); use the arra