[GENERAL] date and time

2008-03-24 Thread Alain Roger
Hi, i have a stored procedure (a function) in which i must generate a date/time stamp. for that i use select * from now(); and store the result into a column table. is there a easier way to do that ? i tried to store directly now(); result but without success. thx. -- Alain

Re: [GENERAL] date and time

2008-03-24 Thread Raymond O'Donnell
On 24/03/2008 14:35, Alain Roger wrote: for that i use select * from now(); and store the result into a column table. is there a easier way to do that ? i tried to store directly now(); result but without success. Can you show us the full SQL statement? You could also use CURRENT_TIMESTAMP

Re: [GENERAL] date and time

2008-03-24 Thread Alain Roger
Hi Ray, yes for sure. Here it is: SELECT count(*) INTO existing_email FROM cust_portal.tmp_newsletterreg; if (existing_email 0) then { result = false; } else { result = true; INSERT INTO cust_portal.tmp_newsletterreg VALUES (

Re: [GENERAL] date and time

2008-03-24 Thread Adrian Klaver
On Monday 24 March 2008 7:35 am, Alain Roger wrote: Hi, i have a stored procedure (a function) in which i must generate a date/time stamp. for that i use select * from now(); and store the result into a column table. is there a easier way to do that ? i tried to store directly now();

Re: [GENERAL] date and time

2008-03-24 Thread Thomas Kellerer
Alain Roger wrote on 24.03.2008 15:45: SELECT count(*) INTO existing_email FROM cust_portal.tmp_newsletterreg; if (existing_email 0) then { result = false; } else { result = true; INSERT INTO cust_portal.tmp_newsletterreg VALUES (

Re: [GENERAL] date and time

2008-03-24 Thread Raymond O'Donnell
On 24/03/2008 14:45, Alain Roger wrote: INSERT INTO cust_portal.tmp_newsletterreg VALUES ( nextval( 'tmp_newsletterreg_nlreg_id_seq' ), email, session, SELECT CURRENT_TIMESTAMP; ) Hi Alain, That won't work; you just need ... values ( email, session, CURRENT_TIMESTAMP)

Re: [GENERAL] C function and enum types parameters

2008-03-24 Thread Edoardo Panfili
Edoardo Panfili ha scritto: I use a C function in my database from 2002, all goes well also with postgresql 8.3 but with 8.3.1 it no longer works, the problem is with this line: text *hibrid = (PG_ARGISNULL( 0) || VARSIZE(PG_GETARG_TEXT_P( 0))==VARHDRSZ ?NULL:PG_GETARG_TEXT_P(0)); the

Re: [GENERAL] date and time

2008-03-24 Thread Alain Roger
So thanks a lot to everybody... so here is the result. 1. the semicolon was missing after the INSERT as wrote Raymond. 2. CURRENT_TIMESTAMP works great 3. i use pl/pgsql as language thanks again. Alain On Mon, Mar 24, 2008 at 3:56 PM, Thomas Kellerer [EMAIL PROTECTED] wrote: Alain Roger wrote

Re: [GENERAL] date and time

2008-03-24 Thread Tony Caduto
Alain Roger wrote: Hi, i have a stored procedure (a function) in which i must generate a date/time stamp. for that i use select * from now(); and store the result into a column table. is there a easier way to do that ? i tried to store directly now(); result but without success. Do you

Re: [GENERAL] Insert

2008-03-24 Thread Bob Pawley
The count procedure appears to be working well. Thanks Adrian for your help. Bob - Original Message - From: Adrian Klaver [EMAIL PROTECTED] To: pgsql-general@postgresql.org Cc: Bob Pawley [EMAIL PROTECTED] Sent: Sunday, March 23, 2008 4:04 PM Subject: Re: [GENERAL] Insert On

[GENERAL] Checking if Aggregate exists

2008-03-24 Thread Josh Trutwin
Hi, I have an upgrade script that is supposed to install items into a postgresql database if they don't already exist. One of the items I'm having a hard time with is aggregates. I want to check if aggregate foo doesn't exist, then run an SQL command to generate it. if

Re: [GENERAL] Checking if Aggregate exists

2008-03-24 Thread Martijn van Oosterhout
On Mon, Mar 24, 2008 at 12:47:43PM -0500, Josh Trutwin wrote: My code to check if an aggregate exists runs this query: SELECT * FROM pg_catalog.pg_aggretate WHERE aggfnoid = 'foo'::REGPROC; Seems to me you'd rather want the proisagg column in pg_proc and forget about pg_aggregate

Re: [GENERAL] Checking if Aggregate exists

2008-03-24 Thread Alvaro Herrera
Josh Trutwin wrote: Is there a better way to do this? Maybe a stored proc that eats the error message? Well, you can use a plpgsql function with a BEGIN/EXCEPTION/END block to eat the error message. However I'm wondering whether you should be checking the aggregate argument type(s) as well.

Re: [GENERAL] Checking if Aggregate exists

2008-03-24 Thread Erik Jones
On Mar 24, 2008, at 1:09 PM, Martijn van Oosterhout wrote: On Mon, Mar 24, 2008 at 12:47:43PM -0500, Josh Trutwin wrote: My code to check if an aggregate exists runs this query: SELECT * FROM pg_catalog.pg_aggretate WHERE aggfnoid = 'foo'::REGPROC; Seems to me you'd rather want the

[GENERAL] Problem with update on partitioned table

2008-03-24 Thread Alex Solovey
Hello, We have pretty big production database (running PostgreSQL 8.3.1) with many partitioned tables. In most cases, they work well (since 8.2.1 at least) -- constraint exclusion is able to select correct partitions. However, there is an exception: queries on partitioned tables using

Re: [GENERAL] Checking if Aggregate exists

2008-03-24 Thread Josh Trutwin
On Mon, 24 Mar 2008 14:02:02 -0500 Erik Jones [EMAIL PROTECTED] wrote: On Mar 24, 2008, at 1:09 PM, Martijn van Oosterhout wrote: On Mon, Mar 24, 2008 at 12:47:43PM -0500, Josh Trutwin wrote: My code to check if an aggregate exists runs this query: SELECT * FROM pg_catalog.pg_aggretate

Re: [GENERAL] Checking if Aggregate exists

2008-03-24 Thread Erik Jones
On Mar 24, 2008, at 2:18 PM, Josh Trutwin wrote: On Mon, 24 Mar 2008 14:02:02 -0500 Erik Jones [EMAIL PROTECTED] wrote: On Mar 24, 2008, at 1:09 PM, Martijn van Oosterhout wrote: On Mon, Mar 24, 2008 at 12:47:43PM -0500, Josh Trutwin wrote: My code to check if an aggregate exists runs this

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Tom Lane
Alex Solovey [EMAIL PROTECTED] writes: We have pretty big production database (running PostgreSQL 8.3.1) with many partitioned tables. In most cases, they work well (since 8.2.1 at least) -- constraint exclusion is able to select correct partitions. However, there is an exception: queries

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Alex Solovey
Martin, which if you dont want to scan ALL partitions must be set to 'on' constraint_exclusion = on It is 'ON'. The problem is that it does not work well for 'UPDATE foo ... FROM bar' queries, when partitioned table 'foo' is joined with another table. Martin Gainty wrote: Alex-

[GENERAL] East: Only 3 days left.

2008-03-24 Thread Joshua D. Drake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Online registration ends for PostgreSQL Conference East on March 26th at 5:00pm PST. PostgreSQL Conference: East is being held at the Univerisity of Maryland, College Park in the CSIC building. The conference series is designed to be a geographically

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Alex Solovey
Tom, Thanks for the patch. We've tried it here, and it improved query plan slightly (indeed, it looks exactly like the plan from 8.2.6 now). But, as you've said, empty sub-joins are still not discarded, so query execution time did not improve. And this is the same in both 8.2 and 8.3. Note

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Tom Lane
Alex Solovey [EMAIL PROTECTED] writes: Thanks for the patch. We've tried it here, and it improved query plan slightly (indeed, it looks exactly like the plan from 8.2.6 now). But, as you've said, empty sub-joins are still not discarded, so query execution time did not improve. And this is

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Alex Solovey
Tom, If you're feeling brave, try the patch I just committed to CVS. I just did it. It works! According to the query plan, only one partition is being examined now. Is this patch going to be included in 8.3 only, or in 8.2 as well? Thanks! - Sent via pgsql-general mailing list

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Tom Lane
Alex Solovey [EMAIL PROTECTED] writes: Is this patch going to be included in 8.3 only, or in 8.2 as well? I thought I was already taking a chance by putting it in REL8_3_STABLE. Since 8.2 doesn't have a regression compared to the previous release, and is also very much more different from HEAD,

Re: [GENERAL] Problem with update on partitioned table

2008-03-24 Thread Martin Gainty
Alex- http://www.postgresql.org/docs/8.2/static/runtime-config-query.html#GUC-CONS TRAINT-EXCLUSION postgresql.conf contains a constraint_exclusion parameter called constraint_exclusion (boolean) which if you dont want to scan ALL partitions must be set to 'on' constraint_exclusion = on HTH

[GENERAL] Need help to migrate pqSQL db 8.0.3 to 8.2.6

2008-03-24 Thread Tri Quach
Hi All, I installed pqsql 8.2.6 on a new server. I need to migrate the data from pqSQL db 8.0.3 on the old server to 8.2.6 on the new server. Can anyone provide me a document how to migrate? Thank you for your help. Tri

Re: [GENERAL] Need help to migrate pqSQL db 8.0.3 to 8.2.6

2008-03-24 Thread Andrej Ricnik-Bay
On 25/03/2008, Tri Quach [EMAIL PROTECTED] wrote: Hi All, I installed pqsql 8.2.6 on a new server. I need to migrate the data from pqSQL db 8.0.3 on the old server to 8.2.6 on the new server. Can anyone provide me a document how to migrate? It's part of the package. Read the INSTALL

Re: [GENERAL] ATTN: Clodaldo was Performance problem. Could it be related to 8.3-beta4?

2008-03-24 Thread Bruce Momjian
Added to TODO: * Consider sorting entries before inserting into btree index http://archives.postgresql.org/pgsql-general/2008-01/msg01010.php --- Tom Lane wrote: Clodoaldo [EMAIL PROTECTED] writes: 2008/1/16, Tom

[GENERAL] OLEDB vs ODBC to access postgres

2008-03-24 Thread J Ottery
I am using a grid component (delphi) connected via Postgres ODBC , and via Datasource - ADOTable - ADOConnection to a postgres database. All works well. Tried using the PostgreSQL Native Provider, built a working connection string. It connects OK but I have only read access to the data (in the

Re: [GENERAL] OLEDB vs ODBC to access postgres

2008-03-24 Thread Joshua D. Drake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 24 Mar 2008 20:14:18 -0700 (PDT) J Ottery [EMAIL PROTECTED] wrote: I am using a grid component (delphi) connected via Postgres ODBC , and via Datasource - ADOTable - ADOConnection to a postgres database. All works well. Tried using the