Re: [SQL] Select Maths

2006-07-10 Thread Phillip Smith
Beautiful Works a treat. Thanks Aaron. A follow-on problem now I have the below column in the select, but I need to validate the value across all 3 rules I need to assign it to a variable!! Example my pqty function calculates a value less than the suppliers minimum order qty (and

Re: [SQL] SELECT substring with regex

2006-07-10 Thread T E Schmitz
Emils wrote: 2006/7/7, T E Schmitz [EMAIL PROTECTED]: valid entries would be: 28mm F2.8 (prime lens) 30-70mm F4 (zoom lens) 30-70mm F2.8 (zoom lens) 30-100mm F4.5-5.6 (zoom lens with variable speed) If these are the cases, wouldn't the regex be simply: ^[\d\-]+mm for BASE ^[\d\-]+mm

[SQL] MS-SQL-Postgres sync

2006-07-10 Thread Kevin Bednar
Looking to keep 2 databases in sync, at least semi-realtime if possible, although running a batch update every x mins wouldn't be out of the question. One db is postgres and the other is ms-sql. It's to keep inventory in sync from 2 seperate locations, one being a brick and mortar store and

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Forums @ Existanze
WearelookingfortheexactthingbutwithtwoPostgreSQLdatabases From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin BednarSent: 10 July 2006 18:28To: pgsql-sql@postgresql.orgSubject: [SQL] MS-SQL-Postgres sync Looking to keep 2 databases in sync, at least

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Andrew Sullivan
On Mon, Jul 10, 2006 at 11:27:52AM -0400, Kevin Bednar wrote: Looking to keep 2 databases in sync, at least semi-realtime if possible, although running a batch update every x mins wouldn't be out of the question. One db is postgres and the other is ms-sql. It's to keep inventory in sync

Re: [SQL] Select Maths

2006-07-10 Thread Aaron Bono
On 7/10/06, Phillip Smith [EMAIL PROTECTED] wrote: Beautiful – Works a treat. Thanks Aaron. A follow-on problem now… I have the below column in the select, but I need to validate the value across all 3 rules – I need to assign it to a variable!! Example – my pqty function

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Aaron Bono
On 7/10/06, Kevin Bednar [EMAIL PROTECTED] wrote: Looking to keep 2 databases in sync, at least semi-realtime if possible, although running a batch update every x mins wouldn't be out of the question. One db is postgres and the other is ms-sql. It's to keep inventory in sync from 2

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Aaron Bono
Please reply to all when replying on the list...On 7/10/06, Kevin Bednar [EMAIL PROTECTED] wrote: Thanks Aron. What I'm actually trying to do is this: Postgress in physical store, being used by POS system as the back end. MS-SQL being used on web server by ecommerce system. Table

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Kevin Bednar
Yeah, I was kind of thinking that myself. I do have control over both DB's, and postgres does have an ODBC connector available as well. Perhaps using a trigger to watch a temp table on each site and having it replicate to the opposite side and then remove the record from the temp table

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Richard Broersma Jr
On 7/10/06, Kevin Bednar [EMAIL PROTECTED] wrote: Thanks Aron. What I'm actually trying to do is this: Postgress in physical store, being used by POS system as the back end. MS-SQL being used on web server by ecommerce system. Table structures are different of course, but some

[SQL] Can function results be used in WHERE?

2006-07-10 Thread Bryce Nesbitt
I have a function, the results of which seem to apply to ORDER BY and HAVING, but not to WHERE. Is this expected? -- Return distance in some mystery units (TODO: convert to miles or kilometers) CREATE FUNCTION calculate_distance(double precision, double precision, double precision, double

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Scott Marlowe
Look at slony. On Mon, 2006-07-10 at 11:06, Forums @ Existanze wrote: We are looking for the exact thing but with two PostgreSQL databases __ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Kevin Bednar
Took a quick glance but were running windows on both sides and it didnt look like that would work. Didnt look real hard though. Kevin -Original Message-From: Scott Marlowe [EMAIL PROTECTED]To: "Forums @ Existanze" [EMAIL PROTECTED]Cc: pgsql-sql@postgresql.orgDate: Mon, 10 Jul

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Scott Marlowe
On Mon, 2006-07-10 at 11:25, Andrew Sullivan wrote: On Mon, Jul 10, 2006 at 11:27:52AM -0400, Kevin Bednar wrote: Looking to keep 2 databases in sync, at least semi-realtime if possible, although running a batch update every x mins wouldn't be out of the question. One db is postgres and

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Aaron Bono
On 7/10/06, Bryce Nesbitt [EMAIL PROTECTED] wrote: I have a function, the results of which seem to apply to ORDER BY andHAVING, but not to WHERE.Is this expected?-- Return distance in some mystery units (TODO: convert to miles orkilometers)CREATE FUNCTION calculate_distance(double precision,

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Alvaro Herrera
Kevin Bednar wrote: Took a quick glance but were running windows on both sides and it didnt look like that would work. Didnt look real hard though. I think the to-be-released stuff is supposed to have Windows support. They were supposed to release Real Soon Now some time ago, so I guess they

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Scott Marlowe
I think there's a version with windows support due out soon. Not sure, since I don't run windows... just remember seeing it mentioned. On Mon, 2006-07-10 at 13:59, Kevin Bednar wrote: Took a quick glance but were running windows on both sides and it didnt look like that would work. Didnt look

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Dave Page
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Marlowe Sent: 10 July 2006 20:03 To: Kevin Bednar Cc: Forums @ Existanze; pgsql-sql@postgresql.org Subject: Re: [SQL] MS-SQL-Postgres sync I think there's a version with windows support

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Bryce Nesbitt
Aaron Bono wrote: First I recommend making your function IMMUTABLE since, given the same arguments, it gives the same result - this will allow PostgreSQL to optimize the function call and cache the results. Will do! Then, don't use 4, use calculate_distance(lat,lon, 37.789629,-122.422082).

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Aaron Bono
On 7/10/06, Bryce Nesbitt [EMAIL PROTECTED] wrote: I think it is ugly also, but no other syntax seems to work:stage=# selectpod_code,lat,lon,calculate_distance(lat,lon,37.789629,-122.422082) asdist from eg_pod where dist 1 order by dist desc limit 10; ERROR:column dist does not existSELECT

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Bryce Nesbitt
Aaron Bono wrote: On 7/10/06, *Bryce Nesbitt* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I think it is ugly also, but no other syntax seems to work: stage=# select pod_code,lat,lon,calculate_distance(lat,lon,37.789629,-122.422082) as dist from eg_pod where dist 1

Re: [SQL] Select Maths

2006-07-10 Thread Phillip Smith
Example: Funcation pqty(stock.code) calculates a value of 0 for a particular product. This fails the last CASE that makes sure the pqty() value is greater than our Usage Rate * Review Cycle in this case is 3. But that is less than our Minimum Order Qty (First CASE) and not a multiple of

Re: [SQL] MS-SQL-Postgres sync

2006-07-10 Thread Chris Browne
[EMAIL PROTECTED] (Scott Marlowe) writes: On Mon, 2006-07-10 at 11:25, Andrew Sullivan wrote: On Mon, Jul 10, 2006 at 11:27:52AM -0400, Kevin Bednar wrote: Looking to keep 2 databases in sync, at least semi-realtime if possible, although running a batch update every x mins wouldn't be out

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Aaron Bono
On 7/10/06, Bryce Nesbitt [EMAIL PROTECTED] wrote: Aaron Bono wrote: On 7/10/06, *Bryce Nesbitt* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I think it is ugly also, but no other syntax seems to work: stage=# select pod_code,lat,lon,calculate_distance(lat,lon,37.789629,-122.422082) as dist

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Tom Lane
Bryce Nesbitt [EMAIL PROTECTED] writes: stage=# select pod_code,lat,lon,calculate_distance(lat,lon,37.789629,-122.422082) as dist from eg_pod where 4 1 order by dist desc limit 10; [ allegedly returns 10 rows ] I'm having a real hard time believing any of this: WHERE 4 1 is a constant FALSE

Re: [SQL] Select Maths

2006-07-10 Thread Aaron Bono
On 7/10/06, Phillip Smith [EMAIL PROTECTED] wrote: Example: Funcation pqty(stock.code) calculates a value of 0 for a particular product. This fails the last CASE that makes sure the pqty() value is greater than our Usage Rate * Review Cycle – in this case is 3. But that is less

Re: [SQL] Select Maths

2006-07-10 Thread Phillip Smith
It ties back to my other post about the FLAGS column I need to be able to find out if the original pqty() calculation has needed to be modified. I guess what youre saying is to have 2 functions one that calculates the figure I have at the moment, then a second to return the adjusted

Re: [SQL] Can function results be used in WHERE?

2006-07-10 Thread Aaron Bono
On 7/10/06, Tom Lane [EMAIL PROTECTED] wrote: But as far as the underlying misconception goes, you seem to think that4 in the WHERE clause might somehow be taken as referring to thefourth SELECT result column (why you don't think that the 1 would likewise refer to the first result column isn't