I imagine its the quoting.
I would use qq| for the sql and Form.pm sub quote for the data.
I like the idea of a separate table for anything extra makes upgrades safer.
We use <table_name>_xtras so for parts we have a parts_xtras.
Here is the code I use:
for (qw(vndr_invoice monthly_bill )) {
$form->{$_} = $form->quote( $form->{$_} );
}
$query = qq|
INSERT INTO parts_xtras (parts_id,vndr_invoice,monthly_bill)
VALUES
(?,?,?);
|;
$sth = $dbh->prepare($query);
$sth->execute(
$form->{id},
$form->{vndr_invoice},
$form->{monthly_bill}
) || $form->dberror($query);
}
}
I really enjoyed this book:
http://shop.oreilly.com/product/9781565926998.do
Cheers
turtle
> The situation is that multiple Amazon product identifiers (ASIN) can be
> assigned to one of our products (parts). We have a custom field
> ("asin") on the Add Part screen. When data reaches *ic.pl*, the code
> (snippet) below is exercised to insert a row in the parts table. Since
> there can be multiple ASINs, it would be better to store them in a
> separate table with a foreign key.
>
> I'm an experienced Python developer, but a novice at Perl. The last
> three lines of code are causing the queries to not work. What syntax
> should I introduce into ic.pl to store ASINs in a separate database table?
>
> Thanks.
> Brian
>
>
> $sth = $dbh->prepare($query);
> $form->{partnumber} = trim($form->{partnumber});
> $form->{description} = trim($form->{description});
>
> <snip>
>
> $sth->execute(
> $form->{partnumber}, $form->{partname},
>
> <snip>
>
> $form->{expense_accno}, $form->{obsolete},
> $form->{image}, $form->{drawing},
> $form->{microfiche}, $partsgroup_id,
> $form->{id}
> ) || $form->dberror($query);
>
> * $query = "insert into part_asin (part_id, asin) values (?, ?)";**
> ** $sth = $dbh->prepare($query);**
> ** $sth->execute( $form->{id}, 'B005QUQP8U');**
> ***
>
> Activus Technologies
> Brian Wolf
> Phone: 410.367.2958
> Email: [email protected]
>
> * Integrated Payment Solutions
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk_______________________________________________
> Ledger-smb-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel
>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel