Re: insert a text file into a variable in order to insert into a bytea column

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Arthur Lewis <arthur(dot)lewis(at)hypermediasystems(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: insert a text file into a variable in order to insert into a bytea column
Date: 2016-01-28 23:01:44
Message-ID: 56AA9DD8.104@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 01/28/2016 02:36 PM, Arthur Lewis wrote:
> Hi David,
> Yes you're correct. The problem is caused by the back-ticks (`) Here is what I found in the docs about back-ticks
>
> "Within an argument, text that is enclosed in backquotes (`) is taken as a command line that is passed to the shell. The output of the command (with any trailing newline removed) replaces the backquoted text."

Huh, I missed that in reading the docs.

So:

test-# \set stext `cat test.txt`
test-# \echo :stext

Test

second line

test-# \set stext `cat test.txt` '\n'

test-# \echo :stext

Test

second line


test-#

New lesson learned.

>
> Arthur Lewis
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Joseph Krogh 2016-01-29 00:05:54 GROUP BY overlapping (tsrange) entries
Previous Message Arthur Lewis 2016-01-28 22:36:02 Re: insert a text file into a variable in order to insert into a bytea column