Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Perl DBI MS SQL Question

by peppiv (Curate)
on Jul 12, 2002 at 17:03 UTC ( #181344=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl DBI MS SQL Question
in thread Perl DBI MS SQL Question

Yes, of course. My apologies. But again, LIMIT does not work in MSSQL - command not found.

sub DoSearchActive { my $dbh = DBI->connect('DBI:mysql:new_db','username','password'); my $limit_3 = param("limit_3"); my $limit = param("limit"); $limit = ($limit_3 + $limit); my $spread = ($limit + 1); my $spread_2 = ($limit + 10); my $types = $dbh->selectrow_array('SELECT COUNT(status) FROM appl +icant WHERE status = "Active"'); if ($spread_2 >= $types){$spread_2 = $types} if ($spread >= $types){$spread = $types} print qq(<p style="margin-left: 0; margin-top: 20"><font size="2" + face="Arial"><b>There are $types applications listed as 'Active'.<br +>Results $spread - $spread_2 shown.</b></font></p>); print qq($table); print qq($table_headers); my $sth = $dbh->prepare('SELECT * FROM applicant WHERE status = " +Active" ORDER BY date_col DESC LIMIT ?,10'); $sth->bind_param(1, $limit, DBI::SQL_INTEGER); $sth->execute($limit) or die $sth->errstr; while (my @result = $sth->fetchrow_array()) { if ($result[21] eq '' || $result[21] eq '0000-00-00') {$shade += $default} else {$shade = $default2} if ($result[32] eq 'checked') {$fav = $something} else {$fav = ''} print qq(<tr><td><form method="POST" action="applicant_trackin +g.pl"><input type="radio" name="selection" value="all"><input type="h +idden" name="id" value="$result[0]"><br><input type="submit" value="G +O"></form></td><td bgcolor="$shade"><font size=2 face="Arial">$result +[20]</font></td><td bgcolor="$shade"><font size="2" face="Arial">$res +ult[15]</font></td><td bgcolor="$shade"><font size="2" face="Arial">$ +result[16]</font></td><td bgcolor="$shade"><font size="2" face="Arial +">$result[1], $result[2]</font></td><td bgcolor="$shade"><font size=" +2" face="Arial">$result[28]<br>$result[6]</font></td><td bgcolor="$sh +ade"><font size="2" face="Arial">$result[11]-$result[12]-$result[13]< +/font></td><td bgcolor="$shade"><font size="2" face="Arial">@result[1 +7, 18, 19]</font></td><td bgcolor="$shade"><font size="2" face="Arial +">$result[61]<br>$result[39]<br>$fav</font></td><td><font size="2" fa +ce="Arial">$result[31]$result[62]$result[63]$result[64]$result[65]</f +ont></td></tr>\n); } print qq(<tr><td colspan="10"><center><form method="POST" acti +on="applicant_tracking.pl"><input type="hidden" name="limit_3" value= +"10"><input type="hidden" name="limit" value="$limit"><input type="su +bmit" name="action11" value="Next"></form></center></td></tr>); print qq(</table>); if ($sth->rows == 0) { print qq(<br>There are no employees in the Active folder.\n\n +); } $sth->finish(); $dbh->disconnect; &DoSomethingElse; }


This allowed me to return results 1-10, then with the click of a button return 11-20, and so forth. jeffa actually helped with the incremental code. Thanks jeffa++

peppiv


Comment on Re: Re: Perl DBI MS SQL Question
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181344]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-18 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls