[SQL] query/transaction history/logs

2002-07-10 Thread q
Is there anyway we can track queries entered? Is there a table that stores all the actions that a user entered? (history) Is there such a feature? ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] query/transaction history/logs

2002-07-10 Thread David BOURIAUD
Le Mercredi 10 Juillet 2002 10:34, q a écrit : > Is there anyway we can track queries entered? > Is there a table that stores all the actions that a user entered? (history) > Is there such a feature? > For both of your problems, see the way you can launch the postmaster. For example, I use to laun

[SQL] Help with function optimisation

2002-07-10 Thread Ian Cass
Hi, I've got a function that I run as a trigger to update a summary table on insert to the main table. As you can see below, it does a select & an INSERT if not found, or an UPDATE if found. This currently works OK, but I'd like to improve performance by removing the SELECT & attempting an UPDATE

Re: [SQL] Problem on PostgreSQL (error code, store procedures)

2002-07-10 Thread Christoph Haller
> > I would like to know if there are any global variables > storing the error code or the number of rows affected > after each execution of the SQL statement. You did not mention which interface you are using. In C there are functions available like extern const char *PQcmdTuples(PGresult *r

Re: [SQL] Variables in PSQL

2002-07-10 Thread Christoph Haller
> > I'm trying to declare a variable in PostgreSQL, so I can save some values in > it. After, I want to calculate with this variable. > For example: > > declare vp integer; > select price into :vp from article where anr = 1; > vp := vp + 1; > update article set price = :vp where anr = 1; AFAIK,

[SQL] Error with DISTINCT and AS keywords

2002-07-10 Thread Andreas Schlegel
Hi, I need some help to let this sql statement run with Postgres 7.2.1 Doesn't work: select DISTINCT tnr, titel, 'TEST' AS testcol from tTitel; ERROR: Unable to identify an ordering operator '<' for type 'unknown' Use an explicit ordering operator or modify the query If I remove the D

Re: [SQL] Bad SUM result

2002-07-10 Thread Petr Jezek
There're no another ways? It don't looks like optimal. Petr Jezek - Original Message - From: "Jean-Luc Lachance" <[EMAIL PROTECTED]> To: "Roy Souther" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, July 08, 2002 5:22 PM Subject: Re: [SQL] Bad SUM result > That is because your

[SQL] How to get total number of rows when using LIMIT/OFFSET?

2002-07-10 Thread Dirk Lutzebaeck
Hello, when using LIMIT/OFFSET is it possible to get also the total number of rows besides the actual number of rows of the select? It should be there because the whole list is ordered anyhow. I'm using 7.2.1. Thanks for help, Dirk ---(end of broadcast)--

Re: [SQL] Error with DISTINCT and AS keywords

2002-07-10 Thread Achilleus Mantzios
On Wed, 10 Jul 2002, Andreas Schlegel wrote: > Hi, > > I need some help to let this sql statement run with Postgres 7.2.1 > > Doesn't work: > select DISTINCT tnr, titel, 'TEST' AS testcol from tTitel; > ERROR: Unable to identify an ordering operator '<' for type 'unknown' > Use an exp

Re: [SQL] Help with function optimisation

2002-07-10 Thread Tom Lane
"Ian Cass" <[EMAIL PROTECTED]> writes: > I've got a function that I run as a trigger to update a summary table on > insert to the main table. As you can see below, it does a select & an INSERT > if not found, or an UPDATE if found. This currently works OK, but I'd like > to improve performance by

Re: [SQL] Error with DISTINCT and AS keywords

2002-07-10 Thread Richard Huxton
On Wednesday 10 Jul 2002 1:25 pm, Achilleus Mantzios wrote: > On Wed, 10 Jul 2002, Andreas Schlegel wrote: > > select DISTINCT tnr, titel, 'TEST' AS testcol from tTitel; > > ERROR: Unable to identify an ordering operator '<' for type 'unknown' > > Use an explicit ordering operator or mo

Re: [SQL] Error with DISTINCT and AS keywords

2002-07-10 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Does anyone know what type a quoted literal has? It's assigned the placeholder type UNKNOWN until the parser can figure out from context what type it should be. Unfortunately in this case there's no context the parser knows how to work with. > It doe

Re: [SQL] Error with DISTINCT and AS keywords

2002-07-10 Thread Jean-Luc Lachance
PostgreSQL does not know how to sort 'TEST'. You must help it be telling it what tpe it is. Add ::text after 'TEST' as in 'TEST'::text. Maybe PostgreSQL should default to text for unknown types... JLL Andreas Schlegel wrote: > > Hi, > > I need some help to let this sql statement run with Po

Re: [SQL] Waiting for Update

2002-07-10 Thread Jan Wieck
JGM wrote: > > Could it be true?? > > I've a table with < 46000 rows. And a little Update like > > UPDATE foo set xxx = 'X'; > > needs about 15 seconds??? > > What's wrong? How long since you vacuumed that table? How big are the rows? Are there triggers, constraints, anything fancy? How many

Re: [SQL] pg_restore cannot restore index

2002-07-10 Thread Jie Liang
Thanks! But I did not make long form works also, is it: pg_restore --index="\"indexname\"" --dbname=mydb mydumpfile ??? msg: pg_restore:[archiver] could open input file: No such file or directory could you give out a example of long form Thanks again. Jie Liang -Original Mes

[SQL] BETWEEN bug?

2002-07-10 Thread Josh Berkus
Folks, Why does BETWEEN only work for ascending criteria? For example: jwnet=> select '2002-06-07'::TIMESTAMP BETWEEN '2002-06-29'::TIMESTAMP and '2002-06-01'::TIMESTAMP; ?column? -- f (1 row) jwnet=> select '2002-06-07'::TIMESTAMP BETWEEN '2002-06-01'::TIMESTAMP and '2002-06-29'::

[SQL] Insert Function

2002-07-10 Thread David Durst
Is there anyway to create a insert function? I am trying: CREATE FUNCTION add_user(varchar(20),varchar(20),varchar(20),int4,int4) RETURNS int4 AS 'INSERT INTO usr (user_name,first_name,last_name,permission_set_id,customer_id) values ($1,$2,$3,$4,$5)' language 'sql'; and get: ERROR: function dec

Re: [SQL] BETWEEN bug?

2002-07-10 Thread Stephan Szabo
On Wed, 10 Jul 2002, Josh Berkus wrote: > Folks, > > Why does BETWEEN only work for ascending criteria? For example: > > jwnet=> select '2002-06-07'::TIMESTAMP BETWEEN '2002-06-29'::TIMESTAMP and > '2002-06-01'::TIMESTAMP; > ?column? > -- > f > (1 row) > > jwnet=> select '2002-06-07':

Re: [SQL] Insert Function

2002-07-10 Thread Ian Barwick
On Wednesday 10 July 2002 21:59, David Durst wrote: > Is there anyway to create a insert function? > I am trying: > CREATE FUNCTION add_user(varchar(20),varchar(20),varchar(20),int4,int4) > RETURNS int4 AS 'INSERT INTO usr > (user_name,first_name,last_name,permission_set_id,customer_id) values > (

Re: [SQL] BETWEEN bug?

2002-07-10 Thread Josh Berkus
Stephan, > Spec thing. > > In SQL92, > "X BETWEEN Y AND Z" is equivalent to "X>=Y AND X<=Z". > > In SQL99, there's BETWEEN SYMMETRIC and ASYMMETRIC, but ASYMMETRIC is the > default which is the same as the SQL92 version afaics. Symmetric is an > optional feature that I think Christopher's been

[SQL] Returning rows from functions

2002-07-10 Thread David Durst
I was wondering if there was a way of returning a complete row from a function, in reading the documentation of CREATE FUNCTION. I was under the impression that you could return a row by using setof, but this does not seem to be true. Can anyone help? ---(end of broadcas

Re: [SQL] How to get total number of rows when using LIMIT/OFFSET?

2002-07-10 Thread Bruce Momjian
Dirk Lutzebaeck wrote: > > Hello, > > when using LIMIT/OFFSET is it possible to get also the total number of rows > besides the actual number of rows of the select? It should be there > because the whole list is ordered anyhow. I'm using 7.2.1. No way to do that. Perhaps a CURSOR and look at t

Re: [SQL] pg_restore cannot restore index

2002-07-10 Thread Bruce Momjian
Jie Liang wrote: > Thanks! > But I did not make long form works also, is it: > pg_restore --index="\"indexname\"" --dbname=mydb mydumpfile > ??? > msg: > pg_restore:[archiver] could open input file: No such file or directory Strange. I found a few more problems with the getopt values in

Re: [SQL] BETWEEN bug?

2002-07-10 Thread Josh Berkus
Stephan, > Thanks. Thought it was something like that. > > Thank you guys, though, OVERLAPS is asymmetric. Err ... I meant "symmetric". -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 6: Have you searche

Re: [SQL] Returning rows from functions

2002-07-10 Thread Joe Conway
David Durst wrote: > I was wondering if there was a way of returning a complete row from a > function, in reading the documentation of CREATE FUNCTION. I was under the > impression that you could return a row by using setof, but this does not > seem to be true. > Can anyone help? The short answer

Re: [SQL] Insert Function

2002-07-10 Thread Ian Barwick
On Wednesday 10 July 2002 23:04, David Durst wrote: > I am not sure what the end select does, so if you can give me a explination > it would be apreciated It is there to satisfy the requirement that the function should return a value from a select statement: "12.2. Query Language (SQL) Functions