[SQL] Set binary column dependent on cumulative value of integer column

2006-12-01 Thread Markus Juenemann
Hi I've got a bit of a tricky (or me!) problem. The example below is completely ficticious but describes my real problem in a way which might be easier to understand. Imagine your table contains CREATE TABLE passenger_queue ( id serial NOT NULL, name character varying(40) NOT NULL,

Re: [SQL] set return function is returning a single record,

2006-04-28 Thread Ross Johnson
On Fri, 2006-04-28 at 12:56 +0200, A. Kretschmer wrote: > am 28.04.2006, um 16:14:10 +0530 mailte Penchalaiah P. folgendes: > > 4) The following is the function that retrieves the records from pss : > > > > CREATE or replace FUNCTION ftoc9() RETURNS setof structrankmaster2 > > LANGUAGE 'plpgsq

Re: [SQL] set return function is returning a single record, multiple

2006-04-28 Thread Alexis Paul Bertolini
CREATE or replace FUNCTION ftoc9() RETURNS setof structrankmaster2 LANGUAGE 'plpgsql' AS' DECLARE rowdata pss%rowtype; BEGIN for i in 1..3 loop select * into rowdata from pss ; return next rowdata ; end loop; return; end'; The query should be outside the loop, otherwise you are re

Re: [SQL] set return function is returning a single record, multiple times,how can i get all the records in the table( description inside )

2006-04-28 Thread A. Kretschmer
am 28.04.2006, um 16:14:10 +0530 mailte Penchalaiah P. folgendes: > 4) The following is the function that retrieves the records from pss : > > CREATE or replace FUNCTION ftoc9() RETURNS setof structrankmaster2 > LANGUAGE 'plpgsql' > > AS' DECLARE > rowdata pss%rowtype; > BEGIN for i in 1..

[SQL] set return function is returning a single record, multiple times,how can i get all the records in the table( description inside )

2006-04-28 Thread Penchalaiah P.
Hi   Please spare some time to provide a solution for the described problem :   I am using set returning functions to return all the records from a table named  pss , But what I am getting is the first record is returned as many  times , the number of records present in the rank_mas

Re: [SQL] Set generating functions and subqueries

2006-03-13 Thread Tom Lane
Markus Schaber <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> The fact that the other form is even allowed is more of a holdover from >> PostQUEL than something we have consciously decided is a good idea. >> (IMHO it's actually a fairly *bad* idea, because it does not work nicely >> when there's

Re: [SQL] Set generating functions and subqueries

2006-03-13 Thread Markus Schaber
Hi, Tom, Tom Lane wrote: > The behavior of the subquery expression is dictated by the SQL spec: > > 1) If the cardinality of a or a is > greater than 1, then an exception condition is raised: cardinal- > ity violation. That's interesting to know, and it seems

Re: [SQL] Set generating functions and subqueries

2006-03-10 Thread Tom Lane
Markus Schaber <[EMAIL PROTECTED]> writes: > postgres=# select (select generate_series(1,2)),'othercol'; > ERROR: more than one row returned by a subquery used as an expression > So it seems that set-returning functions "blow up" the resultset by > duplicating rows - so why is this not allowed fo

[SQL] Set generating functions and subqueries

2006-03-10 Thread Markus Schaber
Hello, Today, I stumbled across the following: postgres=# select generate_series(1,2),'othercol'; generate_series | ?column? -+-- 1 | othercol 2 | othercol (2 rows) postgres=# select (select generate_series(1,2)),'othercol'; ERROR: more tha

Re: [SQL] Set Membership operator -- test group membership

2005-06-19 Thread Oleg Bartunov
Look contrib/intarray On Tue, 14 Jun 2005, Sophie Yang wrote: Say I have a table tbl1 with two columns: tbl1(a integer, b integer, c integer) I want to select the rows in which a and b are members of a list of integer pairs. The SQL in my mind is something like: select * from tbl1 where (a,

[SQL] Set Membership operator -- test group membership

2005-06-18 Thread Sophie Yang
Say I have a table tbl1 with two columns: tbl1(a integer, b integer, c integer) I want to select the rows in which a and b are members of a list of integer pairs. The SQL in my mind is something like: select * from tbl1 where (a, b) in ((1, 20), (2, 30), (3, 50)); I know the SQL above does n

Re: [SQL] Set Returning Function problem

2004-12-06 Thread Tom Lane
Alvaro Nunes Melo <[EMAIL PROTECTED]> writes: > I noticed what i think is a weird behaviour with SRFs. When I use them > in a SELECT clause, and the SRF returns no rows, the query returns no > rows too, when I think it should return an a null column. Why would you think that? The behavior is exac

[SQL] Set Returning Function problem

2004-12-06 Thread Alvaro Nunes Melo
Hi, I noticed what i think is a weird behaviour with SRFs. When I use them in a SELECT clause, and the SRF returns no rows, the query returns no rows too, when I think it should return an a null column. I'm posting an example below: test=> CREATE TABLE foo (cod SERIAL, bar TEXT); NOTICE: CREAT

Re: [SQL] SET AUTOCOMMIT TO OFF

2004-12-02 Thread Richard Huxton
sad wrote: On Wednesday 01 December 2004 18:42, Tom Lane wrote: Christoph Haller <[EMAIL PROTECTED]> writes: Please, could someone point me to the right list or tell me how to do a "SET AUTOCOMMIT TO OFF" within libpq. libpq does not have any support for that. Does this mean libpq calls always unc

Re: [SQL] SET AUTOCOMMIT TO OFF

2004-12-01 Thread sad
On Wednesday 01 December 2004 18:42, Tom Lane wrote: > Christoph Haller <[EMAIL PROTECTED]> writes: > > Please, could someone point me to the right list > > or tell me how to do a "SET AUTOCOMMIT TO OFF" within libpq. > > libpq does not have any support for that. Does this mean libpq calls always

Re: [SQL] SET AUTOCOMMIT TO OFF

2004-12-01 Thread Tom Lane
Christoph Haller <[EMAIL PROTECTED]> writes: > Please, could someone point me to the right list > or tell me how to do a "SET AUTOCOMMIT TO OFF" within libpq. libpq does not have any support for that. regards, tom lane ---(end of broadcast)--

[SQL] SET AUTOCOMMIT TO OFF

2004-12-01 Thread Christoph Haller
I cannot find the autocommit-off-switch within the libpq interface. TIA Regards, Christoph BTW In ./postgresql-7.4.5/doc/html/ecpg-commands.html there is still a line saying This mode can be explicitly turned off using EXEC SQL SET AUTOCOMMIT TO OFF. ---(end of broadcast

Re: [ADMIN] [SQL] \set

2004-05-12 Thread Jie Liang
Thank you, Tom. Jie -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 4:06 PM To: Jie Liang Cc: Christian Kratzer; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [ADMIN] [SQL] \set "Jie Liang" <[EMAIL PROTECTED]> writes: &g

Re: [ADMIN] [SQL] \set

2004-05-12 Thread Tom Lane
"Jie Liang" <[EMAIL PROTECTED]> writes: > You will see AAA associate with 'whatever', it's an internal variable, > but how could I use it in my SQL query? regression=# \set AAA 'whatever' regression=# select :AAA; ERROR: column "whatever" does not exist regression=# \set AAA '\'whatever\'' regres

Re: [SQL] \set

2004-05-12 Thread Jie Liang
able, but how could I use it in my SQL query? Thanks anyway. Jie Liang -Original Message- From: Christian Kratzer [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 3:13 AM To: Jie Liang Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [SQL] \set Hi, On Tue, 11 May 2004, J

[SQL] \set

2004-05-11 Thread Jie Liang
Hi, How to use an internal variable? Original question was how to set a variable in postgresql? If I want to set a variable like start_date='2004-05-10'; How could I use it in my SQL statement? E.g. Db> set start_date '2004-05-10' Db> select start_date as 'start date'; It's not executable! Than

[SQL] SET idiom in insert statement

2004-04-14 Thread Kenneth Gonsalves
hi, does any version of postgresql support the 'SET' idiom in an insert statement? Need this to generate an insert statement from a python dictionary -- regards kg -- http://www.ootygolfclub.org ---(end of broadcast)--- TIP 6: Have you searched ou

Re: [SQL] SET database TO ...?

2003-09-15 Thread Tom Lane
ow <[EMAIL PROTECTED]> writes: > --- Achilleus Mantzios <[EMAIL PROTECTED]> wrote: >> dynacom=# \c bab >> You are now connected to database bab. > I'm actually looking for a way to set database from a *script*, not psql > console, if this is possible (similar to "SET search_path TO whatever;"). I

Re: [SQL] SET database TO ...?

2003-09-15 Thread ow
--- Achilleus Mantzios <[EMAIL PROTECTED]> wrote: [...] > dynacom=# \c bab > You are now connected to database bab. > bab=# I'm actually looking for a way to set database from a *script*, not psql console, if this is possible (similar to "SET search_path TO whatever;"). Any ideas? Thanks

Re: [SQL] SET database TO ...?

2003-09-15 Thread A.Bhuvaneswaran
> Suppose, one server/postmaster is running several databases. Is there > something like "SET database TO whatever" (and I mean *database* not > schema). I need this to ensure that a script runs only against db for > which it was desinged. You can use PG* environment variables if you wish to write

Re: [SQL] SET database TO ...?

2003-09-15 Thread Achilleus Mantzios
On Mon, 15 Sep 2003, ow wrote: > Hi, > > Suppose, one server/postmaster is running several databases. Is there something > like "SET database TO whatever" (and I mean *database* not schema). I need this > to ensure that a script runs only against db for which it was desinged. [EMAIL PROTECTED] ~

[SQL] SET database TO ...?

2003-09-15 Thread ow
Hi, Suppose, one server/postmaster is running several databases. Is there something like "SET database TO whatever" (and I mean *database* not schema). I need this to ensure that a script runs only against db for which it was desinged. Thanks __ Do you Yahoo

Re: [SQL] set decimal point in SQL

2003-06-18 Thread Jeff Eckermann
--- Rodger Donaldson <[EMAIL PROTECTED]> wrote: > On Mon, Jun 16, 2003 at 05:02:34PM -0500, Bu, Ning > wrote: > > > I have a field set up as money and I try to > calculate some number > > and put in this field, but the number will be 6 > demical point and I > > want to cut it to only 2-4 decimal p

Re: [SQL] set decimal point in SQL

2003-06-18 Thread Rodger Donaldson
On Mon, Jun 16, 2003 at 05:02:34PM -0500, Bu, Ning wrote: > I have a field set up as money and I try to calculate some number > and put in this field, but the number will be 6 demical point and I > want to cut it to only 2-4 decimal point, how can I do it? Thanks round(); eg select round(foo, 2

[SQL] set decimal point in SQL

2003-06-18 Thread Bu, Ning
    I have a field set up as money and I try to calculate some number and put in this field, but the number will be 6 demical point and I want to cut it to only 2-4 decimal point, how can I do it? Thanks <>

Re: [SQL] SET TIMEOUT equivalent / was: Lock timeout detection

2003-02-07 Thread Tomasz Myrta
Christoph Haller wrote: Sorry to bother again with my question. Is it too stupid or trivial to this list? Should I send it to NOVICE? Regards, Christoph There are no stupid questions, there are only stupid answers ;-) Anyway - try to not create more threads for the same subject if possible. Re

[SQL] SET TIMEOUT equivalent / was: Lock timeout detection

2003-02-07 Thread Christoph Haller
> > > > > > > T1 (within psql): > > > BEGIN; DELETE FROM ; > > > DELETE n > > > > > > T2 (within psql): > > > BEGIN; DELETE FROM ; > > > > > > > ... > > > >I don't think there is a deadlock in the example > > given above. If I'm not mistaken a deadlock occurs if > > both transactions are wai

Re: [SQL] SET DEFAULT

2002-11-13 Thread Achilleus Mantzios
On Wed, 13 Nov 2002, Archibald Zimonyi wrote: > > Hi everyone, > > I have a problem with adding a column to an existing table. I want to add > a column named modified which is of datatype TIMESTAMP and has a DEFAULT > CURRENT_TIMESTAMP as it's initial value. I cannot do this with ALTER > TABLE, it

[SQL] SET DEFAULT

2002-11-13 Thread Archibald Zimonyi
Hi everyone, I have a problem with adding a column to an existing table. I want to add a column named modified which is of datatype TIMESTAMP and has a DEFAULT CURRENT_TIMESTAMP as it's initial value. I cannot do this with ALTER TABLE, it tells me to user ALTER TABLE SET DEFAULT instead but I can

Re: [SQL] set difference

2002-10-16 Thread Tom Lane
=?iso-8859-1?Q?Domoszlai_L=E1szl=F3?= <[EMAIL PROTECTED]> writes: > So, do you think a DIFFERENCE or EXCEPT SYMMETRIC clause will be reasonable > feauture for postgresql? I doubt it; haven't heard a request for it before, and AFAICS there's no such thing in the SQL spec...

Re: [SQL] set difference

2002-10-16 Thread Domoszlai László
Tom Lane wrote: > > I would like to make symmetrical(set) difference in a query. > > But the simpliest way I could find is > > > select id from a > > except > > select id from b > > union > > select id from b > > except > > select id from a > > > Is there any better solution for this problem?

Re: [SQL] set difference

2002-10-15 Thread Tom Lane
=?iso-8859-1?Q?Domoszlai_L=E1szl=F3?= <[EMAIL PROTECTED]> writes: > I would like to make symmetrical(set) difference in a query. > But the simpliest way I could find is > select id from a > except > select id from b > union > select id from b > except > select id from a > Is there any better

[SQL] set difference

2002-10-15 Thread Domoszlai László
Hello, I would like to make symmetrical(set) difference in a query. But the simpliest way I could find is select id from a except select id from b union select id from b except select id from a Is there any better solution for this problem? Thanks Laca ---(end of

[SQL] set DateStyle to 'SQL'

2002-07-26 Thread Elielson Fontanezi
Hi folks! There are a buch of varibles like DateStyle. I am interested to set them all in script shell. I've tried in postgresql.conf, but I could not. I've tried in shell environment, but it did not work. So, how can I do that? ..

[SQL] \set variant for use in regular sql commands

2001-08-15 Thread Jeff Barrett
I need to use the \set command in regular sql (I am running postgres queries through php and it does not seem to support the \ commands in general). How can I set a variable with regular sql? I want to be able to do the following: \set testvar '1,2,3,4,5' \set testvar '6,7,8,':testvar Which is

Re: [SQL] set datestyle to European PROBLEM

2001-06-22 Thread Roelof Sondaar
Hello Alessandro, The manual I have says the following about Date/Time Styles: - 4 styles (ISO-8601, SQL, Postgres, German) The one which resembles your layout is German. I looked it up in Bruce Momjians book. Best regards, Roelof Alessandro Rossi schreef: > > I have the defaul installation o

Re: [SQL] set datestyle to European PROBLEM

2001-06-20 Thread George Moga
Alessandro Rossi wrote: > I have the defaul installation of postgres 7.0.3 and on another machine > 7.1.2 on redhat 7.1 > > I cannont get the date in correct form: . > Is this a bug ? > > I think i should get dd-mm-yyy date format and not -mm-dd > > Is postgres using ISO date format as

[SQL] set datestyle to European PROBLEM

2001-06-20 Thread Alessandro Rossi
I have the defaul installation of postgres 7.0.3 and on another machine 7.1.2 on redhat 7.1 I cannont get the date in correct form: dbme=# select data_ar from equipment limit 5; data_ar 2001-11-05 2001-05-17 2001-05-28 2001-05-28 2001-05-22 (5 rows) then: dbme=# set dat

[SQL] Set Datestyle

2001-05-22 Thread Tubagus Nizomi
Hallo, i have postgres 7.1 in Radhat 6.5 the Datestype default is ISO format where is change default Datestyle to Postgres format ?? i used Set Datestyle to postgres in plsql test#>select now() now 2001-05-21 09:55:36+07 test#>set datestyle to postgres; S

[SQL] SET SEQSCAN TO OFF - error

2001-04-26 Thread Hans-Jürgen Schönig
I have the command below like it is described in the documentation (http://www.archonet.com/pgdocs/force-index.html) but it doens't work. SET SEQSCAN TO OFF; ERROR: 'seqscan' is not a valid option name Does anybody know why? Hans ---(end of broadcast)

Re: [SQL] SET SEQSCAN TO OFF - error

2001-04-26 Thread Bruce Momjian
> I have the command below like it is described in the documentation > (http://www.archonet.com/pgdocs/force-index.html) but it doens't work. > > SET SEQSCAN TO OFF; > ERROR: 'seqscan' is not a valid option name > > > Does anybody know why? > Try: test=> set enable_seqscan to off;

Re: [SQL] SET SEQSCAN TO OFF - error

2001-04-26 Thread Jeff Hoffmann
Hans-Jürgen Schönig wrote: > > I have the command below like it is described in the documentation > (http://www.archonet.com/pgdocs/force-index.html) but it doens't work. > > SET SEQSCAN TO OFF; > ERROR: 'seqscan' is not a valid option name > > Does anybody know why? > because the documentat

Re: [SQL] SET SEQSCAN TO OFF - error

2001-04-26 Thread Peter Eisentraut
Hans-Jürgen Schönig writes: > I have the command below like it is described in the documentation > (http://www.archonet.com/pgdocs/force-index.html) but it doens't work. > > SET SEQSCAN TO OFF; > ERROR: 'seqscan' is not a valid option name > > Does anybody know why? Because 'seqscan' is not a v

[SQL] set digest

2000-10-12 Thread karasiov
set digest