<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="The SQLResult Object" package="Max">

<h1>
The SQLResult Object
</h1>

<p>
An SQLResult object is a container for results obtained in an SQLite.exec call. Not every <b>exec</b>() call will produce results, but any database query (SELECT in particular) will generate an SQLResult object even if the result is empty.
</p>

<h2>SQLResult Constructor</h2>

<code language="javascript">var res = new SQLResult;
</code>

<p>
No arguments are required for the constructor.
</p>

<h2>SQLResult Methods</h2>

<p>
All data from the SQLResult object is retrieved using object methods.
</p>
	<jsmethod_list name="SQLResult">
  		<jsmethod name="numrecords">
		    <description>
		    	Returns the number of records that were returned in the SQLResult object.
		    </description>
  		</jsmethod>

  		<jsmethod name="numfields">
		    <description>
		    	Returns the number of fields in the dataset returned in the SQLResult object.
		    </description>
  		</jsmethod>

  		<jsmethod name="fieldname">
		    <arglist>
		    	<arg name="index" type="Number"/>
		    </arglist>
		    <description>
		    	Returns the name of a column at the requested index.
		    </description>
  		</jsmethod>

  		<jsmethod name="value">
		    <arglist>
		    	<arg name="index" type="Number"/>
		    	<arg name="record_no" type="Number"/>
		    </arglist>
		    <description>
		    	Returns the value of the column identified by index, and in the record identified by <I>record_no</I>.
		    	<p>
				<b>Example:</b>
				</p>
				<code language="javascript">
function print_everything(sqlres)
{
	var numrecs = sqlres.numrecords();
	var numflds = sqlres.numfields();

	var field_names = new Array();
	for (var i=0; i&lt;numflds; i++) {
		field_names[i] = sqlres.fieldname(i);
	}

	for (var i=0; i&lt;numrecs; i++) {
		for (var j=0; j&lt;numflds; j++) {
			post("Rec: ", i, " field ", field_names[j], " value ", sqlres.value(j, i), '\n');
		}
	}
}
				</code>
		    </description>
  		</jsmethod>
  	</jsmethod_list>
</vignette>
