Re: [GENERAL] Is this possible in a trigger?

2008-05-06 Thread Robert Treat
On Tuesday 06 May 2008 20:10:50 Klint Gore wrote: > Fernando wrote: > > I want to keep a history of changes on a field in a table. This will > > be the case in multiple tables. > > > > Can I create a trigger that loops the OLD and NEW values and compares > > the values and if they are different cr

[GENERAL] ERROR: could not open relation

2008-05-06 Thread Q Master
I get this strange error Caused by: org.postgresql.util.PSQLException: ERROR: could not open relation 1663/53544/58374: No such file or directory How do I recover from it ? Version 8.2 on windows. I think I had an hardware issue in the past where my box rebooted few times I assume this is du

Re: [GENERAL] Is this possible in a trigger?

2008-05-06 Thread Kerri Reno
This is easy with plpython. We do something similar. Kerri On Tue, May 6, 2008 at 6:10 PM, Klint Gore <[EMAIL PROTECTED]> wrote: > Fernando wrote: > > > I want to keep a history of changes on a field in a table. This will be > > the case in multiple tables. > > > > Can I create a trigger that

Re: [GENERAL] Is this possible in a trigger?

2008-05-06 Thread Klint Gore
Fernando wrote: I want to keep a history of changes on a field in a table. This will be the case in multiple tables. Can I create a trigger that loops the OLD and NEW values and compares the values and if they are different creates a change string as follows: e.g; FOR EACH field IN NEW

Re: [GENERAL] Cannot update table with OID with linked server in SQl Server

2008-05-06 Thread Adrian Klaver
-- Original message -- From: "Ken Allen" <[EMAIL PROTECTED]> > I have a linked server on SQL server 2005. I can update or write to a > table in Postgres that does not have a OID. But the Table I have has an > OID and I cannot write or update to that table. Anyone

Re: [GENERAL] xlogdump & pgview

2008-05-06 Thread Alex Vinogradovs
Okay, looks like pgdview 0.2 was released just yesterday, and it supports 8.3 ;) On Tue, 2008-05-06 at 14:20 -0700, Alex Vinogradovs wrote: > Guys, > > Are there low-level maintenance tools, such as xlogdump and pgview, > available for version 8.3 datafiles/wal logs ? Thanks! > > > best regard

Re: [GENERAL] select from an index

2008-05-06 Thread Pau Marc Munoz Torres
Hi Recently i created an index in a table using a function (not a column) as following create index H2IAb on precalc (idr(p1,p4,p6,p7,p9,'H-2*IAb')); , where idr is a function that returns a real number,as a result i got the following table mhc2db=> \d precalc; Table

[GENERAL] xlogdump & pgview

2008-05-06 Thread Alex Vinogradovs
Guys, Are there low-level maintenance tools, such as xlogdump and pgview, available for version 8.3 datafiles/wal logs ? Thanks! best regards, Alex Vinogradovs -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/

[GENERAL] Is this possible in a trigger?

2008-05-06 Thread Fernando
I want to keep a history of changes on a field in a table. This will be the case in multiple tables. Can I create a trigger that loops the OLD and NEW values and compares the values and if they are different creates a change string as follows: e.g; FOR EACH field IN NEW IF field.value <>

[GENERAL] Rules to provide a virtual column

2008-05-06 Thread James B. Byrne
This might be a little off topic and it may show a degree of naivety on my part but I have a small problem with coding a Ruby on Rails application and it seems to me that the best answer may reside in the database itself. The situation is this. A dependent table relationship is episodic. In othe

[GENERAL] Cannot update table with OID with linked server in SQl Server

2008-05-06 Thread Ken Allen
I have a linked server on SQL server 2005. I can update or write to a table in Postgres that does not have a OID. But the Table I have has an OID and I cannot write or update to that table. Anyone have any ideas.

Re: [GENERAL] Autocast script of peter e in PostgreSQL 8.3

2008-05-06 Thread Daniel Schuchardt
Martijn van Oosterhout schrieb: Did you not find this during your searching? http://archives.postgresql.org/pgsql-general/2008-03/msg00995.php and followups. Have a nice day, no i didnt found it in google. now everything is working and as excpected: EXPLAIN ANALYSE big query Runtime 45

Re: [GENERAL] GROUP BY, ORDER & LIMIT ?

2008-05-06 Thread hubert depesz lubaczewski
On Tue, May 06, 2008 at 01:22:30PM -0400, Kynn Jones wrote: > Suppose table X has two columns: class (TEXT) and size (INT). I want a > listing showing the (up to) 5 largest values of "size" for each value of > "class" (for some values of "class" the total number of available records > may be less

Re: [GENERAL] GROUP BY, ORDER & LIMIT ?

2008-05-06 Thread David Wilson
select class, size from X t1 where size in (select size from X t2 where t2.class=t1.class order by size desc limit 5); On Tue, May 6, 2008 at 1:22 PM, Kynn Jones <[EMAIL PROTECTED]> wrote: > Suppose table X has two columns: class (TEXT) and size (INT). I want a > listing showing the (up to) 5 la

[GENERAL] GROUP BY, ORDER & LIMIT ?

2008-05-06 Thread Kynn Jones
Suppose table X has two columns: class (TEXT) and size (INT). I want a listing showing the (up to) 5 largest values of "size" for each value of "class" (for some values of "class" the total number of available records may be less than 5). What would be the simplest way to achieve such a listing?

Re: [GENERAL] more custom C function fun

2008-05-06 Thread Martijn van Oosterhout
On Tue, May 06, 2008 at 09:39:50AM -0600, Dan Heron Myers wrote: > Using DatumToCString(mytextvariable), I get single-character-length > strings that do not match the data actually in the fields. Correct, because it's not a cstring. Pretending it is one gives you garbage. > Using VARDATA(mytextv

Re: [GENERAL] more custom C function fun

2008-05-06 Thread Dan "Heron" Myers
Martijn van Oosterhout wrote: You do realise that VARDATA does not return a null terminated string? I did not realize that... but it led me in the right direction. Try using something like text_to_cstring or using elog(NOTICE) to display what's actually being compared. I've outputted some

Re: [GENERAL] Autocast script of peter e in PostgreSQL 8.3

2008-05-06 Thread Martijn van Oosterhout
On Tue, May 06, 2008 at 03:37:57PM +0200, Daniel Schuchardt wrote: > Hey Matijn, > > it simply does not work. Every created CAST will crash with the '||' > operator. > > Thnx for your comments, Did you not find this during your searching? http://archives.postgresql.org/pgsql-general/2008-03/ms

Re: [GENERAL] Autocast script of peter e in PostgreSQL 8.3

2008-05-06 Thread Daniel Schuchardt
Martijn van Oosterhout schrieb: On Tue, May 06, 2008 at 02:09:30PM +0200, Daniel Schuchardt wrote: *SCDS=# SELECT 1||'~'||1; ERROR: operator is not unique: integer || unknown at character 9 HINT: Could not choose a best candidate operator. You might need to add explicit type casts. LINE 1

[GENERAL] storing long live parameters

2008-05-06 Thread Ivan Sergio Borgonovo
I've some nearly static tables that store id that comes handy as "constant". I'd like to keep maintenance as low as possible and still avoid to execute selects looking for the current value of a certain ID. eg. I may have stages of a process stored in a table, that table is not going to change oft

Re: [GENERAL] Feature request

2008-05-06 Thread Scott Miller
On Sun, May 4, 2008 at 12:31 AM, Scott Marlowe <[EMAIL PROTECTED]> wrote: > > You have the same type of problem if you have this query: > > select count(id), count(int2) from table. > > They both are named count. The simple answer is to always alias your > select fields. > > select count(id) as i

Re: [GENERAL] Autocast script of peter e in PostgreSQL 8.3

2008-05-06 Thread Martijn van Oosterhout
On Tue, May 06, 2008 at 02:09:30PM +0200, Daniel Schuchardt wrote: > *SCDS=# SELECT 1||'~'||1; > ERROR: operator is not unique: integer || unknown at character 9 > HINT: Could not choose a best candidate operator. You might need to add > explicit type casts. > LINE 1: SELECT 1||'~'||1; Check th

[GENERAL] CREATE CHARSET would be nice feature

2008-05-06 Thread Michael Enke
Hi all, I had to get data out of postgresql in CP852 encoding (internally stored in UNICODE). So I wrote my own encoding function and used CREATE DEFAULT ENCODING. The problem with this is: I can only use character set names which are known internally. So I "misused" the LATIN2: update pg_conver

Re: [GENERAL] Extract only numbers from a varchar column

2008-05-06 Thread Leandro Casadei
-- Forwarded message -- From: Leandro Casadei <[EMAIL PROTECTED]> Date: May 5, 2008 2:08 PM Subject: Extract only numbers from a varchar column To: pgsql-general@postgresql.org I need to extract only the first occurence of numbers from a column that is varchar. Here are a few exa

Re: [GENERAL] Speed up repetitive queries

2008-05-06 Thread Javier Olazaguirre
Hi, Thanx for your help. I don't think the application is preparing the query, I think it just runs the same query again and again as if it were completely different each time, althoug it's not. I paste some lines of the log file during the execution of the software: 2008-04-30 19:59:22.923 CES

[GENERAL] Extract only numbers from a varchar column

2008-05-06 Thread Leandro Casadei
I need to extract only the first occurence of numbers from a column that is varchar. Here are a few examples of what I need to do: abc200xx -> 200 340ppsdd -> 340 150ytyty555 -> 150 Can this be done by a simple query or do I need to use a cursor? Thanks

[GENERAL] PostgreSQL 8.3.x Win32-Releases - always without psqlODBC?

2008-05-06 Thread Robert Max Kramer
Hi, We are using PostgreSQL 8.2.x and like to upgrade to 8.3.x. So I downloaded and installed the Win32-Binaries. This happens with shell scripts that I had to modify because it seems that the ODBC driver isn't included anymore (checkes 8.3.0 and 8.3.1). Also the module msvclibs isn't available.

[GENERAL] Autocast script of peter e in PostgreSQL 8.3

2008-05-06 Thread Daniel Schuchardt
If i use this script http://people.planetpostgresql.org/peter/index.php?/archives/18-Readding-implicit-casts-in-PostgreSQL-8.3.html in PostgreSql 8.3 to reactivate autocast i get the following problems: *without autocast* script (i learned that 8.3 does autocast if one of the || parameters is T

Re: [GENERAL] now i'm really confused. insert/update does autocast, where sometimes.

2008-05-06 Thread Martijn van Oosterhout
On Tue, May 06, 2008 at 11:31:55AM +0200, Daniel Schuchardt wrote: > demo=# SELECT * FROM a WHERE b=3||'~1'; > a | b > ---+- > 5 | 3~1 > 6 | 3~1 > 7 | 3~1 > (3 rows) The difference is the use of '||' which will autocast *if* one of the arguments is text. I was about to ask it you'd actually

[GENERAL] now i'm really confused. insert/update does autocast, where sometimes.

2008-05-06 Thread Daniel Schuchardt
Daniel Schuchardt schrieb: Hey Group, i know what all will say but i need to recreate the = operator for datatypes varchar and integer in PostgreSQL 8.3. Our Software Project has Millions of Lines and so it would be difficult to check all queries and Datatypes. Also it works really fine and

Re: [GENERAL] now i'm really confused. insert/update does autocast, where sometimes.

2008-05-06 Thread Daniel Schuchardt
demo=# ALTER TABLE a ADD COLUMN d VARCHAR; ALTER TABLE demo=# UPDATE a SET d=current_date; UPDATE 3 demo=# SELECT * FROM a WHERE d=current_date; ERROR: operator does not exist: character varying = date at character 24 HINT: No operator matches the given name and argument type(s). You might need

Re: [GENERAL] operator is not unique: integer || integer

2008-05-06 Thread Daniel Schuchardt
Alban Hertroys schrieb: another example?: RAISE NOTICE "error during validation % :", 'ks:"'||ks||'"@"'||loopdate||'"'; (here LoopDate is a DateTime) Ehm... What's wrong with RAISE NOTICE "error during validation ks:"%"@"%" :', ks, loopdate; ? (I don't quite understand the purpose of that

Re: [GENERAL] Custom C function - is palloc broken?

2008-05-06 Thread Dave Page
On Tue, May 6, 2008 at 4:18 AM, Joshua D. Drake <[EMAIL PROTECTED]> wrote: > Just FYI, the "installer" project as of 8.3 (I don't know about previous > releases) is using MSVC++ as far as I know. It is. Visual Studio 2005 Professional w/SP1 to be precise. > I see now that the FAQ appears to be o

Re: [GENERAL] Custom C function - is palloc broken?

2008-05-06 Thread Dave Page
On Tue, May 6, 2008 at 5:02 AM, Craig Ringer <[EMAIL PROTECTED]> wrote: > WIN32 is defined by all Microsoft build tools EXCEPT Visual Studio > Express Edition 2005's default win32 project, which is why 2005 wasn't > working but 2008 was. It certainly is defined on my copy. -- Dave Page Enterpris

Re: [GENERAL] operator is not unique: integer || integer

2008-05-06 Thread Daniel Schuchardt
Klint Gore schrieb: > RAISE NOTICE "error during validation % :", 'ks:"'||ks||'"@"'||loopdate||'"'; (here LoopDate is a DateTime) You know you can use more than one % in a raise and it will take care of the data types? yes i know. the real code looks like this: S:='another ABG found on ks

Re: [GENERAL] Silent install 8.3 diiffers from 8.2

2008-05-06 Thread Syra . Didelez
anyone ? - Syra Didelez - Apogee Portal Deployment Manager Apogee Portal Hotfix Manager Agfa-Gevaert N.V. Tel.: +32 3 444 4237 http://www.agfa.com

Re: [GENERAL] Request for Materialized Views

2008-05-06 Thread Harald Armin Massa
Jan, > we arrived at the conclusion that we really need "Materialized Views" > for our further business. just some information http://wiki.postgresql.org/wiki/Updatable_views are on the wishlist for PostgreSQL 8.4; and (Bernd) is the one coordinating it: http://wiki.postgresql.org/wiki/Todo:W