Re: [GENERAL] How to insert on duplicate key?

2007-12-24 Thread Greg Smith
On Tue, 25 Dec 2007, [EMAIL PROTECTED] wrote: insert a record into a table, and when the record already exists(according to the primary key), update it. There is an example that does exactly that, 37-1, in the documentation at http://www.postgresql.org/docs/current/static/plpgsql-control-stru

Re: [GENERAL] How to insert on duplicate key?

2007-12-24 Thread [EMAIL PROTECTED]
Michael Glaesemann wrote: On Dec 24, 2007, at 22:03 , [EMAIL PROTECTED] wrote: I have googled and currently the only way I can find is do query first and then update or insert. Or alternatively, UPDATE and see if you've affected any rows. If not, insert. Michael Glaesemann grzm seespotcod

Re: [GENERAL] How to insert on duplicate key?

2007-12-24 Thread Michael Glaesemann
On Dec 24, 2007, at 22:03 , [EMAIL PROTECTED] wrote: I have googled and currently the only way I can find is do query first and then update or insert. Or alternatively, UPDATE and see if you've affected any rows. If not, insert. Michael Glaesemann grzm seespotcode net

[GENERAL] How to insert on duplicate key?

2007-12-24 Thread [EMAIL PROTECTED]
Hi all, I have a table like this, CREATE TABLE mytable( avarchar(40), btext, ctext, PRIMARY KEY (a, b) ); What I want to do is: insert a record into a table, and when the record already exists(according to the primary key), update it. I know that there is a ON DUPLICATE clause

Re: [GENERAL] Postgres from PHP in Leopard

2007-12-24 Thread Michael Glaesemann
On Dec 24, 2007, at 19:28 , Shane Ambler wrote: Also their updates can often wipe out a custom built version of php. If you install your custom-built PHP in /usr/local or use MacPorts (which uses /opt) or Fink (which uses /sw IIRC), you don't have to worry about anything being overwritten

Re: [GENERAL] Postgres from PHP in Leopard

2007-12-24 Thread Shane Ambler
brian wrote: Steve Atkins wrote: On Dec 20, 2007, at 7:35 AM, Gordon wrote: On Dec 19, 11:32 am, Gordon <[EMAIL PROTECTED]> wrote: I'm a web developer who does a lot of work in PHP. The back end database we use is bases on Postgres. I am trying to set my new MacBook Pro up as a developm

Re: [GENERAL] copy database by copying datafiles ?

2007-12-24 Thread Alex Vinogradovs
Sorry guys, was my mistake... I found one file missing in global tablespace. Copying it there fixed the problem. Thanks everyone! On Mon, 2007-12-24 at 14:07 -0800, Richard Broersma Jr wrote: > --- On Mon, 12/24/07, Alex Vinogradovs <[EMAIL PROTECTED]> wrote: > > > P.S. datafiles are 85GB in s

Re: [GENERAL] copy database by copying datafiles ?

2007-12-24 Thread Richard Broersma Jr
--- On Mon, 12/24/07, Alex Vinogradovs <[EMAIL PROTECTED]> wrote: > P.S. datafiles are 85GB in size, I couldn't really dump > and restore... Don't for get the steps of compressing and uncompressing between dump and restore.;) If the file is still too big, you can always use tar to spit the fil

Re: [GENERAL] copy database by copying datafiles ?

2007-12-24 Thread Thomas Hart
I expect that it is not quite as easy as that. My advice (as a non-expert) would be to install the same version of pg onto the target machine, and use etl (http://en.wikipedia.org/wiki/Extract,_transform,_load) to transfer the data. Basically you just need a small script (I like PHP myself, bu

[GENERAL] copy database by copying datafiles ?

2007-12-24 Thread Alex Vinogradovs
Guys, I've created a copy of my database to run on a different server by copying entire data directory while database instance was stopped. Database generally works on the target machine, but I'm getting following error when trying to create a plpgsql function : ERROR: could not open relation 166

Re: [GENERAL] Postgres from PHP in Leopard

2007-12-24 Thread brian
Steve Atkins wrote: On Dec 20, 2007, at 7:35 AM, Gordon wrote: On Dec 19, 11:32 am, Gordon <[EMAIL PROTECTED]> wrote: I'm a web developer who does a lot of work in PHP. The back end database we use is bases on Postgres. I am trying to set my new MacBook Pro up as a development system. I

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Martijn van Oosterhout
On Mon, Dec 24, 2007 at 04:10:45PM -0200, Henrique Pantarotto wrote: > Hi Richard, > > I actually want to change the enum values after I have created and > associated it to a table colum. > > Is it possible? No. An enum is defined by its members. You can't change a type after it is created, not

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Richard Broersma Jr
--- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote: > I actually want to change the enum values after I have > created and > associated it to a table colum. It looks like you will have to drop the type and re-create it. You might have to try a couple of tests: 1) BEGIN TRANSACT

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Henrique Pantarotto
Hi Richard, I actually want to change the enum values after I have created and associated it to a table colum. Is it possible? Thanks. On Mon, 24 Dec 2007 09:50:09 -0800 (PST) Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > --- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote:

Re: [GENERAL] Postgres from PHP in Leopard

2007-12-24 Thread Steve Atkins
On Dec 20, 2007, at 7:35 AM, Gordon wrote: On Dec 19, 11:32 am, Gordon <[EMAIL PROTECTED]> wrote: I'm a web developer who does a lot of work in PHP. The back end database we use is bases on Postgres. I am trying to set my new MacBook Pro up as a development system. I have managed to install

[GENERAL] Retrying transactions in serializable isolation level

2007-12-24 Thread Laurent Birtz
Hello, I am trying to execute a long series of statements within a transaction in "serializable" isolation level. I've read Tom Lane's excellent document describing concurrency issues in Postgres and learned of the general method of doing this: loop BEGIN; SELECT hits FROM webpages WHERE ur

Re: [GENERAL] pg_ctl start fails on Windows

2007-12-24 Thread Richard Broersma Jr
--- On Mon, 12/24/07, Abraham, Danny <[EMAIL PROTECTED]> wrote: > I can manually create the file "postmaster.pid", > so the problem > Does not look like a permission problem. I had a similar problem once. For some reason, after I installed a windows service pack update, my Postgresql directory

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Richard Broersma Jr
--- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote: > I tried searching the documentation and mailing list, and I > couldn't > figure this one out. ALTER TABLE questions ALTER COLUMN answers TYPE possible_answers; Actually your type is fine. you only need to alter the column

Re: [GENERAL] Postgres from PHP in Leopard

2007-12-24 Thread Gordon
On Dec 19, 11:32 am, Gordon <[EMAIL PROTECTED]> wrote: > I'm a web developer who does a lot of work in PHP. The back end > database we use is bases on Postgres. I am trying to set my new > MacBook Pro up as a development system. > > I have managed to install Postgres > fromhttp://sourceforge.net

[GENERAL] pg_get_serial_sequences still have problems with downcasting

2007-12-24 Thread Ivan Sergio Borgonovo
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00964.php It is still true in 8.1. Is it still true in >8.1? Will something like that in a function be statically compiled or computed every time? _Basket_seq:= pg_get_serial_sequence('shop_commerce_baskets', lower('BasketID')); If n

Re: [GENERAL] pg_ctl start fails on Windows

2007-12-24 Thread Martin Gainty
are you using the same username that you use to start postgres??? M-- - Original Message - From: "Abraham, Danny" <[EMAIL PROTECTED]> To: Sent: Monday, December 24, 2007 9:37 AM Subject: [GENERAL] pg_ctl start fails on Windows The error message is "could not open PID file". I can man

Re: [GENERAL] pg_ctl start fails on Windows

2007-12-24 Thread Obe, Regina
Could still be a permission problem. Whatever NT account you are using as the service account (usally called postgres) for the PostgreSQL server is the one that needs to be able to create the postmaster.pid. Make sure that account has full rights to the data folder. Hope that helps, Regina --

[GENERAL] pg_ctl start fails on Windows

2007-12-24 Thread Abraham, Danny
The error message is "could not open PID file". I can manually create the file "postmaster.pid", so the problem Does not look like a permission problem. Thanks Danny ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send

[GENERAL] how to alter an enum type

2007-12-24 Thread Henrique Pantarotto
Hi, I was wondering how can I alter an ENUM type? I have created a table like this: create type possible_answers as enum('yes', 'no'); create table questions ( question text, answers possible_answers); insert into questions values ('Do you like me?', 'yes'); So my question is... How can I chang