Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why sqlca.sqlcode always 0 when use Update Statement

338 views
Skip to first unread message

Norman

unread,
Sep 22, 1999, 3:00:00 AM9/22/99
to

Hi PB Experts:
In Powerscrpit ,I try to detect update sqlcode then do something
But sqlca.sqlcode always is 0 ,Why .
My scrpit like this :
UPDATE paym040
SET surecode = :ls_surecode,
userno = :ls_sur_empno
WHERE ( paym040.empno = " ") AND
( paym040.bonusyymm = :ls_yymm ) AND
( paym040.times = :ls_times ) AND
( paym040.recid = :ls_recid ) ;

If sqlca.sqlcode <> 0 Then
Rollback;
MessageBox("","Fail.....")
Else
commit ;
MessageBox("',"success....")
End If

Thank U !

Enrico Chiaramonte

unread,
Sep 22, 1999, 3:00:00 AM9/22/99
to

Are you sure?
Sqlcode is 0 if any error occurs... for example the table not exist... or
you try to assign a string int a number field.
But if your update didn't find any row is not an error...
You can check also sqlca.sqlnrows (but is not supported from all db!) for
see how many rows you had proceded.

Enrico

Sorry for my english
Norman <nor...@taiwan.com> wrote in message
CydkfBMB$GA....@forums.sybase.com...

Mark J. Pfeifer[TeamSybase]

unread,
Sep 22, 1999, 3:00:00 AM9/22/99
to

In article <CydkfBMB$GA....@forums.sybase.com>, nor...@taiwan.com says...

> Hi PB Experts:
> In Powerscrpit ,I try to detect update sqlcode then do something
> But sqlca.sqlcode always is 0 ,Why .
> My scrpit like this :
> UPDATE paym040
> SET surecode = :ls_surecode,
> userno = :ls_sur_empno
> WHERE ( paym040.empno = " ") AND
> ( paym040.bonusyymm = :ls_yymm ) AND
> ( paym040.times = :ls_times ) AND
> ( paym040.recid = :ls_recid ) ;
>
> If sqlca.sqlcode <> 0 Then
> Rollback;
> MessageBox("","Fail.....")
> Else
> commit ;
> MessageBox("',"success....")
> End If
>
> Thank U !
>
>
>
Norman -

Have you tried getting it to fail - is that how you know it is always
zero? Does the DB get updated?

Altry try "USING SQLCA" at the end of the statement. You might also want
to take a look at the examples for dynamic sql. There are a couple
options.

HTH
Mark
TeamSybase

--

Mark Pfeifer Corporate Technology Partners, Inc.
Emerging Technology Solutions
mpfeifer@ sprynet.com www.ctpartners.com

Norman

unread,
Sep 26, 1999, 3:00:00 AM9/26/99
to

Thank U Sir :

I try "USING SQLCA" , and debug it I get result :
sqlca.sqlcode = 0
sqlca.sqldbcode = 0
sqlnrows = 1

I use INFORMIX 7.X ON-Line And PB6.0!

Mark J. Pfeifer[TeamSybase] 撰寫於文章 ...

Norman

unread,
Sep 26, 1999, 3:00:00 AM9/26/99
to

Thank U Sir :

I had tried "USING SQLCA" , and debug it ,I got result :
sqlca.sqlcode = 0


sqldbcode = 0
sqlnrows = 1

I make sure that variable 'ls_yymm' and 'ls_recid' not exist in table
"paym040".

I use PB6.0 & Informix 7.x On-Line

0 new messages