[Fwd: Re: non-ascii text]
Posted in 2003
This is a multi-part message in MIME format.
--------------060203030202000101040504
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
I saw the question on dbi-users@perl.org and accidentally replied to
just the questioner and not the mailing list too - sorry.
The questioner also asked the question on the comp.databases.informix
news group, so I'm copying my answer there too; there shouldn't be a
need for others to chip in unless my outline answer is grossly wrong.
--
Jonathan Leffler (jleffler@earthlink.net, jleffler@us.ibm.com)
#include <disclaimer.h>
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
--------------060203030202000101040504
Content-Type: message/rfc822;
name="Re: non-ascii text"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Re: non-ascii text"
X-Mozilla-Status2: 00800000
Message-ID: <3ED6DC09.7040709@earthlink.net>
Date: Thu, 29 May 2003 21:20:25 -0700
From: Jonathan Leffler <jleffler@earthlink.net>
Organization: Chaotic Sputterings
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Brian McLaughlin <bmclaugh@georgefox.edu>
Subject: Re: non-ascii text
References: <10E6C696E40B654AB7B5A934DB181F9A01A944B6@foxmail.campus.georgefox.edu>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Brian McLaughlin wrote:
> I have two Informix servers -- a production box and a test box. Passwords
> to our vendor's software are stored encrypted in a char(20) column. I want
> to copy passwords from production to test. I've written a perl script to
> fetch the password from production and I want to put that password into the
> same table/column on the test box. The problem is that the encrypted
> passwords have non-ascii characters.
>
> update user_mst set access_code = "blahblah" where id="235112">
> This update command gives me this:
> DBD::Informix::db do failed: SQL: -202: An illegal character has been found
> in the statement. at ./3000create.pl line 27.
>
> How can I copy the contents of one char column to another if the data
> contains "illegal characters" ??
Read the value into a Perl variable, and then use the Perl variable as
an argument to the UPDATE...
$st_prod = $db_prod->prepare("SELECT access_code, id FROM user_mst");
$st_prod->execute;
$st_test = $db_test->prepare("UPDATE User_MST SET Access_Code = ?
WHERE Id = ?");
($prod_password, $prod_id) = $st_prod->fetchrow_array();
$st_test->execute($prod_password, $prod_id);
I'm assuming you have RaiseError = 1 or you should add error handling
code; you should also loop on the fetch and execute.
The technique is hardly Informix-specific either.
--
Jonathan Leffler (jleffler@earthlink.net, jleffler@us.ibm.com)
#include <disclaimer.h>
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
--------------060203030202000101040504--