From: | Arthur Lewis <arthur(dot)lewis(at)hypermediasystems(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, 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 22:36:02 |
Message-ID: | 1374628469.7191030.1454020562643.JavaMail.root@hypermediasystems.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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."
Arthur Lewis
----- Original Message -----
From: "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "Arthur Lewis" <arthur(dot)lewis(at)hypermediasystems(dot)com>
Cc: "Adrian Klaver" <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-sql(at)postgresql(dot)org
Sent: Thursday, January 28, 2016 1:57:38 PM
Subject: Re: [SQL] insert a text file into a variable in order to insert into a bytea column
On Thu, Jan 28, 2016 at 2:08 PM, Arthur Lewis < arthur(dot)lewis(at)hypermediasystems(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2016-01-28 23:01:44 | Re: insert a text file into a variable in order to insert into a bytea column |
Previous Message | David G. Johnston | 2016-01-28 21:57:38 | Re: insert a text file into a variable in order to insert into a bytea column |