Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
NAME
go - execute database statements

SYNOPSIS
go [OPTION]

DESCRIPTION
Send the contents of the Work Buffer to the database. It then displays the results of the query and returns, causing the Work Buffer to be cleared and moved
to the end of the History Buffer.

OPTIONS
-i VARIABLE_NAME=COLUMN_INDEX
Save the value of the cell at row 1 and column index COLUMN_INDEX into shell variable VARIABLE_NAME. COLUMN_INDEX is 1-based. This option can be repeated.

-k, --session-id SESSION_ID
Use the server connection associated with the session identified by SESSION_ID.

-n VARIABLE_NAME=COLUMN_NAME
Save the value of the cell at row 1 with name COLUMN_NAME into shell variable VARIABLE_NAME. This option can be repeated.

EXAMPLES
Code Block
$ select top 25 * from orders
$ go
      To redirect the output of the select statement to a file, use the command go together with >>. SQL statements and the symbols / @ or ; cannot be combined 
with redirection and pipelines.
Code Block
$ select top 25 * from orders
$ GO >> rows.txt
      
Execute a query on the currently connected server and save the values of the first two columns of the first row to shell variables 'v_one' and 'v_two':
Code Block
SELECT * FROM table
go -i v_one=1 -i v_two=2

Execute a query on the currently connected server and save the values of columns 'c2' and 'c3' of the first row to shell variables 'v_one' and 'v_two':
Code Block
SELECT c1, c2, c3 FROM table
go -n v_one=c2 -n v_two=c3

NOTES
For -i and -n options, a new variable is created if the specified variable does not exist; if the query returns nothing, an empty string is saved to the specified variable.
If the specif ied variables already exist but query execution failed, the contents of existing variables will n ot be cleared.

If two different columns are specified by -i and -n options but both of them point to the same variable, the value of the column specified by -n is used.

SEE ALSO
source