473,382 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how to solve the error " DBD::SQLite::db selectall_arrayref failed: unrecognized"?

47
Can you give me a hint that how to print out the 2d array

package DataLayer;
sub nextWords {
my $lang_size = languages();
for my $id(1 .. $lang_size ){
my ($id, $offset) = @_;
my @array = ();
my $statement = $db->selectall_arrayref("select word from words
left outer join language
on words.languageId = language.languageId
where words.languageId = $id
order by word asc
limit 10 offset $offset;");

my @main= ();
foreach my $i (@$statement)
{
push(@main, @{$i}[0]);
}
@array[$id] = [@main];

return @array;
}
}

and I create a test class in order to test the result.

$object = DataLayer->new();


print "Words :\n";

for my $id(1 .. 3 ){

print "=======ID = " . $id . "=======\n";
my $self = 0;
NAME: while (1 > 0){
my @newwordsList = $object->nextWords($id,$self);

$self+= 10;
foreach my $k (@{@newwordsList[$id]}) {

print $k . "\n";
}
print "\n";
if (!@{@newwordsList[$id]}[0]) {
last NAME;
}
}
}

and it gives me an error DBD::SQLite::db selectall_arrayref failed: unrecognized token: "0x156b16c" at C:/

please help .. thank you very much
Feb 28 '11 #1
11 3986
rovf
41
Did you have strict and warnings enabled?
Feb 28 '11 #2
Wiinie
47
yes i did have both
use strict;
use warning;
Feb 28 '11 #3
rovf
41
I guess you mean "use warnings", and not "use warning"....

This is strange, because I would have expected that you should get warning (for example) for

push(@main, @{$i}[0]);

Which Perl version are you using?
Feb 28 '11 #4
Wiinie
47
I did not get any warnings. and i use the latest version.
anything in the codes are ok. i just have a problem with printing the result. can you help me to print the result

thanks
Feb 28 '11 #5
rovf
41
Well, since the error is issued by selectall_arrayref, did you verify that $id and $offset has a reasonable value? I see that you get them from @_, so it might be that they are already garbage at this point.

Further, this construct is weird:


for my $id(1 .. $lang_size ){
my ($id, $offset) = @_;
...
}


You have a variable $id, and in the loop you "hide" it with another variable of the same name, $id (which you incidentally also get from @_). It is not *forbidden* doing it, but is this REALLY what you want to achieve?
Feb 28 '11 #6
Wiinie
47
lol, sorry about that,

for my $id(1 .. $lang_size ){
my ($id, $offset) = @_;
...
}



i just wanna get the size of language() which is (1,2,3)
so i can loop 3 times with different of languages.

can you give me a specific code to print it out because i try several ways, i am still stuck with selectall_arrayref .. please help.. thanks
Feb 28 '11 #7
rovf
41
That's not the point. I would like to know, why you use the SAME name for two DIFFERENT local variables? This really looks like a bug. And why are you assigning @_ *INSIDE* a loop, though it doesn't change? Your code, as posted, is equivalent to the following:


my ($id, $offset) = @_;
for my $this_variable_is_not_used_anyway (1 .. $lang_size ){
my @array = ();
...
}


Are you aware that in your original code, $id has the SAME value on every run through the loop, and that it does NOT have the values 1,2,3...? Basically, you are looping three times, but every time you issue the query with exactly the same values for $id and $offset. This is not forbidden, but certainly looks like a bug.
Mar 1 '11 #8
Wiinie
47
the idea i did that cuz i just wanna to increase the offset 10 each until it goes through each language
Mar 1 '11 #9
rovf
41
I don't question your "idea", but your "$id" (pun intended). No matter how many languages your have, $id will be the SAME value in each iteration.

BTW, you didn't comment yet on my earlier posting, where I asked you: "did you verify that $id and $offset has a reasonable value?"
Mar 1 '11 #10
Wiinie
47
ya i did.. but can u help me to print it out... i am really want to print out.. i cannot figure out how to print out the result..
Mar 1 '11 #11
rovf
41
So what where the values of $id and $offset right before doing the call to selectall_arrayref?

IMO it doesn't make sense discussing the result, as long as you get the error message in selectall_arrayref.
Mar 1 '11 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

59
by: Jeff Bowden | last post by:
For ease of configuration and other reasons, I would like for my single-user GUI app to be able to use postgresql in-process as a library accessing a database created in the users home directory. ...
48
by: Tony | last post by:
How much bloat does the STL produce? Is it a good design wrt code bloat? Do implementations vary much? Tony
2
by: hypermonkey2 | last post by:
Hi there! I am using the "shelve" module in a script to save information in between runtime sessions of the program. (its a sort of data collector, so its important to hold on to anything computed...
15
by: Kurda Yon | last post by:
Hi, I try to "build" and "install" pysqlite? After I type "python setup.py build" I get a lot of error messages? The first error is "src/ connection.h:33:21: error: sqlite3.h: No such file or...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.