On 02/14/2005 11:10 AM, [EMAIL PROTECTED] said:
If I don't use strict, I get the following errors:
You should (nearly) always use 'use strict;'. It helps prevent single errors from combining into real rats' nests.
Database error: DBI::st=HASH(0x239094)->bind_param(...): attribute parameter 'SQL_VARCHAR' is not a hash ref at ./snmp.pl line 38, <INFILE> line 7867.
If I do use strict, I get the following errors:
Bareword "SQL_VARCHAR" not allowed while "strict subs" in use at ./snmp.pl line 38.
All those errors have the same cause, SQL_VARCHAR wasn't defined before it was used.
See http://search.cpan.org/dist/DBI/DBI.pm and search for /sql_types/.
Here is my modified code:
#!/usr/bin/perl
use strict;
use DBI;
# Define the SQL_* values. use DBI qw(:sql_types);
eval { $sth->bind_param( 1, $db->quote($mib), SQL_VARCHAR ); $sth->bind_param( 2, $db->quote($var), SQL_VARCHAR ); $sth->bind_param( 3, $db->quote($vartype), SQL_VARCHAR ); $sth->bind_param( 4, $db->quote($varvalue), SQL_VARCHAR );
> $sth->execute();
Use either placeholders or quote(), not both. Since all your variables are SQL_VARCHAR (the default type), you can use:
$sth -> execute( $mib, $var, $vartype, $varvalue );
instead of everything else in the eval{} block. That also means you don't need to define the SQL_* types.
};
-- Mac :}) ** I usually forward private questions to the appropriate mail list. ** Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age.