perl-unicode

RE: UTF-16 -> UTF-8

2001-11-21 09:04:18
Philip,

There was indeed a mistake in the invocation of the execute method of the 
connection object (it's quite stupid indeed. Allow me not
to go into details... The stupid thing is that the instruction works OK if you 
write literals). I've changed that and now I can
write to the DB, but the values are not properly recognized. If you try to open 
the file I attached to my prior mail in Word, you'll
see exactly what I see in the DB record.

Once again, thank you for your time...
Regards

Rui


On Wed, 21 Nov 2001 15:14:38 -0000, in perl.unicode you wrote:

Still can't write to the BD though. The append SQL instruction has no 
effect.

It looks wrong to me, too.

use Unicode::String qw(utf8 latin1);

You don't need to import 'latin1' if you're not going to use it. (It's
not going to hurt, but it's not needed, either.)

open(FICH1,"fich1.txt")||die"Nao foi possivel abrir o ficheiro fich1.txt 
$!";
open(FICH3,">fich3.txt")||die"Nao foi possivel abrir o ficheiro fich3.txt 
$!";

Ah good, you've got $! in there, now.

$conn->open($constr);

Shouldn't you check whether your DB open succeeded?

    $sql =  "INSERT INTO Tipo_Referencia ( Descricao ) SELECT VALUES 
('$palavra_utf16');";

I think the 'SELECT' should not be there. Just 'INSERT INTO table
(columns) VALUES (literals)'. (And with DBI I leave off the semicolon at
the end; I don't know what ADODB.Connection wants.)

    print FICH3 $palavra_utf16;
    $conn->execute($sql,,,adExecuteNoRecords);

Why don't you write

    $conn->execute($sql, adExecuteNoRecords);

? The two extra commas don't change the fact that you're only passing
two arguments to execute.

Does this function give you a way to check the result? Again, I don't
know ADODB.Connection. But maybe the database itself can tell you what
went wrong? SQL syntax error, database connection not there, wrong
password, whatever....

close(FICH3);

You should also check whether the close succeeded, at least on files
that you opened for writing. For example, if you get a disk full error,
then the close will fail and you can examine $! then. (You could also
check the return value of every print() you do, in order to catch this
error earlier, but in practice nobody does that. But you should still
check your close.)

Cheers,
Philip


<Prev in Thread] Current Thread [Next in Thread>