sql. Retrieving number from database

^int:sql{query}
^int:sql{query}[$.limit(1) $.offset(o) $.default(
expression)]
^double:sql{query}
^double:sql{query}[$.limit(1) $.offset(o) $.default(
expression)]

The method returns number resulted from SQL-query to a database server. The query must return value of single column of single row.

query - query to a DB, written in SQL language;
$.offset(o) - ignore first o query records;
if SQL-server response was empty (0 records), …
$.default(expression) …the given expression will be evaluated returned;
$.default{code} …the given code will be executed and string result returned;
$.default not specified …an error message will be thrown.


This method demands connection with database server (see operator
connect).

Example
Code…

^connect[connect string]{
   ^int:sql{
select count(*) from news}
}

…will return number of records in table
news.


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 25.01.2021