Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Vitaly Burovoy
On 2/9/16, Johannes wrote: > Am 09.02.2016 um 00:56 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes wrote: >>> Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: On 2/8/16, Johannes wrote: > increase speed, Speed will be at least the same. In your case either you have to use m

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Johannes
Am 09.02.2016 um 00:56 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: >>> On 2/8/16, Johannes wrote: Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: > Hmm. Could you clarify why you don't want to pass id from the first > query

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Vitaly Burovoy
On 2/9/16, Marc Mamin wrote: > > Hi, > > is there a best practice to share data between two select statements? > > Hi, > I didn't check the whole thread Try it[1]. The thread is not so long (21 letters before yours) and it worth it. > so forgive me if this was already proposed, > but

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread David G. Johnston
On Tue, Feb 9, 2016 at 12:16 PM, Marc Mamin wrote: > > Hi, > > is there a best practice to share data between two select statements? > > Hi, > I didn't check the whole thread so forgive me if this was already proposed, > but maybe you could do something like: > > create temp table

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Marc Mamin
Hi, is there a best practice to share data between two select statements? Hi, I didn't check the whole thread so forgive me if this was already proposed, but maybe you could do something like: create temp table result2 (...) query_1: WITH cte as (select ..), tmp as ( INSERT INTO

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread David G. Johnston
On Tuesday, February 9, 2016, Vitaly Burovoy wrote: > On 2/9/16, Harald Fuchs > wrote: > > Johannes > writes: > > > >>> What the reason to execute all statements which return different > >>> columns at once? > >>> > Saving roundtrips, > >>> > >>> In most cases they are not so big. Getting a

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Vitaly Burovoy
On 2/9/16, Harald Fuchs wrote: > Johannes writes: > >>> What the reason to execute all statements which return different >>> columns at once? >>> Saving roundtrips, >>> >>> In most cases they are not so big. Getting a bunch of duplicated data >>> is wasting you network bandwidth and don't in

Re: [GENERAL] execute same query only one time?

2016-02-09 Thread Harald Fuchs
Johannes writes: >> What the reason to execute all statements which return different >> columns at once? >> >>> Saving roundtrips, >> >> In most cases they are not so big. Getting a bunch of duplicated data >> is wasting you network bandwidth and don't increase speed. > > In my and your example

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes wrote: >>> Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: Hmm. Could you clarify why you don't want to pass id from the first query to the second one: select col1 from t1 where t

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 21:50 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: >>> On 2/8/16, Johannes wrote: Am 08.02.2016 um 20:15 schrieb David G. Johnston: > On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > >> Hi, >> >>>

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Alban Hertroys wrote: > >> On 08 Feb 2016, at 20:05, Johannes wrote: >> >> select id, col1, col2, ... from t0 where id = (select max(id) from t0 >> where col1 = value1 and col2 = value2 and …); >> >> select col1 from t1 where t0_id = (select max(id) from t0 where col1 = >> value1 and c

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: >> On 2/8/16, Johannes wrote: >>> Am 08.02.2016 um 20:15 schrieb David G. Johnston: On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > Hi, > > is there a best practice to share data between two sele

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Alban Hertroys
> On 08 Feb 2016, at 20:05, Johannes wrote: > > select id, col1, col2, ... from t0 where id = (select max(id) from t0 > where col1 = value1 and col2 = value2 and …); > select col1 from t1 where t0_id = (select max(id) from t0 where col1 = > value1 and col2 = value2 and …); select t0.id, t0.co

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 21:33 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> >> Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: >>> On 2/8/16, Adrian Klaver wrote: Based on rough guess of the above, without seeing actual table schemas: select id, t0.col1, t1.col1, col2, ... from

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > > Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: >> On 2/8/16, Adrian Klaver wrote: >>> Based on rough guess of the above, without seeing actual table schemas: >>> >>> select id, t0.col1, t1.col1, col2, ... from t0 JOIN t1 ON t0.id = >>> t1.t0_id where id = (select ma

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 21:17 schrieb Vitaly Burovoy: > On 2/8/16, Johannes wrote: >> Am 08.02.2016 um 20:15 schrieb David G. Johnston: >>> On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: >>> Hi, is there a best practice to share data between two select statements? Imaging fo

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 20:32 schrieb Vitaly Burovoy: > On 2/8/16, Adrian Klaver wrote: >> On 02/08/2016 11:05 AM, Johannes wrote: >>> Imaging following situation: I want to receive two result sets from two >>> tables, referring to a specific id from table t0 AND I try not to query >>> for that specifi

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Am 08.02.2016 um 20:15 schrieb David G. Johnston: >> On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: >> >>> Hi, >>> >>> is there a best practice to share data between two select statements? >>> >>> Imaging following situation: I want to receive two result sets from t

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Am 08.02.2016 um 20:15 schrieb David G. Johnston: > On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > >> Hi, >> >> is there a best practice to share data between two select statements? >> >> Imaging following situation: I want to receive two result sets from two >> tables, referring to a specifi

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
x27;t subscribed to the list. > -Original Message- > From: Johannes > To: pgsql-general@postgresql.org > Sent: Mon, 08 Feb 2016 11:07 > Subject: [GENERAL] execute same query only one time? > > Hi, > > is there a best practice to share data between two select stat

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Adrian Klaver wrote: > On 02/08/2016 11:05 AM, Johannes wrote: >> Imaging following situation: I want to receive two result sets from two >> tables, referring to a specific id from table t0 AND I try not to query >> for that specific id a second time. > >> Table t0 returns 1 row and tab

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Vitaly Burovoy
On 2/8/16, Johannes wrote: > Hi, > > is there a best practice to share data between two select statements? > > Imaging following situation: I want to receive two result sets from two > tables, referring to a specific id from table t0 AND I try not to query > for that specific id a second time. > >

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread Adrian Klaver
On 02/08/2016 11:05 AM, Johannes wrote: Hi, is there a best practice to share data between two select statements? A join: http://www.postgresql.org/docs/9.4/interactive/sql-select.html Search for: join_type Imaging following situation: I want to receive two result sets from two tables, re

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread travis
Not an expert, but I would try a temporary unlogged table. Sent from my android device. -Original Message- From: Johannes To: pgsql-general@postgresql.org Sent: Mon, 08 Feb 2016 11:07 Subject: [GENERAL] execute same query only one time? Hi, is there a best practice to share data

Re: [GENERAL] execute same query only one time?

2016-02-08 Thread David G. Johnston
On Mon, Feb 8, 2016 at 12:05 PM, Johannes wrote: > Hi, > > is there a best practice to share data between two select statements? > > Imaging following situation: I want to receive two result sets from two > tables, referring to a specific id from table t0 AND I try not to query > for that specifi

[GENERAL] execute same query only one time?

2016-02-08 Thread Johannes
Hi, is there a best practice to share data between two select statements? Imaging following situation: I want to receive two result sets from two tables, referring to a specific id from table t0 AND I try not to query for that specific id a second time. Table t0 returns 1 row and table t1 return

Re: [GENERAL] Execute commands in single-user mode

2016-01-18 Thread Jim Nasby
On 1/10/16 3:44 PM, Andreas Joseph Krogh wrote: It might be about time to come up with an extension that's a replacement for large objects. What would it take to fund such an extension? Time and/or money. It would "have to" support: - Migrate existing LOs away from pg_largeobject -

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Andreas Joseph Krogh
På søndag 10. januar 2016 kl. 22:38:05, skrev Jim Nasby < jim.na...@bluetreble.com >: On 1/10/16 10:01 AM, Andreas Joseph Krogh wrote: > pg_largeobject being a system-relation does quite make sense to me, but > that's another discussion. I know there has been some

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Jim Nasby
On 1/10/16 10:01 AM, Andreas Joseph Krogh wrote: pg_largeobject being a system-relation does quite make sense to me, but that's another discussion. I know there has been some discussions in the past about making it a non system-relation but it never got anywhere AFAIK. BTW, there's some other i

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Andreas Joseph Krogh
På søndag 10. januar 2016 kl. 16:53:54, skrev Tom Lane mailto:t...@sss.pgh.pa.us>>: Andreas Joseph Krogh writes: > P�� s��ndag 10. januar 2016 kl. 16:40:23, skrev Tom Lane >: > Andreas Joseph Krogh writes: >>> Then I have to execute the command: >>> alter table pg_

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Tom Lane
Andreas Joseph Krogh writes: > På søndag 10. januar 2016 kl. 16:40:23, skrev Tom Lane >: > Andreas Joseph Krogh writes: >>> Then I have to execute the command: >>> alter table pg_largeobject set tablespace some_tablespace; > Why do you think you need single-user mo

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Andreas Joseph Krogh
På søndag 10. januar 2016 kl. 16:40:23, skrev Tom Lane mailto:t...@sss.pgh.pa.us>>: Andreas Joseph Krogh writes: > I'm planning to move all my pg_largeobject tables to separate tablespaces and > to be able to do that I need to shuddown PG and start in single-user mode, like > this: > postgre

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Tom Lane
Andreas Joseph Krogh writes: > I'm planning to move all my pg_largeobject tables to separate tablespaces and > to be able to do that I need to shuddown PG and start in single-user mode, > like > this: > postgres --single -O -D $PGDATA $DB_NAME > Then I have to execute the command: > alter table

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Melvin Davidson
Sorry, I've never used single user mode, but here is a better example #!/bin/bash echo "**CHANGING TABLESPACES**" gosu postgres postgres --single -O -D $PGDATA $DB_NAME<<- EOSQL alter table pg_largeobject set tablespace some_tablespace; EOSQL pg_ctl stop -d $PGDATA -m fast echo "" echo

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Andreas Joseph Krogh
På søndag 10. januar 2016 kl. 15:52:12, skrev Melvin Davidson < melvin6...@gmail.com >: Well, you can't combine psql with the postgres startup, but you can issue subsequent commands from bash with the -c option:   EG: postgres --single -O -D $PGDATA $DB_NAME # give

Re: [GENERAL] Execute commands in single-user mode

2016-01-10 Thread Melvin Davidson
Well, you can't combine psql with the postgres startup, but you can issue subsequent commands from bash with the -c option: EG: postgres --single -O -D $PGDATA $DB_NAME # give postgres a few seconds to complete startup sleep 30 psql -U postgres -d your_database -c "alter table pg_largeobject set

[GENERAL] Execute commands in single-user mode

2016-01-10 Thread Andreas Joseph Krogh
Hi all.   I'm planning to move all my pg_largeobject tables to separate tablespaces and to be able to do that I need to shuddown PG and start in single-user mode, like this:   postgres --single -O -D $PGDATA $DB_NAME   Then I have to execute the command: alter table pg_largeobject set tablespace

Re: [GENERAL] Execute DDL across multiple servers in an automated manner

2015-08-28 Thread Anderson Abreu
2015-08-28 13:40 GMT-03:00 Adrian Klaver : > On 08/28/2015 07:09 AM, Anderson Abreu wrote: > >> >> 2015-08-28 10:55 GMT-03:00 Adrian Klaver > >: >> >> On 08/28/2015 06:35 AM, Anderson Abreu wrote: >> >> Hi all, >> >> I usePostgreSQL9.4 >> >>

Re: [GENERAL] Execute DDL across multiple servers in an automated manner

2015-08-28 Thread Adrian Klaver
On 08/28/2015 07:09 AM, Anderson Abreu wrote: 2015-08-28 10:55 GMT-03:00 Adrian Klaver mailto:adrian.kla...@aklaver.com>>: On 08/28/2015 06:35 AM, Anderson Abreu wrote: Hi all, I usePostgreSQL9.4 I'm looking for somepackage/library/plugintoexecute DDLacross

Re: [GENERAL] Execute DDL across multiple servers in an automated manner

2015-08-28 Thread Anderson Abreu
2015-08-28 10:55 GMT-03:00 Adrian Klaver : > On 08/28/2015 06:35 AM, Anderson Abreu wrote: > >> Hi all, >> >> I usePostgreSQL9.4 >> >> I'm looking for somepackage/library/plugintoexecute DDLacross multiple >> serversin an automated manner. >> > > This covers a lot of ground. Could you be more spec

Re: [GENERAL] Execute DDL across multiple servers in an automated manner

2015-08-28 Thread Adrian Klaver
On 08/28/2015 06:35 AM, Anderson Abreu wrote: Hi all, I usePostgreSQL9.4 I'm looking for somepackage/library/plugintoexecute DDLacross multiple serversin an automated manner. This covers a lot of ground. Could you be more specific: 1) Do you have a preferred programmng/scripting language? 2

Re: [GENERAL] Execute DDL across multiple servers in an automated manner

2015-08-28 Thread Melvin Davidson
In Linux, you can use Terminator http://gnometerminator.blogspot.com/p/introduction.html to execute a script simultaneously across multiple terminals. Alternatively, you can write a script that loops through host connections to execute the DDL. On Fri, Aug 28, 2015 at 9:35 AM, Anderson Abreu

[GENERAL] Execute DDL across multiple servers in an automated manner

2015-08-28 Thread Anderson Abreu
Hi all, I use PostgreSQL 9.4 I'm looking for some package/library/plugin to execute DDL across multiple servers in an automated manner. Can do this with shellscript. I would like to know if this is the only way? Thanks & Regards --- Anderson Abreu andersonab...@gmail.com "The judoka is wh

Re: [GENERAL] execute trigger after another one

2014-12-04 Thread Carlos Carcamo
2014-12-04 17:31 GMT-06:00 Adrian Klaver : > On 12/04/2014 03:11 PM, Carlos Carcamo wrote: >> >> 2014-12-04 16:46 GMT-06:00 David G Johnston : >>> >>> Carlos Carcamo wrote I read about oGlenrder of execution of triggers, is supposed that postgres executes triggers in alphabetical ord

Re: [GENERAL] execute trigger after another one

2014-12-04 Thread Adrian Klaver
On 12/04/2014 03:11 PM, Carlos Carcamo wrote: 2014-12-04 16:46 GMT-06:00 David G Johnston : Carlos Carcamo wrote I read about order of execution of triggers, is supposed that postgres executes triggers in alphabetical order, so I called the plpgsql a_trigger and the second one b_trigger (as an

Re: [GENERAL] execute trigger after another one

2014-12-04 Thread Stephen Cook
On 12/4/2014 6:11 PM, Carlos Carcamo wrote: Yes because my update_remote.sh file calls a php file to update a table in mysql, and it is updated after I perform another query to in_kardex, so the mysql table is one query behind postgres... Any thoughts? My bet is that the query run from your

Re: [GENERAL] execute trigger after another one

2014-12-04 Thread Carlos Carcamo
2014-12-04 16:46 GMT-06:00 David G Johnston : > Carlos Carcamo wrote >> I read about order of execution of triggers, is supposed that postgres >> executes triggers in alphabetical order, so I called the plpgsql >> a_trigger and the second one b_trigger (as an example), but it seems >> that the seco

Re: [GENERAL] execute trigger after another one

2014-12-04 Thread David G Johnston
Carlos Carcamo wrote > I read about order of execution of triggers, is supposed that postgres > executes triggers in alphabetical order, so I called the plpgsql > a_trigger and the second one b_trigger (as an example), but it seems > that the second one always executes first. > > Is there any way

[GENERAL] execute trigger after another one

2014-12-04 Thread Carlos Carcamo
Hello list, hope you're well. I need some help with postgres. I have two triggers that are executed after insert, update and delete. One trigger is with plpgsql language and the other one is with pl/python, the first one just update some tables and last one calls a *.sh that is executed to perfor

Re: [GENERAL] execute table query in backend

2014-03-10 Thread Anh Pham
Thank you for you suggestion. I actually took a look at SPI_ functions before. However, I believe using this will bring quite an overhead. I am trying to modify the Sequence scan node such that: each time the scan returns a tuple, we'll take some information from this tuple. And finally issue anoth

Re: [GENERAL] execute table query in backend

2014-03-05 Thread Amit Langote
On Tue, Mar 4, 2014 at 12:38 AM, Anh Pham wrote: > Hi, > I am trying to extend the server backend by writing a new module. > Basically, it tries to retrieve tuples from a specific table using some > predefined qualifications (equivalent to "SELECT FROM WHERE" client sql > statement ). > Is there a

[GENERAL] execute table query in backend

2014-03-03 Thread Anh Pham
Hi, I am trying to extend the server backend by writing a new module. Basically, it tries to retrieve tuples from a specific table using some predefined qualifications (equivalent to "SELECT FROM WHERE" client sql statement ). Is there any quick or efficient way to do this? Many thanks :)

Re: [GENERAL] execute query from inside C function

2014-02-25 Thread Pavel Stehule
2014-02-25 13:36 GMT+01:00 James Harper : > > Hello > > > > you should to use a SPI API > > > > http://www.postgresql.org/docs/9.3/static/spi.html > > > > http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html > > > > Yep just found it. I obviously didn't google hard enough. > It is not on f

Re: [GENERAL] execute query from inside C function

2014-02-25 Thread James Harper
> Hello > > you should to use a SPI API > > http://www.postgresql.org/docs/9.3/static/spi.html > > http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html > Yep just found it. I obviously didn't google hard enough. Thanks James -- Sent via pgsql-general mailing list (pgsql-general@post

Re: [GENERAL] execute query from inside C function

2014-02-25 Thread Pavel Stehule
Hello you should to use a SPI API http://www.postgresql.org/docs/9.3/static/spi.html http://www.postgresql.org/docs/9.3/static/spi-spi-exec.html Regards Pavel Stehule 2014-02-25 13:22 GMT+01:00 James Harper : > I've googled the docs but I can't seem to make a link as to how to execute > dat

[GENERAL] execute query from inside C function

2014-02-25 Thread James Harper
I've googled the docs but I can't seem to make a link as to how to execute database queries from inside a C function. I'm used to having a PGconn and using the API around that, but how do I do that from inside a C function (and a bit later on, a language handler?) Thanks James -- Sent via p

Re: [GENERAL] execute if statement

2012-12-03 Thread John R Pierce
On 12/1/2012 11:59 AM, Peter Kroon wrote: I do not wish to create a function for each query I have. query's aren't IF statements. SELECT stuff FROM table WHERE conditions ;<= thats a query. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to

Re: [GENERAL] execute if statement

2012-12-03 Thread Jasen Betts
On 2012-12-01, Peter Kroon wrote: > --f46d043be1f4bd2dec04cfcfbd6a > Content-Type: text/plain; charset=ISO-8859-1 > > M... > > How do I execute dynamic sql that starts with an if statement. "if" is not SQL. > I'm converting mssql code to pgsql. probably best to rewrite at a higher level

Re: [GENERAL] execute if statement

2012-12-01 Thread Raymond O'Donnell
On 01/12/2012 19:44, Peter Kroon wrote: > M... > > How do I execute dynamic sql that starts with an if statement. > I'm converting mssql code to pgsql. > Without trying it, I'd guess that you need to have the IF outside the dynamic code, something like this: if then execute '

Re: [GENERAL] execute if statement

2012-12-01 Thread Peter Kroon
To give a better idea: DO $$ DECLARE v_string text = 'raise notice ''%'', ''this could be sql with if statement...'';'; BEGIN if 1=1 then raise notice '%', ' first notice has been raised...'; end if; EXECUTE v_string;--this fails END; $$ LANGUAGE plpgsql; I do not wish to create a function for ea

Re: [GENERAL] execute if statement

2012-12-01 Thread Peter Kroon
M... How do I execute dynamic sql that starts with an if statement. I'm converting mssql code to pgsql. 2012/12/1 Raymond O'Donnell > On 01/12/2012 19:11, Peter Kroon wrote: > > How can I achieve this? > > > > EXECUTE ' > > > > if 1=1 then > > raise notice ''%'', ''notice has been rais

Re: [GENERAL] execute if statement

2012-12-01 Thread Raymond O'Donnell
On 01/12/2012 19:11, Peter Kroon wrote: > How can I achieve this? > > EXECUTE ' > > if 1=1 then > raise notice ''%'', ''notice has been raised...''; > end if; > > '; I think EXECUTE used like this is available only in a function: create or replace function my_function() returns void as

[GENERAL] execute if statement

2012-12-01 Thread Peter Kroon
How can I achieve this? EXECUTE ' if 1=1 then raise notice ''%'', ''notice has been raised...''; end if; ';

Re: [GENERAL] "EXECUTE command-string INTO target USING expression" isn't working

2012-04-18 Thread Bartosz Dmytrak
Hi, I have create small proof of concept (pg v. 9.1.3): 1. to map Your dynamic function: CREATE OR REPLACE FUNCTION public.testReturnDynamic(OUT "retValue" TEXT) RETURNS text AS $BODY$ BEGIN "retValue" = 'aaa'; END; $BODY$ LANGUAGE plpgsql SECURITY DEFINER; 2. to test function SELECT public.tes

[GENERAL] "EXECUTE command-string INTO target USING expression" isn't working

2012-04-18 Thread Ken Winter
I swear this used to work, but in PostgreSQL 9.1 it doesn't work any more... CASE 1: If I write it like this: FOR func IN ( SELECT * FROM information_schema.routines WHERE routine_schema = 'tests' ) LOOP q := 'SELECT tests.' || fun

Re: [GENERAL] EXECUTE USING problem

2011-11-15 Thread Raymond O'Donnell
On 15/11/2011 12:45, Graham wrote: > Using PG 9.0.3, I wish to dynamically reference a column in a table > passed into a PL/PgSQL function as follows: > > -- A table with some values. > DROP TABLE IF EXISTS table1; > CREATE TABLE table1 ( > code INT, > descr TEXT > ); > > INSERT INTO

Re: [GENERAL] EXECUTE USING problem

2011-11-15 Thread Pavel Stehule
Hello 2011/11/15 Graham : > Using PG 9.0.3, I wish to dynamically reference a column in a table passed > into a PL/PgSQL function as follows: > > -- A table with some values. >  DROP TABLE IF EXISTS table1; >  CREATE TABLE table1 ( >     code INT, >     descr TEXT >  ); > > INSERT INTO table1 VALU

[GENERAL] EXECUTE USING problem

2011-11-15 Thread Graham
Using PG 9.0.3, I wish to dynamically reference a column in a table passed into a PL/PgSQL function as follows: -- A table with some values. DROP TABLE IF EXISTS table1; CREATE TABLE table1 ( code INT, descr TEXT ); INSERT INTO table1 VALUES ('1','a'); INSERT INTO table1 VALUES ('2

Re: [GENERAL] EXECUTE of a 'create table' string is not happening

2011-02-22 Thread Pavel Stehule
2011/2/22 Ralph Smith : > Hi, > > I'm passing a tablename and two columnnames into a function so that I can > SELECT Records in a FOR LOOP using 'fixed' field names. > Using the passed params I construct the create table command and then alter > the names of two columns. > > When I 'build' the func

Re: [GENERAL] EXECUTE of a 'create table' string is not happening

2011-02-22 Thread David Johnston
: Tuesday, February 22, 2011 2:05 PM To: pgsql-general@postgresql.org Subject: [GENERAL] EXECUTE of a 'create table' string is not happening Hi, I'm passing a tablename and two columnnames into a function so that I can SELECT Records in a FOR LOOP using 'fixed' field names.

[GENERAL] EXECUTE of a 'create table' string is not happening

2011-02-22 Thread Ralph Smith
Hi, I'm passing a tablename and two columnnames into a function so that I can SELECT Records in a FOR LOOP using 'fixed' field names. Using the passed params I construct the create table command and then alter the names of two columns. When I 'build' the function and then run my query to use

Re: [GENERAL] "EXECUTE ... into var" doesn't set FOUND: bug or feature?

2010-09-16 Thread Pavel Stehule
2010/9/16 Louis-David Mitterrand : > On Thu, Sep 16, 2010 at 10:12:57AM -0400, Tom Lane wrote: >> Louis-David Mitterrand writes: >> > I noticed that in a pl/pgsql function FOUND is not set after an >> >     EXECUTE ... into var; >> > Bug or feature? >> >> It's behaving as documented: >> http://www

Re: [GENERAL] "EXECUTE ... into var" doesn't set FOUND: bug or feature?

2010-09-16 Thread Louis-David Mitterrand
On Thu, Sep 16, 2010 at 10:12:57AM -0400, Tom Lane wrote: > Louis-David Mitterrand writes: > > I noticed that in a pl/pgsql function FOUND is not set after an > > EXECUTE ... into var; > > Bug or feature? > > It's behaving as documented: > http://www.postgresql.org/docs/9.0/static/plpgsql-st

Re: [GENERAL] "EXECUTE ... into var" doesn't set FOUND: bug or feature?

2010-09-16 Thread Tom Lane
Louis-David Mitterrand writes: > I noticed that in a pl/pgsql function FOUND is not set after an > EXECUTE ... into var; > Bug or feature? It's behaving as documented: http://www.postgresql.org/docs/9.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS Adding EXECUTE to the li

Re: [GENERAL] "EXECUTE ... into var" doesn't set FOUND: bug or feature?

2010-09-16 Thread Pavel Stehule
Hello 2010/9/16 Louis-David Mitterrand : > Hi, > > I noticed that in a pl/pgsql function FOUND is not set after an > >        EXECUTE ... into var; > > Bug or feature? > feature :( use a GET DIAGNOSTICS statement instead Regards Pavel Stehule > -- > Sent via pgsql-general mailing list (pgsql-

[GENERAL] "EXECUTE ... into var" doesn't set FOUND: bug or feature?

2010-09-16 Thread Louis-David Mitterrand
Hi, I noticed that in a pl/pgsql function FOUND is not set after an EXECUTE ... into var; Bug or feature? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Execute permission for functions

2010-06-30 Thread Adrian Klaver
On 06/30/2010 02:09 PM, mirthcyy wrote: Hi there, I'm a newbie to postgresql and I have some problems working with its permissions. For security purpose, I want that my application service account only has execution permissions to the functions I created. so what I did is: Create a group test

[GENERAL] Execute permission for functions

2010-06-30 Thread mirthcyy
Hi there, I'm a newbie to postgresql and I have some problems working with its permissions. For security purpose, I want that my application service account only has execution permissions to the functions I created. so what I did is: Create a group testgroup (not super user) Create a user testus

Re: [GENERAL] EXECUTE and FOUND

2010-05-27 Thread Pavel Stehule
2010/5/25 Bogdan Gusiev : > I am not sure if EXECUTE 'SELECT * FROM table" correctly sets FOUND > variable. > no - it doesn't it > EXECUTE 'SELECT * FROM ' || quote_ident(stmt.tablename) || ' limit 1'; > if found then >   > end if; > > Is there other way to check if EXECUTE 'SELECT ...' found

[GENERAL] EXECUTE and FOUND

2010-05-27 Thread Bogdan Gusiev
I am not sure if EXECUTE 'SELECT * FROM table" correctly sets FOUND variable. EXECUTE 'SELECT * FROM ' || quote_ident(stmt.tablename) || ' limit 1'; if found then end if; Is there other way to check if EXECUTE 'SELECT ...' found something or not? -- Sent via pgsql-general mailing list (p

Re: [GENERAL] Execute a query passed by parameters to a function

2009-11-09 Thread Yadira Lizama Mue
nviados: Lunes, 9 de Noviembre 2009 17:00:28 GMT +01:00 Amsterdam / Berlín / Berna / Roma / Estocolmo / Viena Asunto: Re: [GENERAL] Execute a query passed by parameters to a function 2009/11/9 Yadira Lizama Mue : > > Hi, > I have a function which receive a parameters as text. This text is a que

Re: [GENERAL] Execute a query passed by parameters to a function

2009-11-09 Thread Thom Brown
2009/11/9 Yadira Lizama Mue : > > Hi, > I have a function which receive a parameters as text. This text is a query. I > want to execute this query, but I don't know how. Can any one help me? > Regards, > Yadira > > > CREATE OR REPLACE FUNCTION myfunction(text) >  RETURNS void AS > $BODY$ > --I wan

[GENERAL] Execute a query passed by parameters to a function

2009-11-09 Thread Yadira Lizama Mue
Hi, I have a function which receive a parameters as text. This text is a query. I want to execute this query, but I don't know how. Can any one help me? Regards, Yadira CREATE OR REPLACE FUNCTION myfunction(text) RETURNS void AS $BODY$ --I want execute the text I pass by parameters as a

Re: [GENERAL] Execute Immediate

2009-07-12 Thread Michael Gould
Thanks, that is exactly what I need as a workaround to session variables. The temp tables will work as we need them as we only have a 5 that are temp tables and preserve is needed only for the active session, once the session has ended the temp table should go away. "Pavel Stehule" wrote: > 200

Re: [GENERAL] Execute Immediate

2009-07-12 Thread Pavel Stehule
Hello plpgsql has execute statement, that has similar behave like execute immediate in others systems. note - postgresql doesn't support global temp tables yet. regards Pavel Stehule 2009/7/12 Michael Gould : > In many SQL dialets there is the availability of Execute immediate which > allows yo

[GENERAL] Execute Immediate

2009-07-12 Thread Michael Gould
In many SQL dialets there is the availability of Execute immediate which allows you to build global temp tables or views at run time and even stored procedures at runtime and then execute them inline.  Is there a way to do this in PostGres 8.4   Best Regards   -- Michael Gould, Managing Par

Re: [GENERAL] Execute Shell script after insert

2008-10-28 Thread Sam Mason
On Mon, Oct 27, 2008 at 04:16:16PM -0400, Tom Lane wrote: > Sam Mason <[EMAIL PROTECTED]> writes: > > when something goes wrong (as code inevitably does) the database > > will continue doing things automatically for you (like touching the > > filesystem) when you're fighting against it trying to fi

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread Chris Browne
[EMAIL PROTECTED] ("Anderson dos Santos Donda") writes: > Is there a way to execute a simple shell script in server after execute > INSERT INTO ? > Example? > INSERT INTO clients (name) VALUES ('Donda'); > after it, execute shell : mkdir $1 You could do this, directly, via stored procedure langua

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread David Fetter
On Mon, Oct 27, 2008 at 03:09:31PM -0300, Anderson dos Santos Donda wrote: > Is there a way to execute a simple shell script in server after execute > INSERT INTO ? > > Example? > > INSERT INTO clients (name) VALUES ('Donda'); > > after it, execute shell : mkdir $1 This will scale better if you

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread Tom Lane
Sam Mason <[EMAIL PROTECTED]> writes: > On Mon, Oct 27, 2008 at 03:09:31PM -0300, Anderson dos Santos Donda wrote: >> Is there a way to execute a simple shell script in server after execute >> INSERT INTO ? > Yes; as other people have said most of the procedural languages allow > you to run code o

Re: [GENERAL] EXECUTE in trigger functions.

2008-10-27 Thread Hannes Dorbath
David Brain wrote: > Is there a way of using EXECUTE in trigger functions to to do something > like: > > CREATE OR REPLACE FUNCTION insert_trigger() > RETURNS trigger AS > $BODY$ > BEGIN > EXECUTE('INSERT INTO public_partitions.table_' > || date_part('year',NEW.eventdate)::VarChar >

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread Sam Mason
On Mon, Oct 27, 2008 at 03:09:31PM -0300, Anderson dos Santos Donda wrote: > Is there a way to execute a simple shell script in server after execute > INSERT INTO ? Yes; as other people have said most of the procedural languages allow you to run code outside PG. You'd just need to hook this proce

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread Andreas Jochem
You can write the insert into command in a shellscript by using #!/bin/bash psql -c "INSERT INTO " -U mkdir $1 Anderson dos Santos Donda wrote: Is there a way to execute a simple shell script in server after execute INSERT INTO ? Example? INSERT INTO clients (name) VALUES (

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread Scott Marlowe
On Mon, Oct 27, 2008 at 12:21 PM, Hannes Dorbath <[EMAIL PROTECTED]> wrote: > Anderson dos Santos Donda wrote: >> Is there a way to execute a simple shell script in server after execute >> INSERT INTO ? >> >> Example? >> >> INSERT INTO clients (name) VALUES ('Donda'); >> >> after it, execute shell

Re: [GENERAL] Execute Shell script after insert

2008-10-27 Thread Hannes Dorbath
Anderson dos Santos Donda wrote: > Is there a way to execute a simple shell script in server after execute > INSERT INTO ? > > Example? > > INSERT INTO clients (name) VALUES ('Donda'); > > after it, execute shell : mkdir $1 You might find the following project useful: http://plsh.projects.post

[GENERAL] Execute Shell script after insert

2008-10-27 Thread Anderson dos Santos Donda
Is there a way to execute a simple shell script in server after execute INSERT INTO ? Example? INSERT INTO clients (name) VALUES ('Donda'); after it, execute shell : mkdir $1 Thanks!!!

[GENERAL] EXECUTE in trigger functions.

2008-10-27 Thread David Brain
Hi, Is there a way of using EXECUTE in trigger functions to to do something like: CREATE OR REPLACE FUNCTION insert_trigger() RETURNS trigger AS $BODY$ BEGIN EXECUTE('INSERT INTO public_partitions.table_' || date_part('year',NEW.eventdate)::VarChar || lpad(date_part(

Re: [GENERAL] Execute

2008-02-08 Thread valgog
On Feb 5, 9:11 am, "Дикий неадекватный кальмар" <[EMAIL PROTECTED]> wrote: > is there a way to catch error returned by EXECUTE statement? > > declare stmt character varying; > begin > stmt=crate user||'some_name'||' with password '''||'somepassword'; > execute stmt; > > end; > > here i need to know

Re: [GENERAL] execute pg_dump via python

2007-10-29 Thread Andy
Garry Saddington wrote: I am using zope on windows with an external python method to backup my database. I am struggling to run the following command: pg_dump.exe database > file I have tried using os.popen - no luck and also subprocess.Popen. eg: import subprocess subprocess.Popen([

Re: [GENERAL] execute pg_dump via python

2007-10-25 Thread Trevor Talbot
On 10/25/07, Garry Saddington <[EMAIL PROTECTED]> wrote: > I am using zope on windows with an external python method to backup my > database. I am struggling to run the following command: > > pg_dump.exe database > file > subprocess.Popen(['c:/dir/dir/pg_dump.exe','database','>','c:/dir/dir/output

  1   2   >