[GENERAL] Scripting function definitions as SQL?

2008-05-11 Thread Postgres User
Has anyone written a function that scripts out all the functions in a database as full SQL statements (Create Function.) I found the below SQL will return all the fields needed to build a SQL statement, but it would take some work to combine the field values correctly to get the right format.

Re: [GENERAL] Scripting function definitions as SQL?

2008-05-11 Thread Martijn van Oosterhout
On Sun, May 11, 2008 at 06:12:40AM -0700, Postgres User wrote: Has anyone written a function that scripts out all the functions in a database as full SQL statements (Create Function.) I found the below SQL will return all the fields needed to build a SQL statement, but it would take some

Re: [GENERAL] Scripting function definitions as SQL?

2008-05-11 Thread Postgres User
Unfortunately I didn't see a way to tell pg_dump to dump only objects of a specific type, like functions or sequences. It requires additional coding to parse the output and that's less than ideal... Does pg_dump not do what you want? On Sun, May 11, 2008 at 6:49 AM, Martijn van Oosterhout

Re: [GENERAL] Scripting function definitions as SQL?

2008-05-11 Thread hubert depesz lubaczewski
On Sun, May 11, 2008 at 11:28:37AM -0700, Postgres User wrote: Unfortunately I didn't see a way to tell pg_dump to dump only objects of a specific type, like functions or sequences. It requires additional coding to parse the output and that's less than ideal... hmmm .. additional coding seems

[GENERAL] How to create a function with multiple RefCursor OUT parameters

2008-05-11 Thread Chuck Bai
I have the following function: CREATE OR REPLACE FUNCTION test_refcursor(INOUT tcount integer, OUT o_user refcursor, OUT o_name refcursor) RETURNS record AS $BODY$ BEGIN tcount := tcount + 1; OPEN o_user FOR SELECT * FROM user_table; OPEN o_name FOR SELECT * FROM name_table; END;

Re: [GENERAL] Scripting function definitions as SQL?

2008-05-11 Thread Postgres User
Yes, but I'm doing this from a Delphi program in Windows and that's why I'm looking for a solution that's SQL-based. It would be nice if one of the system catalog views handled it. hmmm .. additional coding seems a bit too much for a simple thing like this: pg_dump -s | perl -ne 'print if

[GENERAL] Making sure \timing is on

2008-05-11 Thread Francisco Reyes
Is there a way to make certain \timing is on? I am looking for something simmilar to what one can do with the pager \pset pager always Most scripts I am working with (inheritted) don't have \timing in them so I can put timing on/off as needed. However some scripts already have it. So if I set

Re: [GENERAL] Making sure \timing is on

2008-05-11 Thread Tom Lane
Francisco Reyes [EMAIL PROTECTED] writes: Is there a way to make certain \timing is on? Not that I know of :-(. There's been discussion of fixing all of psql's toggle commands to offer \foo on and \foo off variants, which would be far more scripting-friendly ... but nobody's stepped up to do

Re: [GENERAL] Making sure \timing is on

2008-05-11 Thread Francisco Reyes
Tom Lane writes: Not that I know of :-(. There's been discussion of fixing all of psql's toggle commands to offer \foo on and \foo off What would be a good starting point for someone interesting in looking into working on that? Started a job recently as PostgresSQL DBA.. so sooner or

Re: [GENERAL] Making sure \timing is on

2008-05-11 Thread Tom Lane
Francisco Reyes [EMAIL PROTECTED] writes: Tom Lane writes: Not that I know of :-(. There's been discussion of fixing all of psql's toggle commands to offer \foo on and \foo off What would be a good starting point for someone interesting in looking into working on that? This'd be a fine

Re: [GENERAL] Making sure \timing is on

2008-05-11 Thread Scott Marlowe
On Sun, May 11, 2008 at 9:04 PM, Tom Lane [EMAIL PROTECTED] wrote: Francisco Reyes [EMAIL PROTECTED] writes: Tom Lane writes: Not that I know of :-(. There's been discussion of fixing all of psql's toggle commands to offer \foo on and \foo off What would be a good starting point for someone

Re: [GENERAL] Making sure \timing is on

2008-05-11 Thread Tom Lane
Scott Marlowe [EMAIL PROTECTED] writes: Is it reasonable behavior to have \timing along toggle and \timing on / \timing off be a forced switch? Just thinking of other scripts where this isn't a problem and having to update them. The command without an argument should certainly keep the old

Re: [GENERAL] Scripting function definitions as SQL?

2008-05-11 Thread Reece Hart
On Sun, 2008-05-11 at 06:12 -0700, Postgres User wrote: Has anyone written a function that scripts out all the functions in a database as full SQL statements (Create Function.) You could pg_dump the schema in the custom format (-Fc), then call pg_restore with -l to get the TOC, grep the TOC