Baby Moose Proof

Just prove it worked day here in the Moose-pen

So yesterday I left off with my SQL looking correct but my query failing on the DBD::DBM so to-day I though I better just do a quick postette just to prove to my many readers that my code actually works.

So I all did was write up this quick little script

use DBI;
use Data::Dumper;
use Database::Accessor;
my $dbh = DBI->connect("DBI:Oracle:",
"a user id" ,
"a password");

my $new_da = Database::Accessor->new({view=>{name=>'locations'},
my $other_user = Database::Accessor->new({view=>{name=>'locations'},
conditions=>{left =>{ name => 'city',
view => 'locations'},
right =>{ value => 'Toronto'}}});

$new_da->add_condition({left =>{ name => 'city',
right =>{ value => $other_user}

which should just mimic what I had in my last post I just changed he view and element names to ones I know I had data for on my local Oracle DB. When I gave this a run I got this error;

DBD::Oracle::db prepare failed: ORA-00936: missing expression (DBD ERROR: error
possibly near <*> indicator at char 163 in \'SELECT locations.location_id,
locations.street_address, locations.postal_code,,
locations.state_province, locations.country_id FROM locations WHERE <*>.city = (
SELECT FROM locations WHERE = :p1 )\') …

So I guess in my add_condition I will need to add in the view name as well to that left part of the preticate. So I added that in;

$new_da->add_condition({left =>{ name => 'city',
++ view => 'locations'
right =>{ value => $other_user}

and it worked as I get no error in my result class and only this;

'set' => [ [ '1800','147 Spadina Ave','M5V 2L7','Toronto','Ontario', 'CA' ]],

in the set. Which is the only record on the DB with a city name of 'Toronto. Case proven.

Now I think I will have to have modify my tests so I can include an option to test with another DB, but before that I will have to look into that view problem on a condition.

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations