GO (rcli)

is a rcli special command, signaling the end of a batch in a script file.

Syntax

GO [count]

Arguments

count
optional argument. It specifies the number of times the batch will be sent to the server.
It is a literal of type int. It can be 0.

Remarks

If count is specified, the batch will be sent to the server count times for execution.

If this argument omitted, the batch is sent once.

The RSQL Client reads the SQL script file as follows:

  1. The script file is read until GO, EXIT or QUIT command is encountered.
  2. This portion of the script file is the batch to execute, and is sent to the server.
  3. The RSQL Client waits for the response and prints the return code.
  4. If the command was EXIT or QUIT, the RSQL Client stops execution.
  5. Else, continue with the next batch (proceed to point 1.)

If USE command is used in a batch, the change of the current database will propagate to the next batch in the same file.

If GO 0 is encountered, the batch is not sent to the server.

This command is recognized only if it appears at the beginning of a line.

Examples

PRINT 'Hello from the first batch.';
GO

PRINT 'Nothing is printed !';  -- this batch is not sent to the server
GO 0

PRINT 'This is the 2nd batch. It prints a random number: ' + CAST(RAND()*100 AS VARCHAR);
GO 3

PRINT 'Goodbye from 3rd batch'

The result is:

2016/03/20 02:52:39 --- executing batch sample.sql:1 ---
Hello from the first batch.
2016/03/20 02:52:39 return code: 0

2016/03/20 02:52:39 --- executing batch sample.sql:7 ---
This is the 2nd batch. It prints a random number: 19.0879
2016/03/20 02:52:39 return code: 0

2016/03/20 02:52:39 --- executing batch sample.sql:7 ---
This is the 2nd batch. It prints a random number: 39.6825
2016/03/20 02:52:39 return code: 0

2016/03/20 02:52:39 --- executing batch sample.sql:7 ---
This is the 2nd batch. It prints a random number: 93.8236
2016/03/20 02:52:39 return code: 0

2016/03/20 02:52:39 --- executing batch sample.txt:10 ---
Goodbye from 3rd batch
2016/03/20 02:52:39 return code: 0