Hi All,
I am new to perl ,I am stuck with below issues....
I am querying to database to fetch a field for a user through a subroutine. Check the below code....
1. if user is found in Database then subroutine returns the result. The print statement after the soubroutine call print the result. (expected)
2. but if user is not found or the the column vlaue is empty for that user , then my program is getting terminated before return the result to the subroutine ....so the print statement after the subroutine call is not being exceuted...

Please help me...
Here is the code


#!/usr/bin/perl</br> use DBI; $database = "idm"; $username = "idm"; $password = "idm"; $hostname = "localhost"; $output = &connectCBMS(900010); --> calling a subroutine print $output; -- printing the result sub connectCBMS { $db = DBI->connect("DBI:Oracle:host=$hostname;sid=$database",$username +,$password); unless($db) { #LogResult("(ERROR) Failed to connect to $DIRHOST."); #ReportFailure("(ERROR) Failed to connect to $DIRHOST."); print "(ERROR) Failed to connect to $hostname."; return 0; } my ($staffcode) = @_; # Execute a Query my $sql = qq{ SELECT REGISTRATIONDAY FROM CBMS WHERE STAFFCODE = ? }; my $sth = $db->prepare( $sql ); $sth->bind_param( 1, $staffcode ); $sth->execute(); my $row; while ( $row = $sth->fetchrow_array( ) ) { return $row; } $sth->finish(); $db->disconnect(); exit(0); }
Thanks Suriya

In reply to Help me ! I am stuck ! PERL DBI by raja.b4u

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.