Re: [SQL] plpgsql vs. SQL in stored procedures

2004-03-31 Thread Christopher Browne
[EMAIL PROTECTED] (Ivan Sergio Borgonovo) wrote: > Is there a way to declare variables and use IF in plain SQL, not in > plpgsql inside stored procedures? The forthcoming support for recursive queries using a WITH clause might provide, after a fashion, a way to declare variables. As for IF, there

[SQL] Timestamp manipulation

2004-03-31 Thread Stephen Quinney
I am having a bit of difficulty trying to find a solution to this problem of manipulating timestamps and dates so I hope someone can enlighten me. I have a table which contains a column of type timestamp. For each row I want to find out the dates for the beginning and end of the week within which

Re: [SQL] plpgsql vs. SQL in stored procedures

2004-03-31 Thread Ivan Sergio Borgonovo
On Wed, 31 Mar 2004 03:31:01 -0500 Christopher Browne <[EMAIL PROTECTED]> wrote: > The forthcoming support for recursive queries using a WITH clause > might provide, after a fashion, a way to declare variables. I think I'll have to work with pg 7.3 Does this translate to: you won't be able to use

Re: [SQL] plpgsql vs. SQL in stored procedures

2004-03-31 Thread Richard Huxton
On Wednesday 31 March 2004 12:07, Ivan Sergio Borgonovo wrote: > > I was used to do stuff like this with MS SQL > > create proc sp_getuid @uid uniqueidentifier [snip] > Does it mean that to have variables in SP I'll have to use plpgsql > in spite of plain SQL? Yep - just like there you were using

[SQL] Is it normal that functions are so much faster than inline queries

2004-03-31 Thread Olivier Hubaut
I'm doing some test on our PgSQL 7.3.4 and I can't believe what I see: When I want to execute this set of queries in a function: DELETE FROM oly.amaze_log_report WHERE batch = $1 ; INSERT INTO oly.amaze_log_report SELECT $1, 'DATA', 'MISSING_NEWREF_DECLARATION', 'ERROR', tmp.error_count, 'Miss

Re: [SQL] Is it normal that functions are so much faster than inline queries

2004-03-31 Thread Tom Lane
"Olivier Hubaut" <[EMAIL PROTECTED]> writes: > When I want to execute this set of queries in a function: > ... > It takes only 2 seconds. > But when I tried to do it directly in the psql term (replacing the $1 > value with the same used in the function call), I'm obliged to kill the > second q

[SQL] left join on a view takes significantly more time.

2004-03-31 Thread Manuel Sugawara
Hi, I'm facing a wired problem. When I left join two tables PostgreSQL is able to do it fast using the corresponding indices, However, if I define a simple view (to format the data) on one of the tables, the left join does not use the indices. Is something wrong here? The two tables: ***

Re: [SQL] SQL Spec Compliance Questions

2004-03-31 Thread Josh Berkus
Tom, > This looks more like an underling with a checklist than a serious > inquiry. Can you get them to specify particular capabilities that they > need? In sufficient detail that we could actually answer? Ok, talked with him. They are trying to plan OO-->DB mapping in 3 programming language

Re: [SQL] left join on a view takes significantly more time.

2004-03-31 Thread Josh Berkus
Manuel, > I'm facing a wired problem. When I left join two tables PostgreSQL is > able to do it fast using the corresponding indices, However, if I > define a simple view (to format the data) on one of the tables, the > left join does not use the indices. Is something wrong here? At a guess, the