16

I would like to paste

  123
  456
  789

into psql and to store multi-line string in some variable (ie. :str) for later use.

Is that possible? Now I'm getting unterminated quoted string error.

mpapec
  • 50,217
  • 8
  • 67
  • 127

1 Answers1

30

A little clunky, but you can do it with \gset in conjunction with a dollar-quoted literal:

SELECT
$$123
456
789$$ AS str \gset
Nick Barnes
  • 19,816
  • 3
  • 51
  • 63