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

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. Othe

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

[SQL] query results in XML format?

2008-03-06 Thread Emi Lu
Hello, Can someone suggestion some tutorial/hyperlinks/docs about how postgresql output query results into xml files? Thanks a lot! -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org

[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] Bit string help, please

2008-03-06 Thread Richard Huxton
[EMAIL PROTECTED] wrote: Thanks for the help again, Richard. I will look into upgrading to 8.3 as I think that will be the best solution. I don't think you'll regret it. There are some excellent improvements in 8.3 -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-

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] -Origin

Re: [SQL] Bit string help, please

2008-03-06 Thread tyrrill_ed
Thanks for the help again, Richard. I will look into upgrading to 8.3 as I think that will be the best solution. Ed Tyrrill -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: Thursday, March 06, 2008 10:36 AM To: Tyrrill, Ed Cc: pgsql-sql@postgresql.org Subject: Re:

Re: [SQL] Bit string help, please

2008-03-06 Thread Richard Huxton
[EMAIL PROTECTED] wrote: 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

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 m

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

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 cast