Re: SQL equivalint of #incude directive ? - Mailing list pgsql-general

From Francisco Olarte
Subject Re: SQL equivalint of #incude directive ?
Date
Msg-id CA+bJJbx=QbMx+z_8AH4h=E-bfPbsBmUaU4PtD11F13bLMpppjw@mail.gmail.com
Whole thread Raw
In response to SQL equivalint of #incude directive ?  (stan <stanb@panix.com>)
Responses Re: SQL equivalint of #incude directive ?
List pgsql-general
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.



pgsql-general by date:

Previous
From: Morris de Oryx
Date:
Subject: Re: Aggregate functions on groups
Next
From: stan
Date:
Subject: Problems with using function input paramaters