[freetds] DBCOUNT returns -1

chiang.tan at truenergy.com.au chiang.tan at truenergy.com.au
Sun Jul 23 22:52:03 EDT 2006


Hi,
I'm using Sybperl (via freeTDS 0.63) to connect to MSSQL 2000. 

        $sql = "delete db2..tmp_table from db2..tmp_table a, 
db1..final_table b 
                      where a.key1 = b.key1
                      and  a.key2 = b.key2
                      and  a.key3 = b.key3";
        $syb_logon->dbcmd( $sql );
        $syb_logon->dbsqlexec;
        $del_cnt = $syb_logon->DBCOUNT;
        print STDERR "Excluding $del_cnt rows already in production 
dataset\n";

        $sql = "insert into db1..final_table select * from 
db2..tmp_table";
        $syb_logon->dbcmd( $sql );
        $syb_logon->dbsqlexec;
        $ins_cnt = $syb_logon->DBCOUNT;
        print STDERR "Inserted $ins_cnt new rows into production 
dataset\n";


When I run the perl script, I got the following error
        Excluding -1 rows already in production dataset
        DB-Library error:
                Attempt to initiate a new SQL Server operation with 
results pending.
        Operating-system error:
                OpenClient
        Inserted -1 new rows into production dataset

When I look at the tables. 
        The deletion from the 1st sql was successful, but the insert sql 
was not. 
        DBCOUNT returns -1 for both sql

How can I get DBCOUNT to return the correct number of rows 
deleted/inserted?
How can I remove DB-Library error, so that insert can statement can run 
properly?

Cheers,
Chiang Tan
-- 
We're excited by gas & electricity.NOTICEThis email and any files transmitted with it may be confidential and are intended solely for the use of the individual or entity to whom they are addressed. Any confidentiality is not waived or lost because this email has been sent to you by mistake. This email may contain personal information of individuals, and be subject to Commonwealth and/or State privacy laws in Australia.This email is also subject to copyright. If you are not the intended recipient, you must not read, print, store, copy, forward or use this email for any reason, in accordance with privacy and copyright laws. If you have received this email in error, please notify the sender by return email, and delete this email from your inbox.The recipient should check this email and any attachments for the presence of viruses. We do not accept liability for any computer virus, data corruption, delay, interruption, unauthorized access or unauthorised amendment.TRUenergy Austra
 lia Pty Ltd ABN 96 071 611 017

Message  protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au/mg





More information about the FreeTDS mailing list