pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedextracting the sql for a function
4+ messages / 4 participants
[nested] [flat]
* extracting the sql for a function
@ 2018-08-23 17:17 Paul Tilles <paul.tilles@noaa.gov>
0 siblings, 2 replies; 4+ messages in thread
From: Paul Tilles @ 2018-08-23 17:17 UTC (permalink / raw)
To: pgsql-general
Using postgres Version 9.5
I can extract the sql for a table using
pg_dump -d database_name -s -t table_name -f table_name.sql
Is there something equivalent for extracting the sql for a function from
the database?
Paul Tilles
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: extracting the sql for a function
@ 2018-08-23 17:46 Igor Neyman <ineyman@perceptron.com>
parent: Paul Tilles <paul.tilles@noaa.gov>
1 sibling, 0 replies; 4+ messages in thread
From: Igor Neyman @ 2018-08-23 17:46 UTC (permalink / raw)
To: Paul Tilles <paul.tilles@noaa.gov>; pgsql-general
-----Original Message-----
From: Paul Tilles [mailto:paul.tilles@noaa.gov]
Sent: Thursday, August 23, 2018 1:18 PM
To: pgsql-general@postgresql.org
Subject: extracting the sql for a function
WARNING: This email originated from outside of Perceptron! Please be mindful of PHISHING and MALWARE risks.
Using postgres Version 9.5
I can extract the sql for a table using
pg_dump -d database_name -s -t table_name -f table_name.sql
Is there something equivalent for extracting the sql for a function from the database?
Paul Tilles
__________________________________________________________________________________________________________
select prosrc from pg_proc where proname = 'function_name';
You can pronamespace to WHERE clause to specify schema.
Regards,
Igor Neyman
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: extracting the sql for a function
@ 2018-08-23 18:52 Charles Clavadetscher <clavadetscher@swisspug.org>
parent: Paul Tilles <paul.tilles@noaa.gov>
1 sibling, 1 reply; 4+ messages in thread
From: Charles Clavadetscher @ 2018-08-23 18:52 UTC (permalink / raw)
To: 'Paul Tilles' <paul.tilles@noaa.gov>; pgsql-general
Hello
> -----Original Message-----
> From: Paul Tilles [mailto:paul.tilles@noaa.gov]
> Sent: Donnerstag, 23. August 2018 19:18
> To: pgsql-general@postgresql.org
> Subject: extracting the sql for a function
>
> Using postgres Version 9.5
>
> I can extract the sql for a table using
>
> pg_dump -d database_name -s -t table_name -f table_name.sql
>
> Is there something equivalent for extracting the sql for a function from the database?
>
>
> Paul Tilles
>
I don't know if there is but you can get the function definition:
SELECT * FROM pg_get_functiondef('functionname'::regproc);
or
SELECT * FROM pg_get_functiondef('functionname(list of parameters data types)'::regprocedure);
If you want to export you may use the -t and -o switches.
Regards
Charles
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: extracting the sql for a function
@ 2018-08-23 19:31 Melvin Davidson <melvin6925@gmail.com>
parent: Charles Clavadetscher <clavadetscher@swisspug.org>
0 siblings, 0 replies; 4+ messages in thread
From: Melvin Davidson @ 2018-08-23 19:31 UTC (permalink / raw)
To: Charles Clavadetscher <clavadetscher@swisspug.org>; +Cc: Paul Tilles <paul.tilles@noaa.gov>; pgsql-general
*>is there something equivalent for extracting the sql for a function from
the database? *
*Have a look at pg_extractor. It is essentially a pg_dump but with many
more options.*
*https://github.com/omniti-labs/pg_extractor
<https://github.com/omniti-labs/pg_extractor>*
On Thu, Aug 23, 2018 at 2:53 PM Charles Clavadetscher <
clavadetscher@swisspug.org> wrote:
> Hello
>
> > -----Original Message-----
> > From: Paul Tilles [mailto:paul.tilles@noaa.gov]
> > Sent: Donnerstag, 23. August 2018 19:18
> > To: pgsql-general@postgresql.org
> > Subject: extracting the sql for a function
> >
> > Using postgres Version 9.5
> >
> > I can extract the sql for a table using
> >
> > pg_dump -d database_name -s -t table_name -f table_name.sql
> >
> > Is there something equivalent for extracting the sql for a function from
> the database?
> >
> >
> > Paul Tilles
> >
>
> I don't know if there is but you can get the function definition:
>
> SELECT * FROM pg_get_functiondef('functionname'::regproc);
>
> or
>
> SELECT * FROM pg_get_functiondef('functionname(list of parameters data
> types)'::regprocedure);
>
> If you want to export you may use the -t and -o switches.
>
> Regards
> Charles
>
>
>
>
--
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2018-08-23 19:31 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-23 17:17 extracting the sql for a function Paul Tilles <paul.tilles@noaa.gov>
2018-08-23 17:46 ` Igor Neyman <ineyman@perceptron.com>
2018-08-23 18:52 ` Charles Clavadetscher <clavadetscher@swisspug.org>
2018-08-23 19:31 ` Melvin Davidson <melvin6925@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox