Difference between revisions of "SQLVALUES()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to return the single row result of an SQL statement
 
Function to return the single row result of an SQL statement
 
  
 
==Syntax==
 
==Syntax==
 
SQLVALUES(<SQL statement>)
 
SQLVALUES(<SQL statement>)
 
  
 
==See Also==
 
==See Also==
[[CONNECTED()]], [[GATEWAY()]], [[LOGIN]], [[LOGOUT]], [[MODIFY GATEWAY]], [[SET GATEWAY]]
+
[[ASTRING()]], [[SQL SELECT|SELECT]], [[SQLEVAL()]]
 
+
  
 
==Description==
 
==Description==
The SQLVALUES() function executes the <SQL statement> and returns the result as a string. The required <SQL statement> cannot return multiple rows.  If a SELECT statement is specified it must be a singleton select.
+
The SQLVALUES() function executes the <SQL statement> and returns the result as a string. Multiple values from a singleton select are returned as a comma-separated list.
 
+
The SQLVALUES() function can only be used with an active gateway connection.
+
  
 +
If the <SQL statement> returns multiple rows, only the values from the first row are returned, but the results of all rows are available in the automatically created _sqlvalues array.
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
login "Oracle","node","user","Password"
+
open database southwind
// Count the number of records in the employee table
+
cTotal = sqlvalues("select max(available), min(available) from example")
cTotal = sqlvalues("SELECT COUNT(*) FROM emp")
+
 
total=val(cTotal)
+
// Access multiple row results
// Count the number of records in the employee table matching the key "Mr"
+
sqlvalues('select state from example group by state')
cTotal = sqlvalues("SELECT COUNT(*) FROM emp WHERE title = 'Mr'")
+
? astring(_sqlvalues)
 +
AL,AR,CA,CO,CT,FL,GA,IA,IL,KY,LA,MA,MD,ME,NH,NJ,NY,OH,PA,VA,WI
 
</code>
 
</code>
  
 
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Remote Data Connectivity]]
 
[[Category:Remote Data Connectivity Functions]]
 
 
[[Category:SQL]]
 
[[Category:SQL]]
 +
[[Category:Data Analysis Functions]]
 +
[[Category:Lianja VFP Extensions]]
 +
[[Category:VFP Function Extensions]]

Latest revision as of 09:16, 14 March 2013

Purpose

Function to return the single row result of an SQL statement

Syntax

SQLVALUES(<SQL statement>)

See Also

ASTRING(), SELECT, SQLEVAL()

Description

The SQLVALUES() function executes the <SQL statement> and returns the result as a string. Multiple values from a singleton select are returned as a comma-separated list.

If the <SQL statement> returns multiple rows, only the values from the first row are returned, but the results of all rows are available in the automatically created _sqlvalues array.

Example

open database southwind
cTotal = sqlvalues("select max(available), min(available) from example")
 
// Access multiple row results
sqlvalues('select state from example group by state')
? astring(_sqlvalues)
AL,AR,CA,CO,CT,FL,GA,IA,IL,KY,LA,MA,MD,ME,NH,NJ,NY,OH,PA,VA,WI