UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

Parameter Description Examples In the following example, the program segment executes a UniData SQL command: 1-272 UniBasic Commands Reference ASYNC | SYNC UniData no longer supports this parameter, but it remains for syntax compatibility. ON connection UniData no longer supports this parameter, but it remains for syntax compatibility. ON ERROR statements UniData no longer supports this parameter, but it remains for syntax compatibility. EXECUTESQL Parameters (continued) OUT.COMMAND = "SELECT NAME, ADDRESS, CITY" OUT.COMMAND := " FROM CLIENTS;" EXECUTESQL OUT.COMMAND CLEARSELECT The following output displays on the terminal screen when you execute the preceding program: Page 1 Name Address City ------------------------------ ------------------------- --------- ------ Paul Castiglione 45, reu de Rivoli Paris Fredrick Anderson 854, reu de Rivoli Paris Beverly Ostrovich 7925 S. Blake St. Sydney Cal di Grigorio 913 Montreal Ave. Regina Franklin Sears 213 Midland St. Perth Gino Lee 483 E. Silverman St. Fonthill JoAnn Casey 4024 South Ivywood Circle Omaha ...

In the next example, the program segment executes the same UniData SQL command with a TO clause that stores the UniData SQL output in a file that you can access using the READNEXTTUPLE statement. (This program uses the CLIENTS file in the demo database.) OUT.COMMAND = "SELECT NAME, ADDRESS, CITY, STATE" OUT.COMMAND := " FROM CLIENTS TO SQL_INPUT;" EXECUTESQL OUT.COMMAND DONE = 0 FOR X = 1 TO 5 READNEXTTUPLE CLIENT.INFO FROM "SQL_INPUT" ELSE STOP CONVERT @AM TO " " IN CLIENT.INFO PRINT CLIENT.INFO NEXT X CLEARSELECT END This program produces the following results: Paul Castiglione 45, reu de Rivoli Paris Fredrick Anderson 854, reu de Rivoli Paris Beverly Ostrovich 7925 S. Blake St. Sydney NSW Cal di Grigorio 913 Montreal Ave. Regina Saskatchewan Franklin Sears 213 Midland St. Perth In the next example, the UniData SQL statement selects an @ID only. UniData uses a select list instead of storing the output. In this case, the UniData SQL command does not require a TO clause, and the UniBasic READNEXT statement processes the IDs selected. OPEN 'CLIENTS' TO CLIENT.FILE ELSE PRINT 'Open Error.' OUT.COMMAND = "SELECT @ID" OUT.COMMAND := " FROM CLIENTS" OUT.COMMAND := " WHERE CITY = 'Paris';" EXECUTESQL OUT.COMMAND DONE = 0 LOOP READNEXT @ID ELSE DONE = 1 UNTIL DONE DO GOSUB PROCESS.RECS REPEAT CLEARSELECT PROCESS.RECS: *print records for clients in Paris." READ REC FROM CLIENT.FILE,@ID THEN PRINT REC RETURN END EXECUTESQL 1-273

In the next example, the program segment executes the same UniData SQL command<br />

with a TO clause that stores the UniData SQL output in a file that you can access<br />

using the READNEXTTUPLE statement. (This program uses the CLIENTS file in<br />

the demo database.)<br />

OUT.COMMAND = "SELECT NAME, ADDRESS, CITY, STATE"<br />

OUT.COMMAND := " FROM CLIENTS TO SQL_INPUT;"<br />

EXECUTESQL OUT.COMMAND<br />

DONE = 0<br />

FOR X = 1 TO 5<br />

READNEXTTUPLE CLIENT.INFO FROM "SQL_INPUT" ELSE STOP<br />

CONVERT @AM TO " " IN CLIENT.INFO<br />

PRINT CLIENT.INFO<br />

NEXT X<br />

CLEARSELECT<br />

END<br />

This program produces the following results:<br />

Paul Castiglione 45, reu de Rivoli Paris<br />

Fredrick Anderson 854, reu de Rivoli Paris<br />

Beverly Ostrovich 7925 S. Blake St. Sydney NSW<br />

Cal di Grigorio 913 Montreal Ave. Regina Saskatchewan<br />

Franklin Sears 213 Midland St. Perth<br />

In the next example, the UniData SQL statement selects an @ID only. UniData uses<br />

a select list instead of storing the output. In this case, the UniData SQL command<br />

does not require a TO clause, and the <strong>UniBasic</strong> READNEXT statement processes the<br />

IDs selected.<br />

OPEN 'CLIENTS' TO CLIENT.FILE ELSE PRINT 'Open Error.'<br />

OUT.COMMAND = "SELECT @ID"<br />

OUT.COMMAND := " FROM CLIENTS"<br />

OUT.COMMAND := " WHERE CITY = 'Paris';"<br />

EXECUTESQL OUT.COMMAND<br />

DONE = 0<br />

LOOP<br />

READNEXT @ID ELSE DONE = 1<br />

UNTIL DONE DO<br />

GOSUB PROCESS.RECS<br />

REPEAT<br />

CLEARSELECT<br />

PROCESS.RECS:<br />

*print records for clients in Paris."<br />

READ REC FROM CLIENT.FILE,@ID<br />

THEN PRINT REC<br />

RETURN<br />

END<br />

EXECUTESQL 1-273

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!