Re: [SQL] ANY for Array value check

2011-06-11 Thread Jasen Betts
On 2011-06-10, Emi Lu em...@encs.concordia.ca 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

[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] 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); ERROR:

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Tom Lane
Guillaume Lelarge guilla...@lelarge.info 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 (

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Andreas Kretschmer
Leif Biberg Kristensen l...@solumslekt.org 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

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 guilla...@lelarge.info 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)

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 l...@solumslekt.org 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 (

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: http://solumslekt.org/blog/?p=321 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

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; BEGIN