Hi Shao,

Maybe you are looking about how to pass SQL statements via a shell
here-document:

psql [options] <<EOF
SELECT *
FROM foo1
WHERE col='val';

SELECT * FROM foo2;
EOF

Eventual bash variable within the here-document can be interpolated.
To avoid that just quote the first instance of EOF

psql [options] <<'EOF'
SELECT *
FROM foo1
WHERE col='val';

SELECT * FROM foo2;
EOF


Il giorno mar 21 apr 2020 alle ore 21:16 Shaozhong SHI <
[email protected]> ha scritto:

> It is quite appealing to wrap up a large block of psql codes as a string
> and execute the string.
>
> And, how to deal with quotes within quotes.
>
> I tried short text strings.  It worked well, but it does not seem to work
> with very long strings in different lines.
>
> Can anyone shed light on this?
>
> Regards,
>
> Shao
> _______________________________________________
> postgis-users mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to