[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: SQL equivalint of #incude directive ?
From:       Francisco Olarte <folarte () peoplecall ! com>
Date:       2019-08-31 8:11:38
Message-ID: CA+bJJbx=QbMx+z_8AH4h=E-bfPbsBmUaU4PtD11F13bLMpppjw () mail ! gmail ! com
[Download RAW message or body]

Stan:

On Fri, Aug 30, 2019 at 3:49 PM stan <stanb@panix.com> wrote:
...
> I am defining a bunch  of functions, and I would prefer to store them in a
> separate file, which then gets "source" by the main DB init file.
> Is there a standard way to do this?

I assume you mean "standard for postgres", AFAIK there is not even a
(multidb) standard way to feed an sql script to a server (content of
queries / results are standard, how to send them / get them from the
server is not ).

\i in psql has been pointed. I do not know if this is one of your
"workarounds", but what I normally do for this is trat the "init"
script as a program and "make" it. I've done it using many of the
preprocessor freely available around ( i.e. m4, cpp ) and also using a
perl program ( but this is becuase I'm quite fluent in it and it makes
some thing easier ), and even doing "cat *.sql | psql" and naming the
scripts appropiately. You'll probably have it easier going by that
route ( generating the sql script from chunks using a tool of your
choice, it's just a big text chunk and you can easily debug it with a
text editor ), and it is not that complex.

Francisco Olarte.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic