[SQL] query PostgreSQL from c++

2001-05-22 Thread chris Günther
Hi folks, I'm asked to write a "small" c++ application to query a PostgreSQL DB. In principel I can't see why this should be so difficult but I don't really know a lot about the API. Therefor I thought I just ask if anyone has done this before - of course I think - and might be able and willing t

[SQL] RULES

2001-05-22 Thread J.Fernando Moyano
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Well ... i'm testing carefully the two rules ==> CREATE RULE piezas_add AS ON insert TO piezas DO update materia_prima set usadas=(usadas+1) where n_material=new.n_material; CREATE RULE piezas_delete AS ON delete

[SQL] Re: timestamp bug

2001-05-22 Thread Alexander Dederer
Cedar Cox wrote: > > There appears to be a bug in timestamp/interval addition. It happens in > both PG version 7.0.2 and 7.1. There is a duplicate day (2001 Sep 07) and > a missing day (2002 Apr 04). I discovered this by accident when I asked > the interface I'm writing for a 365 day long cal

[SQL] Set Datestyle

2001-05-22 Thread Tubagus Nizomi
Hallo, i have postgres 7.1 in Radhat 6.5 the Datestype default is ISO format where is change default Datestyle to Postgres format ?? i used Set Datestyle to postgres in plsql test#>select now() now 2001-05-21 09:55:36+07 test#>set datestyle to postgres; S

[SQL] convert date to time?

2001-05-22 Thread speeves
Hi! I am migrating a bunch of cf applications that are using access as a backend, and pgadmin is converting all date/time data types to date data types on the postgres side. I want to convert these columns to the appropriate time data types, but am unable to using CAST( according to the pop-

[SQL] c++ wrapper library

2001-05-22 Thread LeoDeBeo
hi, i wonder if there exists a c++ wrapper library to libpq (or native c++ library to postgresql). I'd like to be able to develop c++ applications importing classes from libraries: classes like database connections, data sources, sql-queries, much like for example de database-components in D

[SQL] Re: Transposing data

2001-05-22 Thread Hans-Jürgen Schönig
I have also thought of a solution like that but the problem is that I do not have a complete list of all values occuring in the column so it has to be dynamical. The second problem is that the amount of data involved may become huge. Hans Alexander Dederer schrieb: > Hans-J?rgen Sch?nig wro

[SQL] Why indexes are not used when scanning from functions?

2001-05-22 Thread "Ловпаче Айдамир"
The table (script followed) contains more than 20 records. When I directly selecting records by the single select statement select fio from patient_temp where fio like 'something%'; Postgres uses the index i have created and quickly returns the results. But if that query included in

[SQL] Re: Transposing data

2001-05-22 Thread Alexander Dederer
Hans-J?rgen Sch?nig wrote: > I want the values in column label to be displayed in the a-axis. Is > there an easy way to transform the data: > Here is the input data: > age_code | label | count > --+---+--- > age_1| 30k | 1 > age_1| 50k | 2 > age_1| more

[SQL] Help with ECPG on debian Potato

2001-05-22 Thread BOUCHPAN-LERUST-JUERY Lionel
Hi, I am running Debian GNU/Linux potato and I have a problem with ECPG: when I type the example provided in the PostgreSQL book: http://www.ca.postgresql.org/docs/aw_pgsql_book/node149.html I type : piou@yoda:~/BD$ ecpg truc.pgc and I have the following error : Error: Cannot open include file S

[SQL] Transposing data

2001-05-22 Thread Hans-Jürgen Schönig
I want the values in column label to be displayed in the a-axis. Is there an easy way to transform the data: Here is the input data: age_code | label | count --+---+--- age_1| 30k | 1 age_1| 50k | 2 age_1| more | 2 age_2| 40k | 2 age_3

Re: [SQL] Calculating the age of a person

2001-05-22 Thread Najm Hashmi
Hans-Jürgen Schönig wrote: > I have a table containing the birthdays of various persons. The target > is to compute the age of a persons. > > persons=# SELECT age(birth), * FROM persons LIMIT 1; > age | id | name | birth| gender | > income > ---

[SQL] PL/pgSQL problem with variables

2001-05-22 Thread Hans-Jürgen Schönig
I want to write a function that creates a new column for every value found in the table but something seems to go wrong with the variable: CREATE FUNCTION transp() RETURNS int4 AS ' DECLARE col RECORD; cname varchar; BEGIN CREATE TAB

Re: [SQL] RULES

2001-05-22 Thread Ross J. Reedstrom
On Tue, May 22, 2001 at 10:44:06AM +0300, Mart?n Marqu?s wrote: > On Mar 22 May 2001 20:19, J.Fernando Moyano wrote: > > Deleting is broken if it deletes more than one row. The rule is executed > > only one time each delete command, and not one time each deleted row. > > > > It's this OK ??? Am i

[SQL] implied rows when a rule gets executed.

2001-05-22 Thread J.Fernando Moyano
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 In a rule... is there some way of getting the number of rows updated by the query that activates this rule ?? Martín Marqués says: >You'll have to do more advance programing there. See if count(*) can help >you >in any way. >I see you have to up

[SQL] index/join madness

2001-05-22 Thread Michael Richards
Ok, I've built the most insane query ever. It joins 11 tables, most of which are the same table, just extracting different values. Here is the query plan: Nested Loop (cost=0.00..5011.89 rows=1 width=156) -> Nested Loop (cost=0.00..4191.82 rows=1 width=140) -> Nested Loop (cost=0.