RE: SQL equivalint of #incude directive ?

Поиск
Список
Период
Сортировка
От Kevin Brannen
Тема RE: SQL equivalint of #incude directive ?
Дата
Msg-id DM6PR19MB3451C2CCF6BD06E3F83442ACA4BA0@DM6PR19MB3451.namprd19.prod.outlook.com
обсуждение исходный текст
Ответ на SQL equivalint of #incude directive ?  (stan <stanb@panix.com>)
Список pgsql-general
> From: stan <stanb@panix.com>
>
> I thought this would be common. But a quick Google only revealed what look to be workarounds.
>
> I am defining a bunch of functions, and I would prefer to store them in a separate file, which then gets "source" by
themain DB init file. 
>
> Is there a standard way to do this?

Besides what the others have said, not if you stick to SQL. This is really
more of an application level question where you have something that
will do your init/load process.

If you're willing to use other tools, then there are solutions. IIRC, your
other thread had "#include" in the title. You could build a small file with:

#include "function1.sql"
#include "function2.sql"
...

Then run it thru "cpp" and use the output of that. Might need some
post-processing if you're unlucky; I'd have to try it to see if there are
extraneous lines.

Personally, I'd probably just have a shell script that goes into that dir
and does something like:

cat *.sql | psql -d DB # and other args

and call it done...translate if you're not on a Unix-like system.

I could write a Perl program to do it because Perl can do almost anything. ;)

Your imagination is the limit.

HTH,
Kevin
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential
information.If you are not the intended recipient, or a person responsible for delivering it to the intended recipient,
youare hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or
attachedto this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately
notifyus by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them
todisk. Thank you. 



В списке pgsql-general по дате отправления:

Предыдущее
От: "Arnaud L."
Дата:
Сообщение: Bad estimates on GIN bigint[] index
Следующее
От: Kevin Brannen
Дата:
Сообщение: RE: pg_restore issues with intarray