Description:
Execute the specified SQL statement on the data source and return the result.
Syntax:
$(db)sql;…
Note:
On the data source db, execute the specified SQL statement sql and return the execution result. db is the data source name. If omitting (db), then use the data source specified by the previous statement. If no data source is specified in the previous statement, then use any of the currently connected data sources.
You can use simple SQL in this statement.
Parameter:
sql |
A SQL statement in the form of select * from table, for example; the SQL statement must be one of select/insert/delete/update statements |
(db) |
Data source name |
… |
Argument value passed to the SQL statement |
Return value:
Table sequence
Example:
SELECT statement:
|
A |
|
1 |
$select * from EMPLOYEE |
No data source is specified in the previous statement since parameter (db) is absent, and error report appears if there isn’t a currently connected data source. |
2 |
$(demo)select * from EMPLOYEE where EID=?;1 |
Find the employees whose EID is 1 from the demo data source. |
3 |
$select * from EMPLOYEE where EID in (?) or GENDER=?;[1,3,5,7],"M" |
Since parameter (db) is absent, the program uses the demo data source defined in the previous statement to find the employees whose EID is [1,3,5,7] and gender is M. |
INSERT statement:
|
A |
B |
|
1 |
$(demo)insert into EMPLOYEE (EID, NAME) values(?,?);100,"test" |
|
Insert statement. |
2 |
[51,52,53,54] |
|
|
3 |
for A2 |
|
|
4 |
|
$insert into STATECAPITAL (STATEID) values(?);A3 |
Since parameter (db) is absent, the program uses the demo data source defined in the previous statement; pass members of A2’s sequence to B4’s statement as parameters by loop. |
DELETE statement:
|
A |
|
1 |
$(demo)delete from EMPLOYEE where EID =? or EID=?;100,101 |
|
2 |
$delete from EMPLOYEE where EID in(?);[1,5,7,9] |
|
3 |
$delete from EMPLOYEE where NAME ='Rebecca' |
Since parameter (db) is absent and no data source is specified in the previous statement, the program uses one of the currently connected data sources. |
UPDATE statement:
|
A |
|
1 |
$(demo)update EMPLOYEE set NAME =?, GENDER=? where EID =?;"testnew","M",100 |
|
2 |
$update EMPLOYEE set NAME ='Peter' where EID =10 |
Since parameter (db) is absent, the program uses the data source defined in the previous statement to modify the NAME of the employee whose EID is 10 to Peter. |
3 |
$(sql)update Family set Name='Rose' where Eid=?;2 |
Update the name of a record of Family whose Eid is 2 by connecting to a data source named sql. |
Related function: