Re: [SQL] postgre variable

2005-05-19 Thread Richard Huxton
bandeng wrote:
hello all,
i want to make dynamic sql query like this
select * from tb_cust where name='erick' and age='20'
to
select * from tb_cust $1
i have tried but error comeup
You have tried what? How? What error did you get?
--
  Richard Huxton
  Archonet Ltd
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly


Re: [SQL] postgre variable

2005-05-19 Thread Volkan YAZICI
Hi,

On 5/19/05, bandeng <[EMAIL PROTECTED]> wrote:
> i want to make dynamic sql query like this
> 
> select * from tb_cust where name='erick' and age='20'
> 
> to
> 
> select * from tb_cust $1
> 
> i have tried but error comeup

I think there's a confusion about the usage of parameters like $1, $2,
... etc. You cannot use parameters for a whole statement like "where
name='erick' and age='20'" or "name='erick'". It's only useful to
point returned fields. Namely, above SQL query should be:

SELECT * FROM tb_cust WHERE name = $1 AND age = $2;

Plus beware it doesn't need quotes around parameter. Moreover, if
you're using some PostgreSQL API, you don't need to escape data
inserted by parameters. You may refer to documentation for further
information.

Regards.

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [SQL] Meaning of ERROR: tuple concurrently updated

2005-05-19 Thread KÖPFERL Robert

|PFERL_Robert?= <[EMAIL PROTECTED]> writes:
|> Thus I run VACUUM ANALYZE; every night by cron. However I 
|keep getting
|> ERROR:  tuple concurrently updated
|
|Have you got other processes also doing VACUUM ANALYZE?  The only known
|reason for this to happen is that two processes concurrently 
|ANALYZE the
|same table and conflict when they both try to update the same
|pg_statistic rows.
|
|   regards, tom lane
Tnaks.

No, I can't imagine any other instance that would issue a VACUUM ANALYZE at
the same time.
Could it be some kind of auto statistics which is updated all the time?

Would it be a solution to omit the ANALYZE and just do a VACUUM?
|

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] postgre variable

2005-05-19 Thread KÖPFERL Robert
You should considder a variation as Volkan suggested.

Otherwise the EXECUTE command might be what you are looking for.
Execute a sql made up in a string

|-Original Message-
|From: bandeng [mailto:[EMAIL PROTECTED]
|Sent: Donnerstag, 19. Mai 2005 04:11
|To: [email protected]
|Subject: [SQL] postgre variable
|
|
|hello all,
|
|i want to make dynamic sql query like this
|
|select * from tb_cust where name='erick' and age='20'
|
|to
|
|select * from tb_cust $1
|
|i have tried but error comeup
|
|any suggestion?
|
|thanks
|Ricky
|-- 
|Gutten Aben Sugeng Sonten, Jangane Kurang Santen
|bandeng
|
|---(end of 
|broadcast)---
|TIP 9: the planner will ignore your desire to choose an index 
|scan if your
|  joining column's datatypes do not match
|

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


[SQL] Aggregate Functions Template

2005-05-19 Thread Mark Fenbers
I need to create an aggregate function to do some math not currently 
provided by the available tools.  Can someone point to an example 
aggregate function syntax that I can use as a template for my own 
function.  I'm still a little green on some aspects of PostgreSQL and am 
drawing a blank on how to do this properly from scratch.

Thanks for the help!
Mark
begin:vcard
fn:Mark Fenbers
n:Fenbers;Mark
org:DoC/NOAA/NWS/OHRFC
adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA
email;internet:[EMAIL PROTECTED]
title:Sr. HAS Meteorologist
tel;work:937-383-0430 x246
x-mozilla-html:TRUE
url:http://weather.gov/ohrfc
version:2.1
end:vcard


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] Aggregate Functions Template

2005-05-19 Thread Michael Fuhr
On Thu, May 19, 2005 at 03:17:07PM -0400, Mark Fenbers wrote:
>
> I need to create an aggregate function to do some math not currently 
> provided by the available tools.  Can someone point to an example 
> aggregate function syntax that I can use as a template for my own 
> function.  I'm still a little green on some aspects of PostgreSQL and am 
> drawing a blank on how to do this properly from scratch.

The General Bits newsletter has a few examples that might be helpful,
even if they're not quite what you're after:

http://www.varlena.com/varlena/GeneralBits/109.php
http://www.varlena.com/varlena/GeneralBits/4.html

There are sure to be some examples in the list archives -- just
search for "create aggregate":

http://archives.postgresql.org/

If these links don't help, then please post more details about what
you're trying to do and what trouble you're having.  If you have
any code that doesn't work the way you want but that helps show
what you're after, then go ahead and post it with an explanation
of what it does (or doesn't do) and what you'd like it to do (or
not do).

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]