Search Postgresql Archives

Re: SELECT d02name::bytea FROM ... && DBI::Pg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthias:

On Thu, Oct 10, 2019 at 1:25 PM Matthias Apitz <guru@xxxxxxxxxxx> wrote:
> I can SELECT && print a column in hex with:
> pos71=# select d02name::bytea from d02ben where d02bnr = '00001048313' ;
> ...
>  \x50c3a46461676f67697363686520486f6368736368756c65205765696e67617274656e2020 ...
>
> but when I use the same in Perl DBI::Pg with:
> $sth=$dbh->prepare( "select d02name::bytea from d02ben where d02bnr = '00001048313'");
...
> It prints the UTF-8 string and not the hex string:

May be because perl does not need the contents in hex DBI converts it
to a native string, which is very similar to a "bytea" inside the db (
not in the wire protocol, but it does a similar thing for numbers ).

Notice once you have a string in perl it is trivial to convert it to hex:
$ perl -e 'print(unpack("H*", "1234ABCD"),"\n")'
3132333441424344
$ perl -e 'print(unpack("H*", "día año"),"\n")'
64c3ad612061c3b16f

Francisco Olarte.






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux