Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread David G. Johnston
For what its worth: DO $$ DECLARE vresult text; begin EXECUTE $qry$ WITH cols (c) AS ( VALUES ('col1'),('col2') ) SELECT string_agg('a.' || cols.c, ',') FROM cols WHERE 'foo' = $1 $qry$ USING 'foo' INTO vresult; RAISE NOTICE '%', vresult; END; $$; I still haven't actually figured out what

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
1 - I added some new notes. 2 - That code I know and works fine. I used it in slightly different contexts in other projects Here it is a case . A table with two columns , data type is irrelevant I have a need in which I may get a.col1,a.col2 and other variations Point is yes I could build a

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread David G. Johnston
Please don't top-post - it makes following the thread a lot harder. On Mon, Nov 21, 2016 at 4:15 PM, Armand Pirvu (home) wrote: > Played with unnest but not much luck > If you want help you will need to show your work - ideally with examples that can execute with meaningful data on an empty da

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
Played with unnest but not much luck NOTICE: {item_id,show_id} NOTICE: item_id It takes only the first array element in consideration Ug On Nov 21, 2016, at 5:02 PM, Armand Pirvu (home) wrote: > My bad on the back tick. No idea why it turned that way > > OK got that David. > > Th

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
My bad on the back tick. No idea why it turned that way OK got that David. The idea is that I have the pk columns in an array which I would like to manipulate from the array itself rather than running same query variations multiple times For example I get in foo {item_id,show_id} And from h

Re: [GENERAL] variable value in array_to_string

2016-11-21 Thread David G. Johnston
On Mon, Nov 21, 2016 at 3:09 PM, Armand Pirvu (home) wrote: > Hi > > Is there anyway I can pass a variable in the array_to_string function ? > > ​Yes, just like you can pass variables to any other function.​.. > CREATE OR REPLACE FUNCTION test1 () RETURNS void AS $$ > ​​ > DECLARE > foo text; >

[GENERAL] variable value in array_to_string

2016-11-21 Thread Armand Pirvu (home)
Hi Is there anyway I can pass a variable in the array_to_string function ? CREATE OR REPLACE FUNCTION test1 () RETURNS void AS $$ DECLARE foo text; foo1 text; begin execute 'select ARRAY( SELECT d.COLUMN_NAME::text from information_schema.constraint_table_usage c, information_schema.key_co

Re: [GENERAL] Variable not found

2016-01-22 Thread Adrian Klaver
On 01/21/2016 10:48 PM, Sachin Srivastava wrote: Dear Adrian, So, how the effective way to search this because I have around 1300 tables. See Gilles response. From that I gather global variables are not automatically transferred and it is up to you to decide where to put them. Per your origi

Re: Fwd: Re: [GENERAL] Variable not found

2016-01-22 Thread Gilles Darold
Hi, > > On 01/20/2016 07:35 PM, Sachin Srivastava wrote: > > Dear Folks, > > I have a question about global variables in Oracle pl/sql package. > Where > are these variables when package is converted to schema from Oracle to > Postgres through Ora2PG Tool? > Ora2Pg doesn't exp

Re: [GENERAL] Variable not found

2016-01-21 Thread Sachin Srivastava
Dear Adrian, So, how the effective way to search this because I have around 1300 tables. Regards, SS On Thu, Jan 21, 2016 at 8:48 PM, Adrian Klaver wrote: > On 01/20/2016 07:35 PM, Sachin Srivastava wrote: > >> Dear Folks, >> >> I have a question about global variables in Oracle pl/sql package

Re: [GENERAL] Variable not found

2016-01-21 Thread Adrian Klaver
On 01/20/2016 07:35 PM, Sachin Srivastava wrote: Dear Folks, I have a question about global variables in Oracle pl/sql package. Where are these variables when package is converted to schema from Oracle to Postgres through Ora2PG Tool? For example, package Best guess it is stored in a table i

[GENERAL] Variable not found

2016-01-20 Thread Sachin Srivastava
Dear Folks, I have a question about global variables in Oracle pl/sql package. Where are these variables when package is converted to schema from Oracle to Postgres through Ora2PG Tool? For example, package

Re: [GENERAL] variable not found in subplan target list

2011-11-02 Thread Tom Lane
Roger Niederland writes: > I stripped enough out of the database that it is only good for a test > case. Here is a public url for getting at the database backup: I've committed a fix for this: http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=e4e60e7b6125e77f679861ebf43cc6b9f9db

[GENERAL] variable not found in subplan target list

2011-11-02 Thread Roger Niederland
Hello, I stripped down the original query to what is below. I am not saying that the query below is useful except to show an error I am getting in Postgresql 9.1.1 on both SL6.1 (64 bit) and Windows 2008 server 9.1.1 (32-bit and 64-bit). The error I am getting is: ERROR: variable not found

Re: [GENERAL] variable not found in subplan target list

2011-11-01 Thread Roger Niederland
On 11/1/2011 8:30 PM, Tom Lane wrote: Roger Niederland writes: I extracted the tables from the database which generates the error above I eliminated most of the columns such that this query still exhibits this behavior to reduce the file size. I have a zipped file from windows postgresql 9.1

Re: [GENERAL] variable not found in subplan target list

2011-11-01 Thread Tom Lane
Roger Niederland writes: > I extracted the tables from the database which generates the error above > I eliminated most of the columns such that this query still exhibits > this behavior to reduce > the file size. I have a zipped file from windows postgresql 9.1.1 > (32-bit) which is about 1.5

Re: [GENERAL] variable not found in subplan target list

2011-11-01 Thread Roger Niederland
On 11/1/2011 3:54 PM, Roger Niederland wrote: Hello, I stripped down the original query to what is below. I am not saying that the query below is useful except to show an error I am getting in Postgresql 9.1.1 on both SL6.1 (64 bit) and Windows 2008 server 9.1.1 (32-bit and 64-bit). The e

Re: [GENERAL] variable not found in subplan target list

2011-11-01 Thread Tom Lane
Roger Niederland writes: > I stripped down the original query to what is below. I am not saying > that the query below > is useful except to show an error I am getting in Postgresql 9.1.1 on > both SL6.1 (64 bit) and > Windows 2008 server 9.1.1 (32-bit and 64-bit). The error I am getting is:

[GENERAL] variable not found in subplan target list

2011-11-01 Thread Roger Niederland
Hello, I stripped down the original query to what is below. I am not saying that the query below is useful except to show an error I am getting in Postgresql 9.1.1 on both SL6.1 (64 bit) and Windows 2008 server 9.1.1 (32-bit and 64-bit). The error I am getting is: ERROR: variable not found

Re: [GENERAL] Variable column name

2011-09-02 Thread Scott Ribe
On Sep 2, 2011, at 2:31 PM, Bob Pawley wrote: > It seems to work when I hard code the column name and array point, so I was > hoping to make it work through a loop using variables for column and array > point. > > Does this make sense?? Building queries this way is tedious & error prone; that'

Re: [GENERAL] Variable column name

2011-09-02 Thread Bob Pawley
-Original Message- From: Bill Moran Sent: Friday, September 02, 2011 10:53 AM To: Bob Pawley Cc: Postgresql Subject: Re: [GENERAL] Variable column name In response to "Bob Pawley" : I am getting an error -- "column "1" does not exist" Select

Re: [GENERAL] Variable column name

2011-09-02 Thread Bill Moran
In response to "Bob Pawley" : > > I am getting an error -- "column "1" does not exist" > Select "1" into column ; Where are you selecting "1" from? This query has no FROM clause, so of course the column doesn't exist. The previous query, "SELECT 2 INTO point_array" is going to put the i

Re: [GENERAL] Variable column name

2011-09-02 Thread Bob Pawley
-Original Message- From: Raymond O'Donnell Sent: Friday, September 02, 2011 10:38 AM To: Bob Pawley Cc: Bill Moran ; Postgresql Subject: Re: [GENERAL] Variable column name On 02/09/2011 18:33, Bob Pawley wrote: -Original Message- From: Bill Moran Sent: Thu

Re: [GENERAL] Variable column name

2011-09-02 Thread Raymond O'Donnell
On 02/09/2011 18:33, Bob Pawley wrote: > > > -Original Message- >> From: Bill Moran > Sent: Thursday, September 01, 2011 8:19 AM > To: Bob Pawley > Cc: Postgresql > Subject: Re: [GENERAL] Variable column name > > http://www.postgresql.org/docs/9

Re: [GENERAL] Variable column name

2011-09-02 Thread Bob Pawley
-Original Message- From: Bill Moran Sent: Thursday, September 01, 2011 8:19 AM To: Bob Pawley Cc: Postgresql Subject: Re: [GENERAL] Variable column name http://www.postgresql.org/docs/9.0/static/plpgsql-statements.html Section 39.5.4 If you're not familiar with plpgsql at all

Re: [GENERAL] Variable column name

2011-09-01 Thread Bill Moran
In response to "Bob Pawley" : > > From: Bill Moran > > In response to "Bob Pawley" : > > > > I want to add information to multiple columns (20 - 40) by employing a > > loop. Each pass of the loop will populate one column with an array. > > > > I have tried and I have read that variables can not

Re: [GENERAL] Variable column name

2011-09-01 Thread Adrian Klaver
On Thursday, September 01, 2011 8:04:49 am Bob Pawley wrote: > -Original Message- > From: Bill Moran > Sent: Thursday, September 01, 2011 7:59 AM > To: Bob Pawley > Cc: Postgresql > Subject: Re: [GENERAL] Variable column name > > In response to "Bob Pawley&quo

Re: [GENERAL] Variable column name

2011-09-01 Thread Scott Ribe
On Sep 1, 2011, at 9:04 AM, Bob Pawley wrote: > Would it be possible for you to point me to an example?? The EXECUTE command is what you want. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- Sent via pgsql-general mailing list (pgsql-general@

Re: [GENERAL] Variable column name

2011-09-01 Thread Bob Pawley
-Original Message- From: Bill Moran Sent: Thursday, September 01, 2011 7:59 AM To: Bob Pawley Cc: Postgresql Subject: Re: [GENERAL] Variable column name In response to "Bob Pawley" : I want to add information to multiple columns (20 – 40) by employing a loop. Each pass o

Re: [GENERAL] Variable column name

2011-09-01 Thread Bill Moran
In response to "Bob Pawley" : > > I want to add information to multiple columns (20 – 40) by employing a loop. > Each pass of the loop will populate one column with an array. > > I have tried and I have read that variables can not be used to control column > names. > > Is there a means of wor

[GENERAL] Variable column name

2011-09-01 Thread Bob Pawley
Hi I want to add information to multiple columns (20 – 40) by employing a loop. Each pass of the loop will populate one column with an array. I have tried and I have read that variables can not be used to control column names. Is there a means of working around this restriction other than cre

Re: [GENERAL] variable name in plpgsql

2010-09-08 Thread Darren Duncan
zhong ming wu wrote: It seems that one cannot use the variable name that is the same as the column name of a relation like in the following function -- create or replace function bla() returns void language plpgsql as $$ declare email varchar; begin select email into email fr

Re: [GENERAL] variable name in plpgsql

2010-09-08 Thread Adrian Klaver
On Wednesday 08 September 2010 5:23:20 pm zhong ming wu wrote: > It seems that one cannot use the variable name that is the same as the > column name of a relation like in the following function > > -- > create or replace function bla() returns void language plpgsql as $$ > declare > emai

[GENERAL] variable name in plpgsql

2010-09-08 Thread zhong ming wu
It seems that one cannot use the variable name that is the same as the column name of a relation like in the following function -- create or replace function bla() returns void language plpgsql as $$ declare email varchar; begin select email into email from pass where id=1;

Re: [GENERAL] "--variable foo=bar" vs. "\set foo quux" in ~/.psqlrc

2010-05-15 Thread Julian Mehnle
Tom Lane wrote: > Julian Mehnle writes: > > Can anyone confirm that --variable command-line options are evaluated > > before .psqlrc is read and executed? If so, does anyone know the > > rationale for that? It seems counterintuitive to me, as it makes > > overriding variables from the command-l

Re: [GENERAL] "--variable foo=bar" vs. "\set foo quux" in ~/.psqlrc

2010-05-14 Thread Tom Lane
Julian Mehnle writes: > Can anyone confirm that --variable command-line options are evaluated > before .psqlrc is read and executed? If so, does anyone know the > rationale for that? It seems counterintuitive to me, as it makes > overriding variables from the command-line impossible. Seems enti

[GENERAL] "--variable foo=bar" vs. "\set foo quux" in ~/.psqlrc

2010-05-14 Thread Julian Mehnle
Hi all, I'm trying to add the database host name to my psql prompts. The obvious solution is to add %M or %m to the PROMPT{1,2} variables in ~/.psqlrc. However I have to work with a few databases that can be reached only through SSH tunnels, for which I use aliases like this: alias dbfoo='ssh

Re: [GENERAL] variable

2009-03-19 Thread Adrian Klaver
- glext...@gmail.com wrote: > Hi-- > > > I'm having a bit of trouble with the EXECUTE statement for the > following function. > > > I saw a lot of traffic re. plpgsql & variable substitution for 8.4, > but I'm convinced this is something simple (newbie): > > > > CREATE FUNCTION topm

[GENERAL] variable

2009-03-19 Thread glextact
Hi-- I'm having a bit of trouble with the EXECUTE statement for the following function. I saw a lot of traffic re. plpgsql & variable substitution for 8.4, but I'm convinced this is something simple (newbie): CREATE FUNCTION topmixtot (int[]) RETURNS SETOF record AS $$ DECLARE gids ALIAS

[GENERAL] variable table names in trigger functions

2008-01-31 Thread Hugo
Hi all, I've written a simple trigger function to store the old row in another table to log the data: CREATE FUNCTION logusers() RETURNS trigger AS $$ BEGIN INSERT INTO log.users SELECT FROM data.users WHERE id=OLD.id; RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-17 Thread Gregory Stark
"Reg Me Please" <[EMAIL PROTECTED]> writes: > Of course, in my opinion at least, there's no real reason for the above > syntax limitation, as the sematics is not. Is not what? Is not sensible? > create or replace function f_limoff_1( l int, o int ) > returns setof atable as $$ > select * from at

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-17 Thread Gregory Stark
"Tom Lane" <[EMAIL PROTECTED]> writes: > Sam Mason <[EMAIL PROTECTED]> writes: >> In relational algebra terms, try thinking about what would happen if you >> did something like: > >> SELECT * FROM foo LIMIT val; > >> Where the table foo has more than one row (and val had different values >> for

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-16 Thread Reg Me Please
Il Thursday 15 November 2007 14:09:16 Trevor Talbot ha scritto: > On 11/15/07, Reg Me Please <[EMAIL PROTECTED]> wrote: > > In any case, what'd be the benefit for not allowing "variables" as LIMIT > > and OFFSET argument? > > When you can fully describe the semantics of your example, you'll > proba

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-16 Thread Sam Mason
On Fri, Nov 16, 2007 at 01:38:30AM -0500, Tom Lane wrote: > Sam Mason <[EMAIL PROTECTED]> writes: > > wow, that's kind of fun isn't it. I only thought you could put a > > constant in there. Maybe I should have had a look in the grammar/tested > > it first! > > IIRC, it used to be restricted to a

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-16 Thread Richard Huxton
Reg Me Please wrote: Il Thursday 15 November 2007 20:28:17 hai scritto: Reg Me Please wrote: In my opinion I would say it's more a problem with the syntax checker that with the planner ("semantics" in my lingo). But I could be wrong. Well, what it won't let you do is have a subquery in the LIM

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-16 Thread Tom Lane
Sam Mason <[EMAIL PROTECTED]> writes: > wow, that's kind of fun isn't it. I only thought you could put a > constant in there. Maybe I should have had a look in the grammar/tested > it first! IIRC, it used to be restricted to a constant, a few revisions back. In current releases the only restrict

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-16 Thread Trevor Talbot
On 11/16/07, Reg Me Please <[EMAIL PROTECTED]> wrote: > Il Friday 16 November 2007 08:33:14 Tom Lane ha scritto: > > Let me try to explain one more time. You propose allowing > > > > select ... from > > table1 join table2 on table1.x = table2.y > > limit table1.z > > > > Now

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-16 Thread Reg Me Please
Il Friday 16 November 2007 08:33:14 Tom Lane ha scritto: > Reg Me Please <[EMAIL PROTECTED]> writes: > >> The OP's complaint is that we don't allow a variable of the query's own > >> level, but AFAICT he's still not grasped the point that that leads to an > >> indeterminate limit value ... > > > >

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Tom Lane
Reg Me Please <[EMAIL PROTECTED]> writes: >> The OP's complaint is that we don't allow a variable of the query's own >> level, but AFAICT he's still not grasped the point that that leads to an >> indeterminate limit value ... > So it works, but it's not serious enough to be unlocked. You really d

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Tom Lane
Sam Mason <[EMAIL PROTECTED]> writes: > On Fri, Nov 16, 2007 at 01:38:30AM -0500, Tom Lane wrote: >> IIRC, it used to be restricted to a constant, a few revisions back. > I'm amazed it supports anything more than a constant. The values are > almost always going to come from external code, so ther

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Reg Me Please
Il Friday 16 November 2007 07:38:30 Tom Lane ha scritto: > IIRC, it used to be restricted to a constant, a few revisions back. > In current releases the only restriction that stems from laziness is > not allowing a sub-select. (If anyone were to put forward a serious > use-case, we'd probably go f

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Reg Me Please
Il Thursday 15 November 2007 23:08:10 Richard Huxton ha scritto: > Reg Me Please wrote: > > Il Thursday 15 November 2007 20:28:17 hai scritto: > >> Reg Me Please wrote: > >>> In my opinion I would say it's more a problem with the syntax checker > >>> that with the planner ("semantics" in my lingo).

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Sam Mason
On Thu, Nov 15, 2007 at 07:28:17PM +, Richard Huxton wrote: > Reg Me Please wrote: > >As Sam says I should be able to "put an IMMUTABLE expression into > >a LIMIT or OFFSET". And under some circumstances (SQL function > >body) it's true even with VARIABLE expressions like function call > >argum

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Richard Huxton
Reg Me Please wrote: Sorry but I don't understand. Either the LIMIT and OFFSET are to be definitely CONSTANT or not. They must be constant during the execution of the query. In the SQL function body the LIMIT and the OFFSET *are definitely not* CONSTANT. And the planner can do its job at bes

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Reg Me Please
Sorry but I don't understand. Either the LIMIT and OFFSET are to be definitely CONSTANT or not. In the SQL function body the LIMIT and the OFFSET *are definitely not* CONSTANT. And the planner can do its job at best as usual. As Sam says I should be able to "put an IMMUTABLE expression into a LI

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Reg Me Please
Il Thursday 15 November 2007 20:28:17 hai scritto: > Reg Me Please wrote: > > Sorry but I don't understand. > > > > Either the LIMIT and OFFSET are to be definitely CONSTANT or not. > > They must be constant during the execution of the query. > > > In the SQL function body the LIMIT and the OFFSET

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Sam Mason
On Thu, Nov 15, 2007 at 06:08:20PM +0100, Reg Me Please wrote: > Your remarks make a lot of sense. Of course. good! it's interesting to see how things like this fit together. > But then why allowing the LIMIT and the OFFSET as coming from function > argument evaluations? I believe the query is

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Tom Lane
Sam Mason <[EMAIL PROTECTED]> writes: > In relational algebra terms, try thinking about what would happen if you > did something like: > SELECT * FROM foo LIMIT val; > Where the table foo has more than one row (and val had different values > for each row). Which row would the database use? I

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Sam Mason
On Thu, Nov 15, 2007 at 05:34:43PM +0100, Reg Me Please wrote: > Il Thursday 15 November 2007 14:09:16 Trevor Talbot ha scritto: > > On 11/15/07, Reg Me Please <[EMAIL PROTECTED]> wrote: > > > In any case, what'd be the benefit for not allowing "variables" as LIMIT > > > and OFFSET argument? > > >

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Tom Lane
Sam Mason <[EMAIL PROTECTED]> writes: > On Thu, Nov 15, 2007 at 06:08:20PM +0100, Reg Me Please wrote: >> But then why allowing the LIMIT and the OFFSET as coming from function >> argument evaluations? > I believe the query is planned by ignoring the LIMIT and OFFSET. No, it still knows there wi

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Reg Me Please
Il Thursday 15 November 2007 17:55:42 Sam Mason ha scritto: > On Thu, Nov 15, 2007 at 05:34:43PM +0100, Reg Me Please wrote: > > Il Thursday 15 November 2007 14:09:16 Trevor Talbot ha scritto: > > > On 11/15/07, Reg Me Please <[EMAIL PROTECTED]> wrote: > > > > In any case, what'd be the benefit for

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Reg Me Please
In any case, what'd be the benefit for not allowing "variables" as LIMIT and OFFSET argument? -- Reg me Please ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joinin

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Trevor Talbot
On 11/15/07, Reg Me Please <[EMAIL PROTECTED]> wrote: > In any case, what'd be the benefit for not allowing "variables" as LIMIT and > OFFSET argument? When you can fully describe the semantics of your example, you'll probably be able to answer that question too :) ---(en

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Pavel Stehule
Hello LIMIT has impact on execution plan, so there cannot be variables. Use SRF function and dynamic statements instead. Regards Pavel On 15/11/2007, Reg Me Please <[EMAIL PROTECTED]> wrote: > In any case, what'd be the benefit for not allowing "variables" as LIMIT and > OFFSET argument? > > --

Re: [GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-15 Thread Tom Lane
Reg Me Please <[EMAIL PROTECTED]> writes: > create table limoff( l int, o int ); > insert into limoff values ( 10,2 ); > select a.* from atable a,limoff limit l offset o; I am truly curious what you think the semantics of that ought to be. regards, tom lane --

[GENERAL] Variable LIMIT and OFFSET in SELECTs

2007-11-14 Thread Reg Me Please
Hi all. I'd need to implement a "parametric windowed select" over a table called "atable". The idea is to have a one row table to maintain the LIMIT and the OFFSET for the selects. If I try this: create table limoff( l int, o int ); insert into limoff values ( 10,2 ); select a.* from atable a,lim

Re: [GENERAL] variable in COPY TO variable

2007-10-18 Thread Rob Shepherd
> A case for dynamic > SQL!http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQ > L-STATEMENTS-EXECUTING-DYN > > Yours, > Laurenz Albe > > ---(end of broadcast)--- > TIP 5: don't forget to increase your free space map settings P

Re: [GENERAL] variable in COPY TO variable

2007-10-17 Thread Albe Laurenz
Rob Shepherd wrote: > I'm following the synatx > > COPY TO 'filename' > > .but i'm trying to use a variable as the filename. > [...] > > returns the error > > ERROR: syntax error at or near "$1" at character 21 > QUERY: COPY tt_archive TO $1 > CONTEXT: SQL statement in PL/PgSQL funct

[GENERAL] variable in COPY TO variable

2007-10-16 Thread Rob Shepherd
Dear postgres-users, I'm currently working on a stored procedure, but having an error which seems odd. I'm following the synatx COPY TO 'filename' .but i'm trying to use a variable as the filename. 1 : CREATE OR REPLACE FUNCTION archive() RETURNS void AS 2 : $BODY$DECLARE 3 : ts times

Re: [GENERAL] Variable return type...

2005-10-26 Thread Cristian Prieto
Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Variable return type... On Wed, Oct 26, 2005 at 06:14:23PM -0600, Cristian Prieto wrote: > Hi, I was working in a set of SPs inside PL/pgSQL and I was wonder if I > could return a set of variable types from a function, for example, i

Re: [GENERAL] Variable return type...

2005-10-26 Thread Michael Fuhr
On Wed, Oct 26, 2005 at 06:14:23PM -0600, Cristian Prieto wrote: > Hi, I was working in a set of SPs inside PL/pgSQL and I was wonder if I > could return a set of variable types from a function, for example, in some > time the same function could return a set of tuples with an integer and a > strin

[GENERAL] Variable return type...

2005-10-26 Thread Cristian Prieto
Hi, I was working in a set of SPs inside PL/pgSQL and I was wonder if I could return a set of variable types from a function, for example, in some time the same function could return a set of tuples with an integer and a string, in other times It may return a set of tuples with an integer,

Re: [GENERAL] Variable column name in plpgsql function

2004-12-01 Thread mark
Richard Huxton wrote: George Woodring wrote: Is possible to declare a variable to build the column name Tableid varchar(20) := TG_RELNAME || ''id''; And then use this variable to get the PK value? Tableidvalue int4 := NEW.tableid; No. You can build a dynamic query via EXECUTE, but that can't acces

Re: [GENERAL] Variable column name in plpgsql function

2004-12-01 Thread Richard Huxton
George Woodring wrote: Is possible to declare a variable to build the column name Tableid varchar(20) := TG_RELNAME || ''id''; And then use this variable to get the PK value? Tableidvalue int4 := NEW.tableid; No. You can build a dynamic query via EXECUTE, but that can't access NEW/OLD. -- Richa

[GENERAL] Variable column name in plpgsql function

2004-12-01 Thread George Woodring
I am trying to create a trigger that needs to capture the primary key value out of NEW variable. However the trigger can be called from 2 different tables whose PKs are Table1id Table2id Is possible to declare a variable to build the column name Tableid varchar(20) := TG_RELNAME || ''id''; And

Re: [GENERAL] Variable case database names

2001-08-31 Thread Peter Eisentraut
[EMAIL PROTECTED] writes: > How can i create variable case data bases ? Double quote the database name: psql -c 'create database "MiXeD";' -- Peter Eisentraut [EMAIL PROTECTED] http://funkturm.homeip.net/~peter ---(end of broadcast)---

[GENERAL] Variable case database names

2001-08-31 Thread amprasad
Whenever i create a database with command : psql -h HostName -p PortName -c "create database DATABASENAME " template1 The database is created with small case . How can i create variable case data bases ? regards AMBIKA ---(end of broa

[GENERAL] variable name RESULT in PLPGSQL does not work (PG7.1)

2001-01-10 Thread Mirko Zeibig
Hello everybody, I converted some existing plpgsql-scripts from 7.0.3 to 7.1 (CVS from 2001-01-09) and had problems with a variable RESULT in my script. E.g.: drop function bla(integer); create function bla(integer) returns integer as ' declare RESULT integer; begin

[GENERAL] Variable case database names

2000-01-20 Thread Patrick Welche
List of databases Database | Owner +-- Newnham| prlw1 % psql Newnham psql: connection to database "newnham" failed - FATAL 1: Database "newnham" does not exist in the system catalog. template1=> \c 'Newnham' FATAL 1: Database "newnham" does not exist in the

[GENERAL] Variable as a variable name in PL/pgSQL

1999-02-01 Thread Daniele Orlandi
I'm trying to implement a sort of templates for a user database. I tought of two possibilities. In the first I have a table like this: CREATE TABLE templates ( tplname varchar(32), fieldname varchar(32), value varchar(32) ); Where I specify the value to be assigned to each