[Gambas-user] Subst$ with a Variant array of values

Tobias Boege taboege at gmail.com
Sun May 19 14:06:32 CEST 2019

On Sun, 19 May 2019, Bruce wrote:
> Aaaarrgghh! SO CLOSE :-(
> Some of the string criteria need to be $quoted in order for it to work the
> way I need it. (Surnames with apostrophes and strings with embedded spaces
> ARE quoted correctly according to the help, but as I am trying to use the
> query in a bash script
> 	psql -d auct2019 -F '|' -A -o '/tmp/gambas.500/12311/ext.tmp' -c 'select *
> from sales where house = E'D KB' and errcode = 124;'
> needs to be
> 	psql -d auct2019 -F '|' -A -o '/tmp/gambas.500/12311/ext.tmp' -c 'select *
> from sales where house = E$$D KB$$ and errcode = 124;'
> I can't find a way to get postgres to tell gambas to $quote string values.
> I'll start looking at the gb.db Connection.Subst code to see if I can find
> something.
> b

If you can't avoid the shell (by using Exec which doesn't have quoting
problems) you could

  Shell "psql -d auct2019 -F '|' -A -o '/tmp/...' -c " & Shell$(sSql)

That should just apply whatever quoting the shell needs to read sSql as you
intended on top of the all quoting the database needed.

The $$ quoting syntax is just to make strings more human-readable in case
there are many apostrophes or other characters which have to be escaped
inside, if I understood correctly. So there is no technical need to have
these special $$s, right?

If you do need it, I would suggest you write your own PGSubst$() with a
"$1" placeholder in addition to the usual "&1" style.


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the User mailing list