|
|
sybperl-l Archive
Up Prev Next
From: Dennis Domingo <bigmango at yahoo dot com>
Subject: problems with Sybase::BLK?
Date: Jun 17 2002 5:23PM
Hi.
I get these errors when using Sybase::BLK
bester::~/src/backend-scripts/service/search/topmatches$
mytestbcp.pl
The number of rows in the table SearchPhrases: 0
mytestbcp.pl: 06172002-0942 - More columns passed to
blk_rowxfer() than were alloc
ated with blk_init() at
/usr/local/depot/perl-5.6.0/lib/site_perl/5.6.0/sun4-solar
is-thread/Sybase/BLK.pm line 539, chunk 1.
mytestbcp.pl: 06172002-0942 - BCPing topmatches file
failed at ./mytestbcp.pl line
47.
I have the following file that I am bcping into the
database.
bester::~/src/backend-scripts/service/search/topmatches$
cat -v tm.bcp
4|2001|3|3120|cdburn01|23509
4|2001|3|3120|kazaa|14531
4|2001|3|3120|winzip|13642
4|2001|3|3120|winamp|8261
4|2003|3|3120|osx|7861
4|2001|3|3120|ftp|7847
4|2001|3|3120|divx|7651
4|2001|3|3120|icq|5883
4|2001|3|3120|winrar|5359
4|2001|3|3120|games|5324
bester::~/src/backend-scripts/service/search/topmatches$
cat -v tm.bcp | wc -l
10
As you can see, the file has 10 records with 6 fields
delimited by |
The table I am doing the bulk copy into is the
following .. I have a Sybase 12.5.x database
siteadm-SF_X_STG_DEV1 1>sp_cols SearchPhrases;
|Column name |Type |Null
Rule |Default
|--------------------|--------------------|----------
------------------------------|------------------------------
|siteId |int |No
|
|nodeId |int |No
|
|editionId |int |No
|
|pageTypeId |int |No
|
|searchPhrase |univarchar(128 ) |No
|
|searchHits |int |No
|
(return status = 0)
My code that I run is
18 my $bcp = new Sybase::BLK "siteadm",
"siteadm", "SF_X_STG_DEV1" ;
19 die "db login failed for BLK" unless defined
$bcp;
20
21 # get file sizes
22 my $bcp1Size = (stat($bcp1File))[7];
23 my $restype;
24 my $count;
25
26 # testing the connection
27 $bcp->ct_execute("select count(searchHits)
from SearchPhrases");
28 # Retrieve the result sets
29 while($bcp->ct_results($restype) ==
CS_SUCCEED) {
30
31 # Skip non-fetchable results:
32 next unless $bcp->ct_fetchable($restype);
33
34 # Retrieve actual data rows:
35 while(($count) = $bcp->ct_fetch) {
36 print "The number of rows in the table
SearchPhrases: $count\n";
37 }
38 }
39 if (-e $bcp1File && $bcp1Size > 0) {
40 # now we BCP the topmatches file into the
db into 'SEARCHES TABLE'
41 $bcp->config(INPUT => $bcp1File,
42 OUTPUT =>
$ProcessTMConf::TMBCPTABLE,
43 SEPARATOR => '|',
44 RECORD_SEPARATOR => '\n'
45 #BATCH_SIZE=>
$ProcessTMConf::BATCH_SIZE,
46 # REORDER => { 1=> 'siteId',
47 # 2=> 'nodeId',
48 # 3=> 'editionId',
49 # 4=> 'pageTypeId',
50 # 5=>
'searchPhrase',
51 # 6=> 'searchHits'
52 # }
53 );
54 unless($bcp->run) {
55 die "BCPing topmatches file failed";
56 };
I am not sure why it is failing. I understand that
the blk_init and blk_rowxfer are defined in CTlib. And
that BLK inherits the OO model, but I dont know why
it doesnt work.
Thanx.
dd
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
|