Re: insert a text file into a variable in order to insert into a bytea column - Mailing list pgsql-sql

From David G. Johnston
Subject Re: insert a text file into a variable in order to insert into a bytea column
Date
Msg-id CAKFQuwY8hGODYwA9eEp4dAUo3VtpVie8He4J9ZdJ22CskzJ22w@mail.gmail.com
Whole thread Raw
In response to Re: insert a text file into a variable in order to insert into a bytea column  (Arthur Lewis <arthur.lewis@hypermediasystems.com>)
Responses Re: insert a text file into a variable in order to insert into a bytea column  (Arthur Lewis <arthur.lewis@hypermediasystems.com>)
List pgsql-sql
On Thu, Jan 28, 2016 at 2:08 PM, Arthur Lewis <arthur.lewis@hypermediasystems.com> wrote:
postgres=> \set stext `cat file.txt`
postgres=> select octet_length(:'stext');
 octet_length
--------------
        53603

in my shell I did the following:
$ ls -l file.txt
-rw-rw-r-- 1 alewis alewis 53604 Jan 27 08:30 file.txt

I'm still one byte short.  So the problem has to be either the \set command chomping it or cat.  I just tested cat and that seems to be working.


​Or the "back-ticks" implementation...

David J.​
 

pgsql-sql by date:

Previous
From: Arthur Lewis
Date:
Subject: Re: insert a text file into a variable in order to insert into a bytea column
Next
From: Arthur Lewis
Date:
Subject: Re: insert a text file into a variable in order to insert into a bytea column