multiple sql results to shell

From: Mark Lybarger <mlybarger(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: multiple sql results to shell
Date: 2017-10-23 14:08:04
Message-ID: CAKM-gm+RQmkrO4GytBMN676P5f9cj=1TzdZXXZBWEn=sASvjeQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have this bash/sql script which outputs some curl commands. the
backticks causes it to get interpreted by the shell. This works fine if
there is one result, but when there are many rows returned, it looks like
one shell command.

any help on getting multiple rows returned to be executed by the shell
would be appreciated!

thanks!

`psql -P "tuples_only=on" -h ${DB_HOST} -d ${DB_NAME} -U ${DB_USER} -c
"select 'curl -X POST http://${REGISTER_HOST}:8080/' || source_id ||
'/${MT}/' || model || '/' || site || '/backoffice/register' from
myschema.events where source_id = $SOURCE_ID and ineffective_date is null"`

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2017-10-23 14:19:03 Re: multiple sql results to shell
Previous Message Önder Kalacı 2017-10-23 13:28:43 Is it safe to create foreign keys beforehand when logical replication is used?