Re: [GENERAL] updating dup row

2017-02-16 Thread John R Pierce
On 2/16/2017 6:25 PM, Patrick B wrote: how can I update a row with newest id from another table if it exists somewhere else? Example: *table test1* * id (primary key) * id_user_bill * clientid *table test2* * item_id * userid (there are duplicated rows here) * clientid * id (p

Re: [GENERAL] Updating single/multiple fields of JSON document

2014-12-09 Thread Roxanne Reid-Bennett
On 12/9/2014 3:38 PM, Bruce Momjian wrote: On Mon, Dec 8, 2014 at 04:56:00PM +0530, bln prasad wrote: Hi, Is there any way to update single/multiple fields of JSON document of a column? No, not yet. We are thinking of options but don't have any work in progress. Given a pretty distinct w

Re: [GENERAL] Updating single/multiple fields of JSON document

2014-12-09 Thread Bruce Momjian
On Mon, Dec 8, 2014 at 04:56:00PM +0530, bln prasad wrote: > Hi, >    Is there any way to update single/multiple fields of JSON document of a > column? No, not yet. We are thinking of options but don't have any work in progress. -- Bruce Momjian http://momjian.us EnterpriseDB

Re: [GENERAL] Updating timezone setting

2014-12-06 Thread Bruce Momjian
On Mon, Nov 10, 2014 at 05:09:10PM -0800, Adrian Klaver wrote: > >Would there be any issues then just leaving the columns as "timestamp > >without time zone"? I know that's not ideal, but that would be a big > >project to try and convert every single one of those columns. > > The plus for converti

Re: [GENERAL] Updating timezone setting

2014-11-10 Thread Adrian Klaver
On 11/10/2014 02:04 PM, Keith Fiske wrote: Discovered that a client of ours had assumed their database was running in UTC, but turned out to be running in 'US/Eastern'. They had changed all their systems a while ago to run in UTC but didn't realize the database was independent of that. The postgr

Re: [GENERAL] Updating pg_attribute to widen column

2012-11-30 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Justin Julicher wrote: > If you use ALTER TABLE it will check every row in the table to make sure > the column doesn't exceed the constraint (in 8.4 - I know this has been > updated in 9.x) Correct. > As I am trying to update a table with hund

Re: [GENERAL] Updating pg_attribute to widen column

2012-11-29 Thread Justin Julicher
Hi Greg, First off, thanks for your reply. I had actually just read your blog before writing this. I should have been more clear in my first post. If you use ALTER TABLE it will check every row in the table to make sure the column doesn't exceed the constraint (in 8.4 - I know this has been upd

Re: [GENERAL] Updating pg_attribute to widen column

2012-11-29 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Justin Julicher asked: > We need to widen a column on a table with millions of rows and the only way > to do this currently is to migrate the data from one column to another with > a script and trigger. Not the only way - the canonical way is to

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-15 Thread Jeff Adams
Thanks Alban. Perhaps I will go with the rewrite. I use the table for storage and analysis purposes only and am the only user, so I can take the table offline, I was wondering whether running the ALTER TABLE on the parent table makes the change in the inherited child tables? The fact that my initia

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-14 Thread Alban Hertroys
On 13 Apr 2012, at 18:43, Jeff Adams wrote: > Thanks for the ideas Steve. I am actually working with a partitioned table > and the field I am modifying is the id field (I have reached the cap on the > integer data type and need to modify it to bigint - very poor planning on my > part!), but no

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-13 Thread Jeff Adams
Thanks for the ideas Steve. I am actually working with a partitioned table and the field I am modifying is the id field (I have reached the cap on the integer data type and need to modify it to bigint - very poor planning on my part!), but no related tables exist. The id field in the partitioned ta

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-13 Thread Steve Crawford
On 04/13/2012 08:30 AM, Jeff Adams wrote: so i can? if so, how do i go about? i should mention that, while i dabble in postgres dba activity, it is not my day job... That really depends on details and your concerns. Is the database used for constant insert/update/select activity or is it a big

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-13 Thread Bèrto ëd Sèra
Hi Jeff, read carefully, he said it does stuff ON DISK, which means that all of your fields must be physically remade (so it a lot more than telling it "it's an int4, Sheila", which is what just modifying the catalog would do). Since you are not a dba be aware that you are producing a new record f

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-13 Thread Jeff Adams
so i can? if so, how do i go about? i should mention that, while i dabble in postgres dba activity, it is not my day job... On Fri, Apr 13, 2012 at 11:27 AM, Tom Lane wrote: > I wrote: > > No, that is an actual on-disk change (making the field physically > > wider), so it's going to cost ya. Th

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-13 Thread Tom Lane
I wrote: > No, that is an actual on-disk change (making the field physically > wider), so it's going to cost ya. There are some cases where the > on-disk representation doesn't change and so a catalog update isn't > needed, but int4->int8 isn't one of them. Sheesh, hit send too quickly on that.

Re: [GENERAL] Updating pg_attribute to change field's data type from integer to bigint on very large table

2012-04-13 Thread Tom Lane
Jeff Adams writes: > I have a very large table (approximately 1 billion records). I need to > change a field's data type from integer to bigint. I started up an ALTER > TABLE approach yesterday and it is still running (trying to rewrite the > whole table?). I remember seeing mention of being able

Re: [GENERAL] Updating Geometry

2011-11-10 Thread Tom Lane
Asli Akarsakarya writes: > I am having trouble when attempting to update an existing geometry on a > spatial table. The table stores 2D Point geometry, with the SRID 101. The > update statement i am trying to use to update the geometry with the id 110 is > as follows: > UPDATE SET = Geometry

Re: [GENERAL] Updating 9.0.4 --> 9.1.1: How best to ???

2011-10-02 Thread Devrim GÜNDÜZ
Hi, On Sun, 2011-10-02 at 12:41 +0200, r d wrote: > > I decided to install the PGDG repo (pgdg-fedora91-9.1-5.noarch) to > make it update. It does not. Fedora/Red Hat distro RPMs a only binary compatible since last year. I broke package compatibility by enabling multiple version installation.

Re: [GENERAL] Updating Arrays

2011-08-22 Thread Tom Lane
Merlin Moncure writes: > On Mon, Aug 22, 2011 at 8:49 PM, Bob Pawley wrote: >> I'm not sure what you mean. >> _base -- not base -- is the column name. > oops. anyways, the important point is on the right side of the equals sign. > Update library.compare set _base[2] = 2 where process_id = 2; Ri

Re: [GENERAL] Updating Arrays

2011-08-22 Thread David Johnston
> -Original Message- From: Merlin Moncure > Sent: Monday, August 22, 2011 11:03 AM > To: Bob Pawley > Cc: Postgresql > Subject: Re: [GENERAL] Updating Arrays > > On Mon, Aug 22, 2011 at 12:54 PM, Bob Pawley wrote: >> Hi >> >> I exploring the use of

Re: [GENERAL] Updating Arrays

2011-08-22 Thread Merlin Moncure
> -Original Message- From: Merlin Moncure > Sent: Monday, August 22, 2011 11:03 AM > To: Bob Pawley > Cc: Postgresql > Subject: Re: [GENERAL] Updating Arrays > > On Mon, Aug 22, 2011 at 12:54 PM, Bob Pawley wrote: >> >> Hi >> >> I exploring the

Re: [GENERAL] Updating Arrays

2011-08-22 Thread Bob Pawley
I'm not sure what you mean. _base -- not base -- is the column name. Bob -Original Message- From: Merlin Moncure Sent: Monday, August 22, 2011 11:03 AM To: Bob Pawley Cc: Postgresql Subject: Re: [GENERAL] Updating Arrays On Mon, Aug 22, 2011 at 12:54 PM, Bob Pawley wrote:

Re: [GENERAL] Updating Arrays

2011-08-22 Thread Merlin Moncure
On Mon, Aug 22, 2011 at 12:54 PM, Bob Pawley wrote: > Hi > > I exploring the use of arrays. > > So far I have created a table and inserted a row and updated the row with an > array > Update library.compare >   set _base = >   '{2, 0.764149497122068, 4.8886}' >   where process_id = 2; > – successfu

Re: [GENERAL] updating rows which have a common value forconsecutive dates

2011-04-14 Thread Lonni J Friedman
Hi David, I had just figured out the sub-query requirement when you replied. So now I've got this working: SELECT * FROM ( SELECT testname,os,arch,build_type,branch,current_status,last_update,rank() OVER (PARTITION BY testname,os,arch,branch,build_type ORDER BY last_update DESC) AS myrank FROM myt

Re: [GENERAL] updating rows which have a common value forconsecutive dates

2011-04-13 Thread David Johnston
You need to turn the query with the window function into a sub-query and then in the outer query you can refer to the inner-query's rank() column. The inner query should effectively get you the last two test results for each context and then you can check to see if any of those failed. I have

Re: [GENERAL] updating rows which have a common value forconsecutive dates

2011-04-13 Thread Lonni J Friedman
Hi David, Thanks for your reply. I'm using 8.4.7, so window functions are certainly an option, although I've admittedly never used them before. I've spent the past few hours reading the dox, and I now have a rudimentary understanding of window functions. I tried to compose a query based on your s

Re: [GENERAL] updating rows which have a common value forconsecutive dates

2011-04-13 Thread David Johnston
If you have the ability to use Window functions you can group (as necessary), order by last_update, and then use rank() to number each test run sequentially. Then you can limit the results to ( rank() <= 2 AND current_status = 'FAILED' ). David J. -Original Message- From: pgsql-gener

Re: [GENERAL] updating all records of a table

2011-03-05 Thread Willy-Bas Loos
you might consider lowering the fillfactor a bit. It will consume more space, but it will make updates and inserts faster. http://www.postgresql.org/docs/8.4/interactive/sql-createtable.html : fillfactor (integer) The fillfactor for a table is a percentage between 10 and 100. 100 (complete packin

Re: [GENERAL] updating all records of a table

2011-03-05 Thread Martijn van Oosterhout
On Sat, Mar 05, 2011 at 07:38:23AM -0800, ray wrote: > This has been a great thread! I am missing something because I do not > know what CTAS is. WOuld someone please help me understand. Create Table As Select. Have a nice day, -- Martijn van Oosterhout http://svana.org/kleptog/ > Patriot

Re: [GENERAL] updating all records of a table

2011-03-05 Thread ray
This has been a great thread! I am missing something because I do not know what CTAS is. WOuld someone please help me understand. ray -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] updating all records of a table

2011-03-04 Thread Chris Browne
robjsarg...@gmail.com (Rob Sargent) writes: > On 03/04/2011 04:54 AM, Vibhor Kumar wrote: >> >> On Mar 4, 2011, at 5:17 PM, Andrew Sullivan wrote: >> >>> On Thu, Mar 03, 2011 at 08:03:59PM -0700, Gauthier, Dave wrote: Hi: I have to update all the records of a table. I'm worried ab

Re: [GENERAL] updating all records of a table

2011-03-04 Thread Gauthier, Dave
AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] updating all records of a table On 03/04/2011 04:54 AM, Vibhor Kumar wrote: > > On Mar 4, 2011, at 5:17 PM, Andrew Sullivan wrote: > >> On Thu, Mar 03, 2011 at 08:03:59PM -0700, Gauthier, Dave wrote: >>> Hi: >&g

Re: [GENERAL] updating all records of a table

2011-03-04 Thread Rob Sargent
On 03/04/2011 04:54 AM, Vibhor Kumar wrote: > > On Mar 4, 2011, at 5:17 PM, Andrew Sullivan wrote: > >> On Thu, Mar 03, 2011 at 08:03:59PM -0700, Gauthier, Dave wrote: >>> Hi: >>> >>> I have to update all the records of a table. I'm worried about what the >>> table will look like in terms of

Re: [GENERAL] updating all records of a table

2011-03-04 Thread Vibhor Kumar
On Mar 4, 2011, at 5:17 PM, Andrew Sullivan wrote: > On Thu, Mar 03, 2011 at 08:03:59PM -0700, Gauthier, Dave wrote: >> Hi: >> >> I have to update all the records of a table. I'm worried about what the >> table will look like in terms of fragmentation when this is finished. Is >> there some

Re: [GENERAL] updating all records of a table

2011-03-04 Thread Andrew Sullivan
On Thu, Mar 03, 2011 at 08:03:59PM -0700, Gauthier, Dave wrote: > Hi: > > I have to update all the records of a table. I'm worried about what the > table will look like in terms of fragmentation when this is finished. Is > there some sort of table healing/reorg/rebuild measure I should take if

Re: [GENERAL] updating all records of a table

2011-03-03 Thread Joshua D. Drake
On Thu, 2011-03-03 at 20:03 -0700, Gauthier, Dave wrote: > Hi: > > I have to update all the records of a table. I'm worried about what > the table will look like in terms of fragmentation when this is > finished. Is there some sort of table healing/reorg/rebuild measure I > should take if I want

Re: [GENERAL] Updating from a column

2010-01-18 Thread Adrian Klaver
On Monday 18 January 2010 11:31:57 am Bob Pawley wrote: > Hi > > I have a table that has one column (pump1) controlled by a dbcheckbox. The > values can be True, False or null. > > I want to insert a row of values into second table when column pump1 value > is 'True'. I don't want the trigger to in

Re: [GENERAL] Updating from 8.2 to 8.4

2009-12-26 Thread Mark Morgan Lloyd
Adrian Klaver wrote: Thanks Adrian, noted. I'm hoping to get onto 8.4 before too long because of the analytic functions but that thread suggests that the best course of action would be to make sure that my code is robust against the new server and then decide on an upgrade schedule. I'm building

Re: [GENERAL] Updating from 8.2 to 8.4

2009-12-25 Thread Adrian Klaver
On Friday 25 December 2009 10:27:09 am Mark Morgan Lloyd wrote: > Adrian Klaver wrote: > >> although I don't know why it didn't bite on 8.2 unless it's specifically > >> when 64-bit timestamps are processed. > > > > You might want to confirm your 8.4 installation is using integer > > datetimes as t

Re: [GENERAL] Updating from 8.2 to 8.4

2009-12-25 Thread Mark Morgan Lloyd
Adrian Klaver wrote: although I don't know why it didn't bite on 8.2 unless it's specifically when 64-bit timestamps are processed. You might want to confirm your 8.4 installation is using integer datetimes as there is some variability in its useage among packagers. Follow this thread for one

Re: [GENERAL] Updating from 8.2 to 8.4

2009-12-25 Thread Adrian Klaver
On Friday 25 December 2009 5:06:28 am Mark Morgan Lloyd wrote: > Adrian Klaver wrote: > > On Thursday 24 December 2009 11:20:35 am Mark Morgan Lloyd wrote: > >> I was hoping to finally get the servers updated from 8.2 to 8.4 over the > >> festive season, but by now I think I've left things too tigh

Re: [GENERAL] Updating from 8.2 to 8.4

2009-12-25 Thread Mark Morgan Lloyd
Adrian Klaver wrote: On Thursday 24 December 2009 11:20:35 am Mark Morgan Lloyd wrote: I was hoping to finally get the servers updated from 8.2 to 8.4 over the festive season, but by now I think I've left things too tight. Is it necessary to update the (Windows) ODBC driver as well? I've got a

Re: [GENERAL] Updating from 8.2 to 8.4

2009-12-24 Thread Adrian Klaver
On Thursday 24 December 2009 11:20:35 am Mark Morgan Lloyd wrote: > I was hoping to finally get the servers updated from 8.2 to 8.4 over the > festive season, but by now I think I've left things too tight. > > Is it necessary to update the (Windows) ODBC driver as well? I've got a > couple of app s

Re: [GENERAL] Updating column on row update

2009-11-22 Thread silly8888
> MySQL had the following syntax available: > `updated_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update > CURRENT_TIMESTAMP I wonder supporting this syntax would speed things up a little bit. Here's a simple benchmark about the situation we are discussing here: There are 2 tables:

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Tom Lane
Craig Ringer writes: > I do think this comes up often enough that a built-in trigger "update > named column with result of expression on insert" trigger might be > desirable. There's something of the sort in contrib already, I believe, though it's so old it still uses abstime :-( > So might "CRE

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Craig Ringer > On 23/11/2009 4:15 AM, Scott Marlowe wrote: > > On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown > wrote: > >> Hi, > >> This should be simple, but for some reason I'm not quite sure what the > >> solution is. I want to be able to update the value of a column for rows > >>

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Craig Ringer
On 23/11/2009 4:15 AM, Scott Marlowe wrote: > On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: >> Hi, >> This should be simple, but for some reason I'm not quite sure what the >> solution is. I want to be able to update the value of a column for rows >> that have been updated. More specifical

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Christophe Pettus > David Fetter and Andreas Scherbaum also have solutions for this in > reployment scripts: > > > http://people.planetpostgresql.org/dfetter/index.php?/archives/23-CREATE-OR-REPLACE-LANGUAGE.html > > http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Christophe Pettus
David Fetter and Andreas Scherbaum also have solutions for this in reployment scripts: http://people.planetpostgresql.org/dfetter/index.php?/archives/23-CREATE-OR-REPLACE-LANGUAGE.html http://andreas.scherbaum.la/blog/archives/346-create-language-if-not-exist.html -- -- Christ

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Adrian Klaver
On Sunday 22 November 2009 1:10:36 pm Thom Brown wrote: > 2009/11/22 Scott Marlowe > > > > Thanks Scott. It's a shame a function has to be used because it then > > > has the dependency of plpgsql being loaded. I'm attempting to write a > > > > database > > > > > schema to accompany a PostgreSQL

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Scott Marlowe > > Thanks Scott. It's a shame a function has to be used because it then has > > the dependency of plpgsql being loaded. I'm attempting to write a > database > > schema to accompany a PostgreSQL driver for a popular CMS, but I guess I > > could get it to load plpgsql in

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Scott Marlowe
On Sun, Nov 22, 2009 at 1:32 PM, Thom Brown wrote: > Thanks Scott.  It's a shame a function has to be used because it then has > the dependency of plpgsql being loaded.  I'm attempting to write a database > schema to accompany a PostgreSQL driver for a popular CMS, but I guess I > could get it to

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Scott Marlowe
On Sun, Nov 22, 2009 at 1:32 PM, Thom Brown wrote: > 2009/11/22 Scott Marlowe >> >> On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: >> > Hi, >> > This should be simple, but for some reason I'm not quite sure what the >> > solution is.  I want to be able to update the value of a column for ro

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Scott Marlowe > On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: > > Hi, > > This should be simple, but for some reason I'm not quite sure what the > > solution is. I want to be able to update the value of a column for rows > > that have been updated. More specifically, if a row

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Adrian Klaver
On Sunday 22 November 2009 12:09:04 pm Thom Brown wrote: > 2009/11/22 Aaron Burnett > > > this is how I do it if this helps: > > > > column_name timestamp without time zone NOT NULL DEFAULT > > ('now'::text)::timestamp(6) without time zone > > > > Hi Aaron. Thanks for the reply, but that would on

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Scott Marlowe
On Sun, Nov 22, 2009 at 12:50 PM, Thom Brown wrote: > Hi, > This should be simple, but for some reason I'm not quite sure what the > solution is.  I want to be able to update the value of a column for rows > that have been updated.  More specifically, if a row is updated, I want it's > modified_da

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Aaron Burnett
this is how I do it if this helps: column_name timestamp without time zone NOT NULL DEFAULT ('now'::text)::timestamp(6) without time zone -Original Message- From: pgsql-general-ow...@postgresql.org on behalf of Thom Brown Sent: Sun 11/22/2009 2:50 PM To: PGSQL Mailing List Subject: [G

Re: [GENERAL] Updating column on row update

2009-11-22 Thread Thom Brown
2009/11/22 Aaron Burnett > > this is how I do it if this helps: > > column_name timestamp without time zone NOT NULL DEFAULT > ('now'::text)::timestamp(6) without time zone > > Hi Aaron. Thanks for the reply, but that would only insert the current date upon insertion into the table, not when the

Re: [GENERAL] Updating row with updating function, bug or feature?

2009-09-30 Thread Thomas Jacob
On Wed, 2009-09-30 at 10:17 -0400, Tom Lane wrote: > Thomas Jacob writes: > > I've run into some weirdness in PSQL 8.3.8 (Ubuntu 8.04 LTS x86_64 > > package). When I update a row while using a function result > > that updates that very same row in the "WHERE" part of the update, > > the main updat

Re: [GENERAL] Updating row with updating function, bug or feature?

2009-09-30 Thread Tom Lane
Thomas Jacob writes: > I've run into some weirdness in PSQL 8.3.8 (Ubuntu 8.04 LTS x86_64 > package). When I update a row while using a function result > that updates that very same row in the "WHERE" part of the update, > the main update no longer takes place, even though the "WHERE" > conditions

Re: [GENERAL] updating to 8.3.x

2008-09-17 Thread Ben
On Wed, 17 Sep 2008, Scott Marlowe wrote: In another thread, Ben mentioned the issues he's running into with upgrading to 8.3 and lack of some of the old implicit (but wrong) type conversion. Remember 8.3 also gives you the "opportunity" to fix all the sloppy code in your application that depe

Re: [GENERAL] updating a row referenced by a foreign key

2008-05-18 Thread Craig Ringer
Michael P. Soulier wrote: Is there a simple way to update the row, and cascade the change to any and all rows referencing this row as a foreign key? I searched on cascade in the postgres docs and while I found references to deletion, I didn't find one for updates. http://www.postgresql.org/d

Re: [GENERAL] Updating with a subselect

2008-04-23 Thread Leandro Casadei
On Wed, Apr 23, 2008 at 10:59 AM, Stephan Szabo < [EMAIL PROTECTED]> wrote: > On Tue, 22 Apr 2008, Leandro Casadei wrote: > > > Hi, I need to update a field from a table based in a count. > > > > This is the query: > > > > > > updateshops > > setitemsqty = > > ( > > select coun

Re: [GENERAL] Updating with a subselect

2008-04-23 Thread Stephan Szabo
On Wed, 23 Apr 2008, Leandro Casadei wrote: > On Wed, Apr 23, 2008 at 10:59 AM, Stephan Szabo < > [EMAIL PROTECTED]> wrote: > > > On Tue, 22 Apr 2008, Leandro Casadei wrote: > > > > > Hi, I need to update a field from a table based in a count. > > > > > > This is the query: > > > > > > > > > upda

Re: [GENERAL] Updating with a subselect

2008-04-23 Thread Stephan Szabo
On Tue, 22 Apr 2008, Leandro Casadei wrote: > Hi, I need to update a field from a table based in a count. > > This is the query: > > > updateshops > setitemsqty = > ( > select count(*) > from items i1 > join shops s1 on i1.shopid = s1.shopid > where s1.sh

Re: [GENERAL] Updating with a subselect

2008-04-23 Thread Martijn van Oosterhout
On Tue, Apr 22, 2008 at 01:17:42PM -0300, Leandro Casadei wrote: > Hi, I need to update a field from a table based in a count. > > This is the query: I don't know why your given query doesn't work, but you could simplify it which may help. > updateshops > setitemsqty = > ( > sele

Re: [GENERAL] Updating with a subselect

2008-04-23 Thread A. Kretschmer
am Tue, dem 22.04.2008, um 13:17:42 -0300 mailte Leandro Casadei folgendes: > Hi, I need to update a field from a table based in a count. > > This is the query: > > > updateshops > setitemsqty = > ( > select count(*) > from items i1 > join shops s1 on i1.sho

Re: [GENERAL] Updating

2008-03-17 Thread Tom Lane
Bob Pawley <[EMAIL PROTECTED]> writes: > If NEW.p_id.association.monitoring_fluid is distinct from > Old.p_id.association.monitoring_fluid Then Surely this should just be if new.monitoring_fluid is distinct from old.monitoring_fluid then Also, I think you forgot an "end if" and a "retu

Re: [GENERAL] Updating

2008-03-17 Thread Bob Pawley
an Klaver" <[EMAIL PROTECTED]>; Sent: Monday, March 17, 2008 2:42 PM Subject: Re: [GENERAL] Updating Bob Pawley wrote: I am attempting to use the following code but I get - "ERROR: NEW used in query that is not in a rule". This implies that I create a rule for NEW and OLD

Re: [GENERAL] Updating

2008-03-17 Thread Daniel Verite
Bob Pawley wrote: I am attempting to use the following code but I get - "ERROR: NEW used in query that is not in a rule". This implies that I create a rule for NEW and OLD (which I haven't needed before). No, but are you sure you're using these keywords in the context of a plpgsql

Re: [GENERAL] Updating

2008-03-17 Thread Bob Pawley
ed != . Is this symbol the same as <> ? Bob - Original Message - From: "Adrian Klaver" <[EMAIL PROTECTED]> To: Cc: "Daniel Verite" <[EMAIL PROTECTED]>; "Bob Pawley" <[EMAIL PROTECTED]> Sent: Monday, March 17, 2008 7:16 AM Subje

Re: [GENERAL] Updating

2008-03-17 Thread Adrian Klaver
On Monday 17 March 2008 4:54 am, Daniel Verite wrote: > Adrian Klaver wrote: > > CREATE FUNCTION foo() RETURNS trigger AS > > $Body$ > > BEGIN > > IF NEW.colname != OLD.colname THEN > > ..."Do something"..; > > RETURN whatever; > > ELSE > > RETURN NEW:

Re: [GENERAL] Updating

2008-03-17 Thread Daniel Verite
Adrian Klaver wrote: CREATE FUNCTION foo() RETURNS trigger AS $Body$ BEGIN IF NEW.colname != OLD.colname THEN ..."Do something"..; RETURN whatever; ELSE RETURN NEW: END IF; END; $Body$ LANGUAGE plpgsql; Beware t

Re: [GENERAL] Updating

2008-03-16 Thread Harvey, Allan AC
> Would it be possible to get an example of such coding?? This trigger has an argument passed. When the trigger is "assigned" I know whether the column is of type txt or float. It uses the column name to determine what to do. Hope this helps Allan create or replace function insert_if_diff() re

Re: [GENERAL] Updating

2008-03-16 Thread Adrian Klaver
D]> > Sent: Sunday, March 16, 2008 5:14 PM > Subject: Re: [GENERAL] Updating > > > On Sunday 16 March 2008 3:32 pm, Bob Pawley wrote: > >> Is there a method available for triggering a function after an update on > >> a > >> particular column in a table? >

Re: [GENERAL] Updating

2008-03-16 Thread Bob Pawley
Would it be possible to get an example of such coding?? Bob - Original Message - From: "Adrian Klaver" <[EMAIL PROTECTED]> To: Cc: "Bob Pawley" <[EMAIL PROTECTED]> Sent: Sunday, March 16, 2008 5:14 PM Subject: Re: [GENERAL] Updating On Sunday 1

Re: [GENERAL] Updating

2008-03-16 Thread Andreas 'ads' Scherbaum
Hello, On Sun, 16 Mar 2008 15:32:27 -0700 Bob Pawley wrote: > Is there a method available for triggering a function after an update on a > particular column in a table? > > The only way that I have found is to trigger after an update on the whole > table, which of course can lead to problems.

Re: [GENERAL] Updating

2008-03-16 Thread Adrian Klaver
On Sunday 16 March 2008 3:32 pm, Bob Pawley wrote: > Is there a method available for triggering a function after an update on a > particular column in a table? > > The only way that I have found is to trigger after an update on the whole > table, which of course can lead to problems. > > Bob I tri

Re: [GENERAL] Updating a production database schema from dev server

2008-01-04 Thread mljv
Hi, try using liquibase. http://www.liquibase.org/ . It works very well. kind regards, Janning Am Dienstag, 16. Oktober 2007 18:38 schrieb Stanislav Raskin: > Hello everybody, > > > > I am currently running two PostgreSQL servers on two different machines. > One of them I use for development and

Re: [GENERAL] Updating a production database schema from dev server

2007-10-16 Thread Stanislav Raskin
endet: Dienstag, 16. Oktober 2007 19:51 An: Stanislav Raskin Cc: pgsql-general@postgresql.org Betreff: Re: [GENERAL] Updating a production database schema from dev server On 10/16/07, Stanislav Raskin <[EMAIL PROTECTED]> wrote: > > Hello everybody, > > I am currently running tw

Re: [GENERAL] Updating a production database schema from dev server

2007-10-16 Thread Michael Crozier
Stanislav Raskin wrote: I figure there must be a better way to do so. Is there some kind of software, which compares two database schemas (preferably two sql dumps), and generates a script for applying differences to one of them? What would be the best practice for applying such updates witho

Re: [GENERAL] Updating a production database schema from dev server

2007-10-16 Thread Richard Huxton
Stanislav Raskin wrote: I figure there must be a better way to do so. Is there some kind of software, which compares two database schemas (preferably two sql dumps), and generates a script for applying differences to one of them? What would be the best practice for applying such updates witho

Re: [GENERAL] Updating a production database schema from dev server

2007-10-16 Thread Scott Marlowe
On 10/16/07, Stanislav Raskin <[EMAIL PROTECTED]> wrote: > > Hello everybody, > > I am currently running two PostgreSQL servers on two different machines. One > of them I use for development and the other one as the "real" production > server for my applications. > > While developing new versions o

Re: [GENERAL] updating a view

2006-12-15 Thread m . c . wilkins
ya'da man tom! applied the patch, rebuilt, and postgres doesn't crash anymore. fixed my syntax error, and all is working properly. phew, my first experience with sql thanks! matt On Thu, Dec 14, 2006 at 09:23:40PM -0500, Tom Lane wrote: > [EMAIL PROTECTED] writes: > > so maybe i'm using

Re: [GENERAL] updating a view

2006-12-14 Thread Tom Lane
[EMAIL PROTECTED] writes: > so maybe i'm using the word crash too liberally. this is the error > message i get: > server closed the connection unexpectedly Looks like a crash to me. > version is 8.2.0, just downloaded a few days ago. There's a known bug in 8.2.0 having to do with failing out o

Re: [GENERAL] updating a view

2006-12-14 Thread m . c . wilkins
hi tom, so maybe i'm using the word crash too liberally. this is the error message i get: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting rese

Re: [GENERAL] updating a view

2006-12-14 Thread Tom Lane
[EMAIL PROTECTED] writes: > i would like to allow updates to a view, but pgsql crashes, > presummably from an infinite loop. If it crashes, that's a bug, regardless of whether the code is doing what you want. However, if the thing is indeed into an infinite recursion, you might be running out of

Re: [GENERAL] updating to 7.4.13 helped it appears

2006-10-31 Thread Dimitri Fontaine
Hi list, Le mardi 31 octobre 2006 20:00, Geoffrey a écrit : > I have not had any success in duplicating the failure on my development > environment. I suspect it's because I can't generate the volume of > users. The production system could well have 150-200 users at one time > and we get a core

Re: [GENERAL] updating to 7.4.13 helped it appears

2006-10-31 Thread Geoffrey
Alvaro Herrera wrote: I'm not 100% sure what you are saying here, but if it is what I believe, then you didn't copy the newly compiled executable into the production machine; that won't work. You need to use a debug-enabled executable both to produce the core file, and to pass to GDB for inspec

Re: [GENERAL] updating to 7.4.13 helped it appears

2006-10-31 Thread Alvaro Herrera
Geoffrey wrote: > Alvaro Herrera wrote: > >Geoffrey wrote: > >>It appears that upgrading to 7.4.13 helped the problem we were having > >>with the postgres process terminating. We still are having the problem, > >>but it does appear to be different, based on the output of backtraces. > >>The cor

Re: [GENERAL] updating to 7.4.13 helped it appears

2006-10-31 Thread Geoffrey
Alvaro Herrera wrote: Geoffrey wrote: It appears that upgrading to 7.4.13 helped the problem we were having with the postgres process terminating. We still are having the problem, but it does appear to be different, based on the output of backtraces. The core files are much larger and there d

Re: [GENERAL] updating to 7.4.13 helped it appears

2006-10-31 Thread Alvaro Herrera
Geoffrey wrote: > It appears that upgrading to 7.4.13 helped the problem we were having > with the postgres process terminating. We still are having the problem, > but it does appear to be different, based on the output of backtraces. > The core files are much larger and there does seem to be a

Re: [GENERAL] Updating & inserting in one shot!

2006-04-10 Thread Harald Armin Massa
nearly ready to usereplace (int4, text, "timestamp") with your fieldtypes; its convention: first param is primary keyreplace    update bcachekredbetr set     betreuer=$2, letztespeicherung=$3     where id_p=$1; with the appropriate update (where clause -> references prim

Re: [GENERAL] Updating database structure

2006-03-23 Thread Jim Nasby
On Mar 23, 2006, at 9:50 AM, [EMAIL PROTECTED] wrote: I currently use phpPgAdmin to make changes to the database, so it would be very handy if Postgres could add a change made to a lable somewhere, after which I gather all the rows with changes and put them in a SQL query. My suggestion: d

Re: [GENERAL] Updating database structure

2006-03-23 Thread Miroslav Šulc
Hello, I accidentaly came across this post. I didn't follow it so I don't know whether my posting is to the topic or not. I've just uploaded project at SourceForge.Net on topic of PostgreSQL database schema upgrades because I needed to find out differences between current and new schemas. The p

Re: [GENERAL] Updating database structure

2006-03-23 Thread Alban Hertroys
Guido Neitzer wrote: I mostly use the command line tools or a graphical tool to make my own sql calls for every schema change I make on the development database. Then all these changes come to a "script" in my application (it's not actually a script but similar). The database has a version

Re: [GENERAL] Updating database structure

2006-03-23 Thread Guido Neitzer
On 23.03.2006, at 9:50 Uhr, [EMAIL PROTECTED] wrote: I currently use phpPgAdmin to make changes to the database, so it would be very handy if Postgres could add a change made to a lable somewhere, after which I gather all the rows with changes and put them in a SQL query. I mostly use the

Re: [GENERAL] Updating database structure

2006-03-23 Thread subscribe
Quoting Janning Vygen <[EMAIL PROTECTED]>: Am Mittwoch, 22. März 2006 20:40 schrieb Luuk Jansen: I have a problem with finding a way to update a database structure. This might be a very simple problem, just cannot find the info. I am looking at updating the structure of my database. I put an a

Re: [GENERAL] Updating database structure

2006-03-22 Thread Janning Vygen
Am Mittwoch, 22. März 2006 20:40 schrieb Luuk Jansen: > I have a problem with finding a way to update a database structure. > This might be a very simple problem, just cannot find the info. > > I am looking at updating the structure of my database. I put an > application on my production server som

Re: [GENERAL] Updating database structure

2006-03-22 Thread Johan Vromans
Luuk Jansen <[EMAIL PROTECTED]> writes: > How can I update the structure on the production server to reflect the > database on my test machine in an easy way with preservation of the data > on the production server. There are no major changes in the fields types > etc., mainly additions/deletions

  1   2   >