pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedCasting varchar to bytea
3+ messages / 2 participants
[nested] [flat]
* Casting varchar to bytea
@ 2003-09-12 18:39 Dylan Milks <DMilks@greenridge.ca>
2003-09-12 19:36 ` Re: Casting varchar to bytea Ian Barwick <barwick@gmx.net>
0 siblings, 1 reply; 3+ messages in thread
From: Dylan Milks @ 2003-09-12 18:39 UTC (permalink / raw)
To: pgsql-admin
Hi. Could someone please tell me how to convert a "varchar" to a "bytea" datatype.
I have a column which contains a number stored as a varchar. I have another column of type bytea. I'm trying to insert the value of the varchar column in the bytea column, but the conversion won't work.
Something like the following:
update webuser set ccnum = ccnumstring::bytea where userid=userid;
Any ideas how to do this?
Also, I have the PGCRYPTO module and I can't get the AES algorithm to decrypt properly. It will encrypt, but not decrypt. However, I can get the BLOWFISH algorithm to work in both directions. Can someone please give me an example of decrypting using the AES algorithm?
Thanks in advance.
Dylan
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Casting varchar to bytea
2003-09-12 18:39 Casting varchar to bytea Dylan Milks <DMilks@greenridge.ca>
@ 2003-09-12 19:36 ` Ian Barwick <barwick@gmx.net>
0 siblings, 0 replies; 3+ messages in thread
From: Ian Barwick @ 2003-09-12 19:36 UTC (permalink / raw)
To: Dylan Milks <DMilks@greenridge.ca>; pgsql-admin
On Friday 12 September 2003 20:39, Dylan Milks wrote:
> Hi. Could someone please tell me how to convert a "varchar" to a "bytea"
> datatype.
>
> I have a column which contains a number stored as a varchar. I have another
> column of type bytea. I'm trying to insert the value of the varchar column
> in the bytea column, but the conversion won't work.
>
> Something like the following:
>
> update webuser set ccnum = ccnumstring::bytea where userid=userid;
>
> Any ideas how to do this?
Does
update webuser set ccnum = decode(ccnumstring::text, 'encode')
work?
Ian Barwick
barwick@gmx.net
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Casting varchar to bytea
@ 2003-09-12 19:59 Dylan Milks <DMilks@greenridge.ca>
0 siblings, 0 replies; 3+ messages in thread
From: Dylan Milks @ 2003-09-12 19:59 UTC (permalink / raw)
To: pgsql-admin
Thanks, that helped. This is what we did:
(to encode VARCHAR -> BYTEA)
update webuser set ccnum = decode(ccnumstring, 'escape') where userid=userid
(to decode BYTEA -> VARCHAR)
select encode(ccnum, 'escape') from webuser
But what about decrypting with the AES encryption algorithm?
Dylan
-----Original Message-----
From: Ian Barwick [mailto:barwick@gmx.net]
Sent: Friday, September 12, 2003 2:36 PM
To: Dylan Milks; PostgreSQL (E-mail)
Subject: Re: [ADMIN] Casting varchar to bytea
On Friday 12 September 2003 20:39, Dylan Milks wrote:
> Hi. Could someone please tell me how to convert a "varchar" to a "bytea"
> datatype.
>
> I have a column which contains a number stored as a varchar. I have another
> column of type bytea. I'm trying to insert the value of the varchar column
> in the bytea column, but the conversion won't work.
>
> Something like the following:
>
> update webuser set ccnum = ccnumstring::bytea where userid=userid;
>
> Any ideas how to do this?
Does
update webuser set ccnum = decode(ccnumstring::text, 'encode')
work?
Ian Barwick
barwick@gmx.net
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-09-12 19:59 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-12 18:39 Casting varchar to bytea Dylan Milks <DMilks@greenridge.ca>
2003-09-12 19:36 ` Ian Barwick <barwick@gmx.net>
2003-09-12 19:59 Re: Casting varchar to bytea Dylan Milks <DMilks@greenridge.ca>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox