× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Nathan,

I'm not really sure what you mean, so please forgive me if I'm way off base. I recently (I was just farting around, honestly) wrote a PHP script as a kind-of replacement for the "Run SQL Scripts" option in iNav. It's a pain in the butt to open up iNav, since I rarely use it, but I pretty much always have a browser open.

At any rate, all I did was write a function like this (this is PHP):

function db_print_table($stmt) {

echo '<table border="1">';
$cols = db2_num_fields($stmt);
$heading=TRUE;

while (db2_fetch_row($stmt)) {
if ($heading) {
echo "<tr>";
for ( $x=0; $x<$cols; $x++ ) {
echo "<th>" . db2_field_name($stmt, $x) . "</th>";
}
echo "</tr>";
$heading=FALSE;
}
echo "<tr>";
for ( $x=0; $x<$cols; $x++ ) {
echo "<td>" . db2_result($stmt, $x) . "</td>";
}
echo "</tr>";
}

echo "</table>";
return TRUE;
}

Basically, I execute my query (via the db2_exec() function provided by the IBM_DB2 module for PHP) and I pass the returned value to that db_print_table() routine I've pasted above.

It formats an HTML table from the rows/columns. Not much to it, really.

Is that what you're looking for?

I could probably code the same thing in RPG. The problem with RPG is that it's a strongly-typed language, so all of the output from the SQL statement would be in the data type of the database column (zoned, packed, integer, etc) and I'd have to write code that converts it all, no matter what size/type/etc of variable, to a character string. Not a problem in PHP, where any variable can be any data type. For business rules, RPG's strict data typing works better, but for taking any old generic result set and making it into HTML, PHP's weak-types are easier.

Is that what you're talking about?

Nathan Andelin wrote:
The discussion last month about validating and mapping HTML input elements to records helped me streamline some of my procedures. Now I'm interested in streamlining my interface for writing SQL result sets to browsers.

Actually, the recent discussion about generating PHP result sets from stored procedures triggered some of my thoughts on this matter, with my primary goal of coming up with an interface that's productive for RPG developers.

With that in mind, are there methods that folks are using that you think are good, and would be willing to discuss, to help me improve my interface, regardless of whether you're using MS .Net, or PHP, or Java, or Net.Data, or CGI, or whatever?

Say the application is simple as prompting the user to enter a name. Then generating a list of people having that name (or name prefix) from your database.

Thanks,

Nathan.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.