lampros21_7 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; use DBI; my $dbh = DBI->connect( "dbi:SQLite:dbname=mydatabase.db", "", "" )|| + die "Cannot connect: DBI"; my @pages; # Create the table and make the columns my $column_creator = join(' INTEGER,', @pages) . ' INTEGER'; my $create_columns = "CREATE TABLE mytable ($column_creator)"; $dbh->do($create_columns); my $id_number = 1; my $current_column; my @splitted_string1; $current_column = $db->query("SELECT text FROM data WHERE id = '$id_n +umber'")->list; print $current_column; @splitted_string1 = split " ", $current_column; }
When i run this script the first time the problem is that it cannot write the value from my database file to the $current_column variable. The "text" table is already in my file. It creates the table "mytable" but all it has is the column names.
If i run it for a second time it gives DBD::SQLite::db do failed: table mytable already exists(1) at dbdimp.c line 268 at xxx.pl line xx. What is really weird though is that it actually prints the $current_column variable this time. This error really baffles me. Does anyone know whats happening? Thanks UPDATE: The @pages array has been declared and shebang fixed.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Weird uninitialized value error
by helphand (Pilgrim) on Feb 12, 2006 at 18:55 UTC | |
by lampros21_7 (Scribe) on Feb 12, 2006 at 19:19 UTC | |
by GrandFather (Saint) on Feb 12, 2006 at 19:51 UTC | |
by helphand (Pilgrim) on Feb 12, 2006 at 19:49 UTC | |
Re: Weird uninitialized value error
by trammell (Priest) on Feb 12, 2006 at 18:56 UTC |