Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: No looks like I have 8.2 This works on 8.2: String_to_array(regexp_replace(description,E'\\s+',' ','g'),' ') -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Kevin Duffy
-- From: Scott Marlowe [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2008 5:35 PM To: Kevin Duffy Cc: pgsql-sql@postgresql.org; Frank Bax Subject: Re: [SQL] variables with SELECT statement On Fri, Sep 5, 2008 at 3:28 PM, Kevin Duffy <[EMAIL PROTECTED]> wrote: > No looks like I h

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Scott Marlowe
On Fri, Sep 5, 2008 at 3:28 PM, Kevin Duffy <[EMAIL PROTECTED]> wrote: > No looks like I have 8.2 I can attest that all of 8.3's performance improvements as well all of the really useful new functions like the one mentioned here make it well worth the effort to upgrade. I haven't been as excited

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Kevin Duffy
et me guess I have to upgrade. kd -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Lane Sent: Friday, September 05, 2008 5:27 PM To: Frank Bax Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] variables with SELECT statement Frank Bax <[EMAIL PROTECTED]&

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Kevin Duffy
No looks like I have 8.2 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Bax Sent: Friday, September 05, 2008 5:13 PM Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] variables with SELECT statement Kevin Duffy wrote: > Just testing

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Tom Lane
Frank Bax <[EMAIL PROTECTED]> writes: > Kevin Duffy wrote: >> ERROR: function regexp_string_to_array(text, text) does not exist > Are you running 8.3? Also, it's regexp_split_to_array ... regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: Just testing the regexp_string_to_array This SQL select description, regexp_string_to_array(description::text , E'\\s+' ) as optdesc, securitytype from xx where type = 'B' order by 1 produced this error: ERROR: function regexp_string_to_array(text, text) does n

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Kevin Duffy
EMAIL PROTECTED] Sent: Friday, September 05, 2008 4:47 PM To: Kevin Duffy Subject: Re: [SQL] variables with SELECT statement 2008/9/5, Kevin Duffy <[EMAIL PROTECTED]>: > OK that is a syntax I have never seen. But correct we are getting > close. > > Noticed that string_to_array does no

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: Noticed that string_to_array does not handle double spaces very well. If there are double space between the tokens, there is "" (empty string) in the array returned. Not exactly what I expected. Try regexp_replace http://www.postgresql.org/docs/8.3/interactive/functions-st

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Kevin Duffy
al Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Bax Sent: Friday, September 05, 2008 4:07 PM Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] variables with SELECT statement Kevin Duffy wrote: > Within my table there is a field DESCRIPTION that I would like to

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: Within my table there is a field DESCRIPTION that I would like to parse and split out into other fields. Within DESCRIPTION there are spaces that separate the data items. String_to_array(description, ‘ ‘) does the job very well. I need something like this to work.

[SQL] variables with SELECT statement

2008-09-05 Thread Kevin Duffy
Hello All: I have a simple issue. Within my table there is a field DESCRIPTION that I would like to parse and split out into other fields. Within DESCRIPTION there are spaces that separate the data items. String_to_array(description, ' ') does the job very well. I need something like

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] Variables in PSQL

2002-07-09 Thread Roger Mathis
Hi 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; Is there a posibility

Re: [SQL] Variables.

2001-10-17 Thread Josh Berkus
t for a variety of variable types and constructions is available in FUNCTIONS. PL/pgSQL, PL/TCL, PL/Perl ... take your pick. For the raw command-line SQL, variables, constants, and other procedural language elements are not appropriate. This is best done in procedures, functions, and middleware. Of c

[SQL] Variables.

2001-10-16 Thread Aasmund Midttun Godal
I would really like a feature :) I do not know whether it is part of the SQL standard. Variables... e.g. CREATE VARIABLE foobar INTEGER DEFAULT 1 NOT NULL; SELECT * FROM thebar WHERE id = foobar; CREATE TEMPORARY VARIABLE... CREATE CONSTANT Basically all the functionality from the tabl

Re: [GENERAL] Re: [SQL] variables in SQL??

2000-08-18 Thread Craig Johannsen
You can create a running total provided that you have a unique sequentially increasing (or decreasing) ID for each row. See the following example: create table tran(id int primary key, price dec(8,2)); insert into tran values(1,5.00); insert into tran values(2,4.00); insert into tran values(3,10

Re: [SQL] variables in SQL??

2000-08-16 Thread DalTech - CTE
> what im trying to do is have a Sum of a colum.. as it goes forwards I don't think this is what you want, but I suppose it might help Table= simple +--+--+- --+ | Field | Type

Re: [SQL] variables in SQL??

2000-08-16 Thread Volker Paul
> what im trying to do is have a Sum of a colum.. as it goes forwards with the > cursor.. > like so: > > Price|Sum > 5|5 > 4|9 > 10|19 > 2|21 > 7|28 I think what you mean is called running sum, I had the same problem before, and I found no other solution than creating a column for it, and calcul

[SQL] variables in SQL??

2000-08-16 Thread Francisco Hernandez
anyone know if SQL has variables? what im trying to do is have a Sum of a colum.. as it goes forwards with the cursor.. like so: Price|Sum 5|5 4|9 10|19 2|21 7|28 i can do it in the accessing language.. like PHP, Python, Perl etc.. but i wanted to know if the actuall DB could do it? any ideas?