Re: [SQL] RETURN QUERY generates error

2008-03-07 Thread Yura Gal
> The error sounds suspiciously like what would happen if you tried to > use RETURN QUERY in a pre-8.3 version. > > regards, tom lane > Thanks a lot to all. Actually there were a mass of errors in my function. Now I rewrite it so as it works. It would be much more complica

Re: [SQL] RETURN QUERY generates error

2008-03-06 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Yura Gal wrote: >> all is fine until the last IF. Both RETURN QUERY blocks generate >> error: 'syntax error at or near SELECT ...' I feel that something >> wrong with casting _sequence var but I can't figure out the exact >> point. > Can't think why it'

Re: [SQL] RETURN QUERY generates error

2008-03-06 Thread Pavel Stehule
Hello I did simple test: postgres=# create or replace function unpack(anyarray) returns setof anyelement as $$ select $1[i] from generate_series(array_lower($1,1), array_upper($1,1)) g(i); $$ language sql; CREATE FUNCTION Time: 20,133 ms postgres=# select unpack(string_to_array('a,b,c',',')); un

Re: [SQL] RETURN QUERY generates error

2008-03-06 Thread Richard Huxton
Yura Gal wrote: IF _byblocks IS TRUE THEN RETURN QUERY SELECT regexp_split_to_table(array_to_string(_sequence, ','), E','); ELSE RETURN QUERY SELECT array_to_string(_sequence, ''); END IF; RETURN; END; $body$ LANGUAGE 'plpgsql' IMMUTABLE CALLED ON NULL INPUT SECURITY INVO

[SQL] RETURN QUERY generates error

2008-03-05 Thread Yura Gal
Here is my function: CREATE OR REPLACE FUNCTION "hg18"."get_genomeseq" (_chr varchar, _byblocks boolean, _starts integer [], _ends integer []) RETURNS SETOF text AS $body$ DECLARE _startinteger; _end integer; _sequence text[]; _seq50RECORD; _seq text