Re: [SQL] selecting duplicate records

2003-09-23 Thread Guy Fraser
This is a test I did on one of my tables where I put duplicated entries : select * from acct_other_2003sep except select sep.* from ( select min(oid) as min_oid, "Acct-Status-Type", "User-Name", "Realm", "Acct-Session-Time", "Acct-Input-Octets", "Acct-Output-Octets", "Called-Station

Re: [SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > Do you know anything about good source of C functions documentation and > examples? Look in the main sources (backend/utils/adt/, mostly) and/or contrib modules for functions that do something like what you need. The only difference between a builtin fu

Re: [SQL] Using sql statements in file

2003-09-23 Thread scott.marlowe
On Mon, 22 Sep 2003, Suresh Basandra wrote: > Hi, > > I would like to do the following using files: > > 1. put create database, create tables sql statements in a file and > execute through prompt > 2. insert or update data that is put in a file > > Please let me know if there are any example

Re: [SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tomasz Myrta
I don't understand ERROR message at all: ERROR: SPI_prepare() failed on "SELECT $1 " > This is a bug. Or two bugs, actually: one of yours and one of PG's. I have repaired the PG bug with the attached patch. The bug in your code is that your C function needs to call SPI_connect and SPI_fin

[SQL] updating a field with a SUM from another table

2003-09-23 Thread Jeff Kowalczyk
My SQL is apparently a bit rusty, can anyone advise how to refactor this updatecharges query to work? I need to update a total-charges field in my orders table with the sum of the line-item charges in another table. The tables are related by the orderid column. Thanks for any help you can provide

Re: [SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > I don't understand ERROR message at all: > ERROR: SPI_prepare() failed on "SELECT $1 " This is a bug. Or two bugs, actually: one of yours and one of PG's. I have repaired the PG bug with the attached patch. The bug in your code is that your C func

[SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tomasz Myrta
Hi I'm making my first steps in C functions. I want to avoid doing all the SQL job in them, pl/pgsql looks a better choice. I tried to do this by passing opened cursor from pl/pgsql function to C function. Here is simple C function: #include #include PG_FUNCTION_INFO_V1(test2); Datum test2(PG_