Component index
Section index

Component sql_query


Search

	/*
	    sql_query is a general purpose way to perform an SQL query and
	    iterate over the result. It provides enough functags to avoid
	    all the redundant stuff normally associated with databases query.
	*/
	<mod>
	static void sample_query()
	{
	    // Define the default database.
	    // Use the sample_table.sh to create and stuff the sample database
	    // sh sample_table.sh create
	    // sh sample_table.sh stuff
	    query_setdefaultdb ("localhost","sample");
	    <call sql_query>("select * from test");
	    <f empty>
	        printf ("No record found\n");
	    </f>
	    <f dostart>
	        printf ("List of records in table \"items\"\n");
	    </f>
	    <f doend>
	        printf ("--------\n");
	    </f>
	    <f onerow>
	        printf ("record %03d: %-30s\t%-30s\t%-20s\t%s\n",rownum
	            ,row[0],row[1],row[2],row[3]);
	    </f>
	    </call>
	}
	</mod>