Re: [SQL] Populate unique column with default value

2007-10-01 Thread Jon Horsman
> On 10/1/07, Jon Horsman <[EMAIL PROTECTED]> wrote: > > ... Is there an elegant way i can set the username > > to be the extension of the current row ... > > UPDATE usertable > SET username = extension > WHERE username IS NULL; Hmm, that simple eh, don't

Re: [SQL] Populate unique column with default value

2007-10-01 Thread Jon Horsman
I guess what i'm looking for is something like the following, but i don't know how i'd do it. "UPDATE usertable SET username='SELECT extension FROM usertable WHERE id=' WHERE username ISNULL", Is this possible? Thanks, Jon. On 10/1/07, Jon Horsman <[E

[SQL] Populate unique column with default value

2007-10-01 Thread Jon Horsman
Hey, I'm updating the user table in our db to have a new column "username" as follows. ALTER TABLE usertable ADD COLUMN username varchar(64) UPDATE usertable SET username='' WHERE username ISNULL ALTER TABLE usertable ALTER COLUMN username SET NOT NULL ALTER TABLE usertable ADD CONSTRAINT usertabl

Re: [SQL] When is a shared library unloaded?

2007-08-20 Thread Jon Horsman
seems to be getting unloaded occasionally.We have logs in the _init( ) and _fini( ) of the library and we see that there are times when _fini( ) is getting called when you wouldn't expect it to be. Has anyone else had issues similar to this? Thanks, Jon. On 8/15/07, Jon Horsman &l

Re: [SQL] When is a shared library unloaded?

2007-08-15 Thread Jon Horsman
> "Jon Horsman" <[EMAIL PROTECTED]> writes: > > I'm randomly having issues with my triggers not firing (it turns out > > they are getting removed) and when i turned INFO logs on i saw the > > following > > > 2007-08-14 13:41:44.740305500 LOCATION

[SQL] When is a shared library unloaded?

2007-08-14 Thread Jon Horsman
I have a shared library loaded into postgresql using CREATE FUNCTION medbevent() RETURNS trigger as '/usr/lib/pgsql/libmedbevent.so' language 'C'; I'm randomly having issues with my triggers not firing (it turns out they are getting removed) and when i turned INFO logs on i saw the following 200

Re: [SQL] Connection Limit

2007-07-31 Thread Jon Horsman
Thanks for the help guys, i'll try your suggestions when i get a chance. Jon. ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Connection Limit

2007-07-30 Thread Jon Horsman
with host = 127.0.0.1 and then about 90% of all the processes are running as [local]. What does [local] mean, since in fact 127.0.0.1 is obviously local, how do they differ? Thanks, Jon. On 7/30/07, Jon Horsman <[EMAIL PROTECTED]> wrote: > Hello, > > I have a server running postgre

[SQL] Connection Limit

2007-07-30 Thread Jon Horsman
Hello, I have a server running postgres 7.4.13 and am starting to see errors "FATAL: connection limit exceeded for non-superusers". I'm not sure which one of my applications are hogging all of the connections, is there a way debug this somehow? Thanks, Jon. ---(end of

Re: [SQL] Foreign Unique Constraint

2007-03-29 Thread Jon Horsman
use a pre-insert triggers - one for each table. include something like I ended up going this route and it seems to work. Thanks for the help from all. I figured i'd post the solution to the list so it shows up when googled. Also, if my solution can be simplfied i'd appreciate knowing how. Th

Re: [SQL] Foreign Unique Constraint

2007-03-28 Thread Jon Horsman
Subqueries are not allowed in check constraints. I hadn't tried this yet but i'm sure i would have figured this out quickly then =) Thanks, Jon ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread Jon Horsman
Perhaps this...? It would work, but depending how many rows are in the table, it could become incredibly slow. The max rows in either table would be about 1000 or so, which isn't too many. There also should be a hole lot of inserting going on. ALTER TABLE table1 ADD CHECK (extension NOT IN (S

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread Jon Horsman
> create table table1 ( > id SERIAL PRIMARY KEY > extension UNIQUE, I can't find anything about this syntax in the docs... Oops, i'm missing a comma on that first line, should have been: create table table1 ( id SERIAL PRIMARY KEY, extension UNIQUE, ) I think, you should write a TRIGGER for

[SQL] Foreign Unique Constraint

2007-03-27 Thread Jon Horsman
I was wondering if someone could help point me in the right direction w.r.t. foreign unique constraints. I'm working on a legacy database and have a new requirement and am not sure how to do it. I have something like this create table table1 ( id SERIAL PRIMARY KEY extension UNIQUE, ) create

Re: [SQL] How to query information schema from shell script

2006-10-28 Thread Jon Horsman
I ended up going the pg_catalog route, something like (off the top of my head without a linux machine by to test it) output=$(psql -d template1 -t -c "select * from pg_database where datname='testdb'") if [ -z "$output" ]; then psql createdb testdb else echo 'the db already exists' fi I did the

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
For more information, i know how this is done using the pg_catalog but have yet to find out how its done with the information schema. select * from pg_catalog.pg_database where datname='test' will work for me but i can't find a solution with the IS. I'd prefer to use the IS if its as easily don

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
In my original email i forgot to mentioned i need to know if the database exists or not from the shell script. If it doesn't exist i would then create it. Currently i was just creating the db everytime our db script is run (since it doesn't hurt the db) but this generates the 'db already exists'

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
Thanks for the suggestions guys, i'll give this a try. Jon ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

[SQL] How to query information schema from shell script

2006-10-27 Thread Jon Horsman
Hey, I'm trying to figure out how i can query the postgres information schema from a bourne shell script on linux. I need to know if a user/table exists. Does someone mind giving me a quick example of how this works, is this possible? Thanks, Jon. ---(end of broadcast

[SQL] DB creation script questions

2006-08-16 Thread Jon Horsman
Hey All, I'm new to postgres and am wondering what the recommended way of creating an automated db creation script is. I've reading the postgres 8.1 manual but haven't seen much on this and google doesn't seem to be bringing up much either. I need to create a script that will create a database