Thread: How do I 'include' a stored procedure in a SQL script file
Hi, All I want to do is 'include' a stored procedure (contained in another script file) into my main PostgreSQL database creation script file so that it can get defined/declared before I define my triggers to call it. It seems such a simple thing but I don't seem to be able to find any examples or documentation. Please help!
An .sql file is just a list of sql you can just as well enter when running psql.
If you had the psql prompt open, what would you type to execute the commands in an .sql file, limited to 'true' sql and not psql specific commands
If you know that you know which lines to add to the .sql file
Hope this helps
Regards,
Serge fonville
On Wed, Jan 7, 2009 at 12:41 PM, Donna Rudd <donna@therudds.co.uk> wrote:
Hi,
All I want to do is 'include' a stored procedure (contained in another
script file) into my main PostgreSQL database creation script file so that
it can get defined/declared before I define my triggers to call it. It seems
such a simple thing but I don't seem to be able to find any examples or
documentation. Please help!
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
In response to Donna Rudd : > Hi, > All I want to do is 'include' a stored procedure (contained in another > script file) into my main PostgreSQL database creation script file so that > it can get defined/declared before I define my triggers to call it. It seems > such a simple thing but I don't seem to be able to find any examples or > documentation. Please help! Your main script file is executed with psql? You can use \i <other_file> within your main-file. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
Currently I'm using PGAdmin to create everything, but I need to create a script file to create the schemas and the tables to ultimately run outside of PGAdmin. Since I have triggers, I need to 'load in' the (long) stored/triggered procedures during this process (ie 'call or 'include' another file with the stored procedure in it). It's this 'call' that I can't get to work. The \i <other_file> doesn't work (syntax error) within this main file. I just want to tell it to go and read in this other file. Note: I'm assuming the same file should run wthin PGAdmin and then outside it. Andreas Kretschmer-4 wrote: > > In response to Donna Rudd : >> Hi, >> All I want to do is 'include' a stored procedure (contained in another >> script file) into my main PostgreSQL database creation script file so >> that >> it can get defined/declared before I define my triggers to call it. It >> seems >> such a simple thing but I don't seem to be able to find any examples or >> documentation. Please help! > > Your main script file is executed with psql? You can use \i <other_file> > within your main-file. > > > Andreas > -- > Andreas Kretschmer > Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) > GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general > > -- View this message in context: http://www.nabble.com/How-do-I-%27include%27-a-stored-procedure-in-a-SQL-script-file-tp21330479p21412577.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On Monday 12 January 2009 3:14:56 am DonnaR wrote: > Currently I'm using PGAdmin to create everything, but I need to create a > script file to create the schemas and the tables to ultimately run outside > of PGAdmin. Since I have triggers, I need to 'load in' the (long) > stored/triggered procedures during this process (ie 'call or 'include' > another file with the stored procedure in it). It's this 'call' that I > can't get to work. The \i <other_file> doesn't work (syntax error) within > this main file. I just want to tell it to go and read in this other file. > Note: I'm assuming the same file should run wthin PGAdmin and then outside > it. > Have you tried: psql -d some_db -U some_user -f trigger_func.sql \i only works inside of psql. -- Adrian Klaver aklaver@comcast.net