Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread hubert depesz lubaczewski
On Mon, Nov 12, 2007 at 03:11:50PM -0800, Sarah Dougherty wrote: To recap with an example, the query below works fine, but how do I add a series to it? generate_series will not help with this. try the sequence approach, or this:

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread Tom Lane
hubert depesz lubaczewski [EMAIL PROTECTED] writes: On Mon, Nov 12, 2007 at 03:11:50PM -0800, Sarah Dougherty wrote: To recap with an example, the query below works fine, but how do I add a series to it? generate_series will not help with this. try the sequence approach, or this:

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread Tom Lane
hubert depesz lubaczewski [EMAIL PROTECTED] writes: On Wed, Nov 14, 2007 at 10:26:52AM -0500, Tom Lane wrote: That's a fairly ugly/messy way of doing it. If you're going to need a C function anyway, why not just do it directly? As in the attachment. actually you dont have to do it in c.

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread hubert depesz lubaczewski
On Wed, Nov 14, 2007 at 10:26:52AM -0500, Tom Lane wrote: That's a fairly ugly/messy way of doing it. If you're going to need a C function anyway, why not just do it directly? As in the attachment. actually you dont have to do it in c. alec pointed (in comments) that there already is

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread Jan de Visser
On 11/14/07, Tom Lane [EMAIL PROTECTED] wrote: hubert depesz lubaczewski [EMAIL PROTECTED] writes: On Mon, Nov 12, 2007 at 03:11:50PM -0800, Sarah Dougherty wrote: To recap with an example, the query below works fine, but how do I add a series to it? generate_series will not help with

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread Jan de Visser
On 11/14/07, Tom Lane [EMAIL PROTECTED] wrote: Jan de Visser [EMAIL PROTECTED] writes: Any reason why this couldn't appear in the core of some future version? You didn't read to the end of my post ;-). If a rownum() function like this didn't have any gotchas, I'd be in favor of putting it

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-14 Thread Tom Lane
Jan de Visser [EMAIL PROTECTED] writes: Any reason why this couldn't appear in the core of some future version? You didn't read to the end of my post ;-). If a rownum() function like this didn't have any gotchas, I'd be in favor of putting it in, but I don't really want to set the behavior in

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-13 Thread Decibel!
On Nov 12, 2007, at 5:11 PM, Sarah Dougherty wrote: For some context, I am trying to create a report that provides a list of client charges and payments and a running balance after each transaction. Because we often have multiple charges and/or payments on the same day, we can't use the

[GENERAL] Using generate_series to create a unique ID in a query?

2007-11-12 Thread Sarah Dougherty
Hello, I am trying to create a view that will contain a generated sequence (unique ID), and am running into problems doing so. For some context, I am trying to create a report that provides a list of client charges and payments and a running balance after each transaction. Because we often

Re: [GENERAL] Using generate_series to create a unique ID in a query?

2007-11-12 Thread Pavel Stehule
Hello use temporary sequence instead. postgres=#create temp sequence a; CREATE SEQUENCE postgres=# select nextval('a'), b FROM (values(1),(2),(10),(20)) b(b); nextval | b -+ 1 | 1 2 | 2 3 | 10 4 | 20 (4 rows) Regards Pavel Stehule On 13/11/2007, Sarah