Technical References - [SQLresult]

numero = 280
interpreted = N
texte = [SQLresult Params]Found Items[/SQLresult] Used to access info and result sets resulting from a [SQLExecute]. Example:
[SQLconnect dbType=MySQL&host=192.168.1.1&database=base&uid=sa&pwd=pass&conn_var=conn1]Connected successfully
[/SQLconnect] [SQLexecute conn_ref=conn1&result_var=rs1] select firstName,lastName from employees; [/SQLexecute] [SQLresult result_ref=rs1] [numfound] records found<br> <table border=1><tr><th>First Name</th><th>Last Name</th></tr> [founditems] <tr><td>[firstName]</td><td>[lastName]</td></tr> [/founditems] </table> [/SQLresult]
ParameterDescription
result_ref (or just 'ref')(Required) - The name of the SQLResult variable you created with a prior execution of [SQLexecute] (the value you set for the "result_var" or "var" parameter)
The following tags are available inside a [SQLresult] context:
TagDescription
[commandtext]The SQL command string that was executed via the [SQLexecute] context.
[numfound]A number indicating how many records were returned as the result of the SQL statemtnt (a 'select' staement in most cases). Some SQL statements will not result in a record set, i.e. DELETE, INSERT, DROP, etc... In these cases [numfound] will be zero.
[numfields]A number indicating the number of fields in the returned record set.
[numrowsaffected]The number of rows changed by an INSERT/UPDATE/DELETE command.
[insertID]The insert ID of a successfull INSERT command.
[founditems]...[/founditems]Normally you put a [founditems] loop inside a [SQLrelease] context to retrieve the records resulting from a SQL SELECT statement, so you can display all the matching records. You can put any record set field name inside the [FoundItems] loop to display them in HTML.There are other SQL commands that will return a records set. For example, in MySQL, the following statements will return a record set:"show tables;""show processlist;""describe <table>;"
It may sometimes be the case when you will not know all or any of the field names returned in a record set. Executing 'Select * from mytable' will pull all field values into the record set, but will you *know* what those field names are? If not, you can use the [ListFields] context to iterate the field names of a result set. For example:
[SQLconnect dbType=MySQL&host=192.168.1.1&database=base&uid=sa&pwd=pass&conn_var=conn1][/SQLconnect][SQLexecute conn_ref=conn1&result_var=rs1]select * from employees;[/SQLexecute][SQLresult result_ref=rs1][numfound] records found<br><table border=1><tr>[listfields]<th>[fieldname]</th>[/listfields]</tr>[founditems]<tr>[listfields]<td>[interpret][[fieldname]][/interpret]</td>[/listfields]</tr>[/founditems]</table>[/SQLresult]
You can also use the new [field], inside [founditems], to retrieve field data by the fields position in the records set. For example:
[SQLconnect dbType=MySQL&host=192.168.1.1&database=base&uid=sa&pwd=pass&conn_var=conn1][/SQLconnect][SQLexecute conn_ref=conn1&result_var=rs1]select * from employees; [/SQLexecute][SQLresult result_ref=rs1][founditems][loop start=1&end=[numfields]][field seek=ordinal:[index]&get=NAME]: <b>[field seek=ordinal:[index]&get=VALUE]</b> [hideif [index]=[numfields]]- [/hideif][/loop]<br>[/founditems][/SQLresult]
[SQLresult Params]Found Items[/SQLresult]
Used to access info and result sets resulting from a [SQLexecute].

Example:

[SQLconnect dbType=MySQL&host=192.168.1.1&database=base&uid=sa&pwd=pass&conn_var=conn1]
Connected successfully

[/SQLconnect]

[SQLexecute conn_ref=conn1&result_var=rs1]
select firstName,lastName from employees;
[/SQLexecute]

[SQLresult result_ref=rs1]
[numfound] records found<br>
<table border=1><tr><th>First Name</th><th>Last Name</th></tr>
[founditems]
<tr><td>[firstName]</td><td>[lastName]</td></tr>
[/founditems]
</table>
[/SQLresult]


ParameterDescription
result_ref (or just 'ref')(Required) - The name of the SQLResult variable you created with a prior execution of [SQLexecute] (the value you set for the "result_var" or "var" parameter)


The following tags are available inside a [SQLresult] context:

TagDescription
[commandtext]The SQL command string that was executed via the [SQLexecute] context.
[numfound]A number indicating how many records were returned as the result of the SQL statemtnt (a 'select' staement in most cases). Some SQL statements will not result in a record set, i.e. DELETE, INSERT, DROP, etc... In these cases [numfound] will be zero.
[numfields]A number indicating the number of fields in the returned record set.
[numrowsaffected]The number of rows changed by an INSERT/UPDATE/DELETE command.
[insertID]The insert ID of a successfull INSERT command.
[founditems]...[/founditems]Normally you put a [founditems] loop inside a [SQLrelease] context to retrieve the records resulting from a SQL SELECT statement, so you can display all the matching records. You can put any record set field name inside the [founditems] loop to display them in HTML.There are other SQL commands that will return a records set. For example, in MySQL, the following statements will return a record set:"show tables;""show processlist;""describe <table>;"


It may sometimes be the case when you will not know all or any of the field names returned in a record set. Executing 'Select * from mytable' will pull all field values into the record set, but will you *know* what those field names are? If not, you can use the [listfields] context to iterate the field names of a result set.

For example:

[SQLconnect dbType=MySQL&host=192.168.1.1&database=base&uid=sa&pwd=pass&conn_var=conn1]
[/SQLconnect]

[SQLexecute conn_ref=conn1&result_var=rs1]
select * from employees;
[/SQLexecute]

[SQLresult result_ref=rs1]
[numfound] records found<br>
<table border=1>
<tr>
[listfields]<th>[fieldname]</th>[/listfields]
</tr>
[founditems]
<tr>
[listfields]<td>[interpret][[fieldname]][/interpret]</td>[/listfields]
</tr>
[/founditems]
</table>
[/SQLresult]

You can also use the new [field], inside [founditems], to retrieve field data by the fields position in the records set.

For example:

[SQLconnect dbType=MySQL&host=192.168.1.1&database=base&uid=sa&pwd=pass&conn_var=conn1]
[/SQLconnect]

[SQLexecute conn_ref=conn1&result_var=rs1]
select * from employees;
[/SQLexecute]

[SQLresult result_ref=rs1]
[founditems]
[loop start=1&end=[numfields]]
[field seek=ordinal:[index]&get=NAME]: <b>[field seek=ordinal:[index]&get=VALUE]</b> [hideif [index]=[numfields]]- [/hideif]
[/loop]<br>
[/founditems]
[/SQLresult]


DOWNLOAD WEBDNA NOW!

Top Articles:

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

[biotype]

BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

WebDNA Modules

A list of the currently available modules...

WebDNA Libraries

A list of available libraries for WebDNA...

Tips and Tricks

A list of user-submitted tips ...

Related Readings:

[sendmail]

There is hardly a website that doesn't at some point need to send an email...

[return]

Explicitly identify what text is returned from a function call...

[regex]

[regex] is a full implementation of grep...

[listpath]

Breaks a path into separate foldernames and a filename...

[waitforfile]

The server waits until the file appears on disk...

[function]

This context enables the WebDNA programmer to call a previously defined block of WebDNA code...