Re: [GENERAL] Dynamic SQL - transition from ms to pg

2014-01-06 Thread Erik Darling
Thank you Pavel. That's exactly what I needed to get started. On Jan 6, 2014 3:25 AM, "Pavel Stehule" wrote: > Hello > > > > 2014/1/6 Erik Darling > >> Hi, >> >> I've been developing for MS SQL around four years. I'm starting out with >> some work in Postgresql next week, and I'd like to know i

Re: [GENERAL] Dynamic SQL - transition from ms to pg

2014-01-06 Thread Pavel Stehule
Hello 2014/1/6 Erik Darling > Hi, > > I've been developing for MS SQL around four years. I'm starting out with > some work in Postgresql next week, and I'd like to know if there's any > equivalent way to do something like this (from my word press) > > http://sqldriver.wordpress.com/2013/12/09/

Re: [GENERAL] Dynamic SQL - transition from ms to pg

2014-01-05 Thread Michael Paquier
On Mon, Jan 6, 2014 at 2:13 PM, Erik Darling wrote: > Hi, > > I've been developing for MS SQL around four years. I'm starting out with > some work in Postgresql next week, and I'd like to know if there's any > equivalent way to do something like this (from my word press) > > http://sqldriver.word

[GENERAL] Dynamic SQL - transition from ms to pg

2014-01-05 Thread Erik Darling
Hi, I've been developing for MS SQL around four years. I'm starting out with some work in Postgresql next week, and I'd like to know if there's any equivalent way to do something like this (from my word press) http://sqldriver.wordpress.com/2013/12/09/generating-inserts-dynamically/ My question

[GENERAL] Dynamic SQL in Lua

2013-06-15 Thread Marc Balmer
The PostgreSQL Lua binding found on https://github.com/mbalmer/luapgsql has been extended to make it a bit easier to create SQL commands dynamically and still be able to use execParams(). Imagine a table with user information that contains usernames, hostnames, locations (e.g. building a user work

Re: [GENERAL] Dynamic sql real examples

2011-10-13 Thread Gavin Flower
On 13/10/11 17:55, Gabriel Filipiak wrote: Hi all, I have lately learned what is dynamic sql and one of the most interesting features of it to me is that we can use dynamic columns names and tables. But I cannot think about useful real life examples. The only one that came into my mind is sta

Re: [GENERAL] Dynamic sql real examples

2011-10-13 Thread Gavin Flower
On 13/10/11 18:44, Gabriel Filipiak wrote: 2011/10/13 Gavin Flower > On 13/10/11 18:35, Gabriel Filipiak wrote: Thx Gavin, any other suggestions from others? Gabe 2011/10/13 Gavin Flower mailto:gavinflo...@archidevsys.co.nz>>

Re: [GENERAL] Dynamic sql real examples

2011-10-12 Thread Pavel Stehule
Hello It's really depends on client software and architecture. Dynamic SQL is interesting for some use cases when you use a stored procedures, when you dynamically create tables based on metadata and when you access these tables. We had a object oriented database with interface in stored procedur

Re: [GENERAL] Dynamic sql real examples

2011-10-12 Thread John R Pierce
Please do not 'top post'. In these mailings lists, you are expected to add your comments either interpersed, or (more normally) at the bottom. This allows people to read the context, before they read your comments. Sorry about that. the other half of not top posting is editt

Re: [GENERAL] Dynamic sql real examples

2011-10-12 Thread Gabriel Filipiak
2011/10/13 Gavin Flower > On 13/10/11 18:35, Gabriel Filipiak wrote: > > Thx Gavin, > > any other suggestions from others? > > Gabe > > 2011/10/13 Gavin Flower > >> On 13/10/11 17:55, Gabriel Filipiak wrote: >> >> Hi all, >> >> I have lately learned what is dynamic sql and one of the most >>

Re: [GENERAL] Dynamic sql real examples

2011-10-12 Thread Gabriel Filipiak
Thx Gavin, any other suggestions from others? Gabe 2011/10/13 Gavin Flower > On 13/10/11 17:55, Gabriel Filipiak wrote: > > Hi all, > > I have lately learned what is dynamic sql and one of the most interesting > features of it to me is that we can use dynamic columns names and tables. > But

[GENERAL] Dynamic sql real examples

2011-10-12 Thread Gabriel Filipiak
Hi all, I have lately learned what is dynamic sql and one of the most interesting features of it to me is that we can use dynamic columns names and tables. But I cannot think about useful real life examples. The only one that came into my mind is statistical table. Let`s say that we have table wi

Re: [GENERAL] Dynamic SQL with pgsql, how to?

2010-05-04 Thread Andre Lopes
Thanks for the reply, It is working now. Best Regards. On Tue, May 4, 2010 at 7:44 AM, Maximilian Tyrtania < maximilian.tyrta...@byte-employer.de> wrote: > Am 03.05.2010 um 23:50 schrieb Andre Lopes: > > > Thanks for the reply's, > > > > I need to do a Dynamic SELECT INTO. There is a way of do

Re: [GENERAL] Dynamic SQL with pgsql, how to?

2010-05-03 Thread Maximilian Tyrtania
Am 03.05.2010 um 23:50 schrieb Andre Lopes: > Thanks for the reply's, > > I need to do a Dynamic SELECT INTO. There is a way of doing it? Yes. Plpgsql supports this: EXECUTE command-string [ INTO [STRICT] target ] [ USING expression [, ... ] ]; See http://developer.postgresql.org/pgdocs/postgr

Re: [GENERAL] Dynamic SQL with pgsql, how to?

2010-05-03 Thread Andre Lopes
Thanks for the reply's, I need to do a Dynamic SELECT INTO. There is a way of doing it? Best Regards, On Mon, May 3, 2010 at 10:05 AM, A. Kretschmer < andreas.kretsch...@schollglas.com> wrote: > In response to Andre Lopes : > > Hi, > > > > I need to write some dynamic SQL in pgsql. > > There i

Re: [GENERAL] Dynamic SQL with pgsql, how to?

2010-05-03 Thread A. Kretschmer
In response to Andre Lopes : > Hi, > > I need to write some dynamic SQL in pgsql. > There is documentation on how can I do this in pgsql? Sure, http://www.postgresql.org/docs/8.4/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN Regards, Andreas -- Andreas Kretschmer Kontakt: Hey

Re: [GENERAL] Dynamic SQL with pgsql, how to?

2010-05-03 Thread Jorge Arevalo
On Mon, May 3, 2010 at 10:44 AM, Andre Lopes wrote: > Hi, > > I need to write some dynamic SQL in pgsql. > > I have to do something like this: > > [code=SQL Server] >     SET @STRINGN = @STRINGN + ' AND A.' + @CAMPOFECINI + ' IN (SELECT > MAX(B.' + @CAMPOFECINI + ') >             FROM ' + @TABLA +

[GENERAL] Dynamic SQL with pgsql, how to?

2010-05-03 Thread Andre Lopes
Hi, I need to write some dynamic SQL in pgsql. I have to do something like this: [code=SQL Server] SET @STRINGN = @STRINGN + ' AND A.' + @CAMPOFECINI + ' IN (SELECT MAX(B.' + @CAMPOFECINI + ') FROM ' + @TABLA + ' B WHERE B.ID_SOCIEDAD = A.ID_SOCIEDAD AND B

[GENERAL] Dynamic SQL, Return Query Execute with Join

2010-02-05 Thread Mark Watson
Hi all, I wish to pass a query text (containing joins) and separate parameters to a plpgsql function that will return a result set (more than one row) using RETURN QUERY EEXECUTE, but am having trouble defining the result set because of the join. Am I limited to the result set being restricted to o

Re: [GENERAL] Dynamic SQL in Function

2009-04-23 Thread Martin Gainty
_ Rediscover Hotmail®: Get e-mail storage that grows with you. http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009 -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make c

Re: [GENERAL] Dynamic SQL in Function

2009-04-23 Thread Merlin Moncure
On Thu, Apr 23, 2009 at 11:36 AM, wrote: >> On Wed, Apr 22, 2009 at 12:29 PM,   wrote: >>> If I have built a dynamic sql statement in a function, how do i return >>> it >>> as a ref cursor? >> >> CREATE FUNCTION reffunc(_ref) RETURNS refcursor AS >> $$ >> BEGIN >>     OPEN _ref FOR execute 'SELEC

Re: [GENERAL] Dynamic SQL in Function

2009-04-23 Thread rwade
Is this possible without having to pass in the _ref parameter? Thanks Ryan > On Wed, Apr 22, 2009 at 12:29 PM, wrote: >> If I have built a dynamic sql statement in a function, how do i return >> it >> as a ref cursor? > > CREATE FUNCTION reffunc(_ref) RETURNS refcursor AS > $$ > BEGIN > OP

Re: [GENERAL] Dynamic SQL in Function

2009-04-22 Thread Merlin Moncure
n Wed, Apr 22, 2009 at 2:54 PM, Merlin Moncure wrote: > On Wed, Apr 22, 2009 at 12:29 PM,   wrote: >> If I have built a dynamic sql statement in a function, how do i return it >> as a ref cursor? > > CREATE FUNCTION reffunc(_ref) RETURNS refcursor AS oops CREATE FUNCTION reffunc(_ref refcursor)

Re: [GENERAL] Dynamic SQL in Function

2009-04-22 Thread Merlin Moncure
On Wed, Apr 22, 2009 at 12:29 PM, wrote: > If I have built a dynamic sql statement in a function, how do i return it > as a ref cursor? CREATE FUNCTION reffunc(_ref) RETURNS refcursor AS $$ BEGIN OPEN _ref FOR execute 'SELECT * from foo'; RETURN _ref; END; $$ LANGUAGE plpgsql; BEGIN; SE

[GENERAL] Dynamic SQL in Function

2009-04-22 Thread rwade
If I have built a dynamic sql statement in a function, how do i return it as a ref cursor? -- 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] dynamic sql in PL-Pgsql ?

2008-09-26 Thread Raymond O'Donnell
On 26/09/2008 21:19, Gauthier, Dave wrote: > As you can see, the select statement needs to be dynamic in that the > column name is stored in a variable. > > > Can this be done? http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

[GENERAL] dynamic sql in PL-Pgsql ?

2008-09-26 Thread Gauthier, Dave
Hi: I want to do something like this. create or replace function foo(varchar, varchar) returns integer as $$ declare user_attrib alias for $1; attrib_valalias for $2; rec record; begin for rec in select name from people_table where user_attrib = attrib

Re: [GENERAL] dynamic SQL - variable substitution in plpgsql

2006-12-07 Thread Alban Hertroys
km wrote: > Hi all, > > i could not do variable substitution in plpgsql procedure. > The variable names are taken as it is but not substituted in the SQL query. > what could be the problem ? Does this example even compile? I doubt that... > code looks like this: > --

Re: [GENERAL] dynamic SQL - variable substitution in plpgsql

2006-12-06 Thread Tony Caduto
km wrote: Hi all, i could not do variable substitution in plpgsql procedure. The variable names are taken as it is but not substituted in the SQL query. what could be the problem ? FOR result IN "SELECT x,y,z FROM mydata WHERE x = a AND y < b AND z > c" LOOP RETURN NEXT result;

[GENERAL] dynamic SQL - variable substitution in plpgsql

2006-12-06 Thread km
Hi all, i could not do variable substitution in plpgsql procedure. The variable names are taken as it is but not substituted in the SQL query. what could be the problem ? code looks like this: -- CREATE OR REPLACE FUNCTION test(a te

Re: [GENERAL] Dynamic SQL

2005-06-16 Thread Sean Davis
On Jun 16, 2005, at 6:21 AM, Craig Bryden wrote: Hi I am trying to get information on how to do "Dynamic SQL" in PostgreSQL (preferably pg/plsql). Please can someone give an exaple of how this is done or direct me to the relevant documentation. There is searchable documentation here (book

[GENERAL] Dynamic SQL

2005-06-16 Thread Craig Bryden
Hi I am trying to get information on how to do "Dynamic SQL" in PostgreSQL (preferably pg/plsql). Please can someone give an exaple of how this is done or direct me to the relevant documentation. Thanks Craig ---(end of broadcast)--- TIP 5: Have y

Re: [GENERAL] Dynamic SQL

2005-01-31 Thread Troels Arvin
On Mon, 31 Jan 2005 13:18:38 +0100, Mark Battersby wrote: > When looking at PostGres through the eyes of an Oracle Developer I was > wondering if PostGres supports a feature called Dynamic SQL. Of course even > better would be the ability to run PostGress/PL dynamically too. PostgreSQL does not c

Re: [GENERAL] Dynamic SQL

2005-01-31 Thread Shridhar Daithankar
Mark Battersby wrote: When looking at PostGres through the eyes of an Oracle Developer I was wondering if PostGres supports a feature called Dynamic SQL. Of course even better would be the ability to run PostGress/PL dynamically too. Dynamic SQL and Dynamic PL/SQL are useful when you don’t know

Re: [GENERAL] Dynamic SQL

2005-01-31 Thread John Sidney-Woollett
Yes, it does. And it's a lot easier than DBMS_SQL too! Look at the EXECUTE command in the pl/pgsql programming language. See http://www.postgresql.org/docs/7.4/interactive/plpgsql-statements.html John Sidney-Woollett Mark Battersby wrote: Hi When looking at PostGres through the eyes of an Oracle

[GENERAL] Dynamic SQL

2005-01-31 Thread Mark Battersby
Hi   When looking at PostGres through the eyes of an Oracle Developer I was wondering if PostGres supports a feature called Dynamic SQL. Of course even better would be the ability to run PostGress/PL dynamically too.   Dynamic SQL and Dynamic PL/SQL are useful when you don’t know until

Re: [GENERAL] Dynamic SQL

2004-06-02 Thread Richard Huxton
Hadley Willan wrote: Hi all, I'd like to write a function that would allow me to verify some attributes on a table so that I could give a meaningful error message... constructedSql = ''SELECT INTO recCheckObject * FROM '' || tableName || '' WHERE '' || idColumn || '' = '' || objectId;

[GENERAL] Dynamic SQL

2004-06-01 Thread Hadley Willan
Hi all,     I'd like to write a function that would allow me to verify some attributes on a table so that I could give a meaningful error message... I've been playing with passing in to a plpgsql function the following things. CREATE OR REPLACE FUNCTION fn_verifyObject( VARCHAR, VARCHAR, BIGI