Re: [SQL] Bit string help, please

2008-03-06 Thread Richard Huxton
[EMAIL PROTECTED] wrote: insert into table1 values( DEFAULT, B'1'::bit( n ) ); Where n is one of the parameters to the PL/pgSQL function, but that doesn't work. PostgreSQL doesn't like having a variable for the bit string length. Does anyone have any ideas how I could achieve this? Try

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

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',','));

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's not happy

Re: [SQL] Bit string help, please

2008-03-06 Thread tyrrill_ed
I tried this real quick at the psql command prompt, and unfortunately it doesn't work: mydb=# select ('1' || repeat('0',7))::bit varying; ERROR: cannot cast type text to bit varying I appreciate the try though. Any other ideas? I am using PostgreSQL 8.2.3.1. I don't know if that matters too

Re: [SQL] Bit string help, please

2008-03-06 Thread Tena Sakai
Hi Ed, I tried exactly what you did and it works for me. My postgres is 8.3.0 running on redhat advanced server. This is what it told me: prompt=# SELECT ('1' || repeat('0', 7))::bit varying; varbit -- 1000 (1 row) prompt=# Regards, Tena Sakai [EMAIL PROTECTED]

[SQL] Composite UNIQUE across two tables?

2008-03-06 Thread Jamie Tufnell
Hi, I'm remodeling our authentication tables at the moment to accomodate future changes. I've hit a wall and thought I'd ask here for some help. Hopefully I'm just missing something simple. I'll do my best to explain the domain.. We have users, sites, and groups of sites. Usernames should be

Re: [SQL] query results in XML format?

2008-03-06 Thread Peter Eisentraut
Emi Lu wrote: Can someone suggestion some tutorial/hyperlinks/docs about how postgresql output query results into xml files? http://www.postgresql.org/docs/8.3/static/functions-xml.html#FUNCTIONS-XML-MAPPING -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] Composite UNIQUE across two tables?

2008-03-06 Thread Jamie Tufnell
Hi Ray, Thanks for your reply! On 3/6/08, Ray Madigan [EMAIL PROTECTED] wrote: I don't think I understand. You have a constraint that a user has implied access to any site in the group, explain why you think it would be wrong to have the group_id as an instance variable fro the user.

Re: [SQL] Composite UNIQUE across two tables?

2008-03-06 Thread Jorge Godoy
Em Thursday 06 March 2008 22:10:14 Jamie Tufnell escreveu: I already have site_id in the users table and I can determine the site_group_id from that. So it seems redundant to me, to store site_group_id for each user as well. Also, I'm not sure how I would enforce that the site_group_id