blackadder-
what was the error message you received?
if you're having trouble coding up it up, here's a shot at it:
sub LookupServerID
{
# get the servername that was passed into the function
my $serverName = shift;
# build the sql to select the server_id
my $sql = "select server_id from server_tbl where server_name = '$
+serverName'"
# execute the sql with the open $perms_db object
if ($perms_db->Sql($sql))
{
# error during sql!
print "Error:" . $perms_db->Error() . "\n";
# return a value anyway and let the caller check for -1
return -1;
}
# process the result set
$perms_db->FetchRow();
# get the first row within the result set
my(%data) = $perms_db->DataHash();
# return the server_id to the caller
return $data{'server_id'};
# PLEASE NOTE: this code does not watch out for the case where th
+e server_name does not exist. you should code for this case.
}
You should really take a look at
this page for a good tutorial for Win32::ODBC.There's a couple of examples there from the guys who wrote the module.
OK there champ- take another whack at it.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.