Command group | Flag affected | Reversible | Execute on client | Platform(s) |
---|---|---|---|---|
SQL Object Commands | NO | NO | NO | All |
Begin statement ([Carriage return][,Linefeed])
Carriage return | If specified, the command appends a carriage return, after it appends each line of the statement |
Linefeed | If specified, the command appends a line feed, after it appends each line of the statement |
This command defines the start of a block of SQL statements and text to be stored in the SQL buffer for the current method stack. The current content of the SQL buffer is cleared when you execute this command. The End statement command defines the end of the block. The lines are not checked by Omnis in any way and must be valid SQL in order for the server to be able to use them. To use the SQL buffer, you call the $prepare or $execdirect method of a SQL statement object, passing no parameters.
The Carriage return option causes Omnis to insert a carriage return character between each line of the SQL statement. The Linefeed option causes Omnis to insert a linefeed character between each line of the SQL statement. If you select both Carriage return and Linefeed, then Omnis inserts a carriage return followed by a linefeed. If you select neither option, Omnis separates the statement lines with a space. One example of when you would use these options, is when you use Begin statement, Sta:, End statement, and $execdirect, to add a stored procedure to the database. This makes the procedure more readable when you view it.
# Open a multi-threaded omnis sql connection to
# the datafile mydatafile and create a statement to
# select rows from the table Customers
Calculate lHostname as con(sys(115),'mydatafile.df1')
Do iSessObj.$logon(lHostname,'','','MYSESSION')
Do iSessObj.$newstatement('MyStatement') Returns lStatObj
Begin statement
Sta: Select * From Customers
Sta: Where Cust_ID > 100
End statement
Do lStatObj.$execdirect()
Do lStatObj.$fetch(lMyList,kFetchAll)