Hi Rajpreet!

Here are a few general comments about your code.

On Thursday 21 Jan 2010 13:56:42 Rajpreet wrote:
> Greetings,
> 
> I am trying to read a message from MQ series in perl and want to
> update SYbase with this message. Even though ,the update when directly
> run from command line, works fine. However, if I try to execute my
> perl script, I get an error saying "Database Error Message received
> 'DBD::Sybase
> 
> ::st execute failed: Server message number=105 severity=15 state=2
> 
> line=1 server=S02TRS0 text=Unclosed quote before the character string
> '231126407354223055'."
> 
> Below is the code snippet.
> 
> 
>  my $msgDescRef = $MsgObj->MsgDesc;

You shouldn't start a variable name with a capital letter - use $msg_obj or 
$msgObj instead.

>         my $UniqMsgTag = $$msgDescRef{"CorrelId"};

Do <<< $msgDescRef->{CorrelID} >>> instead of <<< $$msgDescRef{"CorrelId"} 
>>>. The former is more readable.

>         log ("UniqueTag is $UniqMsgTag"); # This variable has value
> 231126407354223055
> $UniqTag ="$UniqMsgTag";

use strict; use warnings;

And why are you assigning to <<< "$UniqMsgTag" >>> instead of <<< $UniqMsgTag 
>>>?

> my $sql="update my_table set UniqueTag='$UniqMsgTag' where id=123";

Now you have an SQL injection attack, there. See:

* http://community.livejournal.com/shlomif_tech/35301.html

* http://en.wikipedia.org/wiki/SQL_injection

Use placeholders or something.

> RunSql("$sql"); # This a function which executes the query using DBI

<<< RunSql($sql); >>> should be good enough. No need to put inside a string 
and interpolate. Of course in your case, you should use a placeholder.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Stop Using MSIE - http://www.shlomifish.org/no-ie/

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to