Product Documentation

FairCom ISQL

Previous Topic

Next Topic

GET

Syntax

G[ET] filename;

Description

The GET statement reads the first SQL statement stored in the specified script file.

Arguments

filename

The name of the script file. ISQL reads the file until it encounters a semicolon ( ; ) statement terminator. It appends the statement to the history buffer as the most-recent statement.

Notes

  • Execute the statement read by GET using the RUN statement.
  • The GET, START, and @ (execute) statements are similar in that they all read SQL script files. Both GET and START read an SQL script file and append the first statement in it to the history buffer. However, the START statement also executes the script statement and accepts arguments that it substitutes for parameter references in the script statement. The @ (execute) statement, on the other hand, executes all the statements in an SQL script file but does not add any of the statements to the history buffer. The @ statement does not support argument substitution.

Example

Once you refine a query to return the results you need, you can store it in an SQL script file. For example, the file query.sql contains a complex query that joins several tables in a sample database.

Use the GET and RUN statements to read and execute the first statement in query.sql:


ISQL> GET query.sql

SELECT customers.customer_name,

orders.order_info,

orders.order_state,

lot_staging.lot_location,

lot_staging.start_date

FROM customers,

orders,

lots,

lot_staging

WHERE ( customers.customer_id = orders.customer_id ) and

( lots.lot_id = lot_staging.lot_id ) and

( orders.order_id = lots.order_id ) and

( ( customers.customer_name = 'Ship Shapers Inc.' ) AND

( lot_staging.start_date is not NULL ) AND

( lot_staging.end_date is NULL ) )

ISQL> RUN

SELECT customers.customer_name,

orders.order_info,

orders.order_state,

lot_staging.lot_location,

lot_staging.start_date

FROM customers,

orders,

lots,

lot_staging

WHERE ( customers.customer_id = orders.customer_id ) and

( lots.lot_id = lot_staging.lot_id ) and

( orders.order_id = lots.order_id ) and

( ( customers.customer_name = 'Ship Shapers Inc.' ) AND

( lot_staging.start_date is not NULL ) AND

( lot_staging.end_date is NULL ) )

CUSTOMER_NAME ORDER_INFO

------------- ----------

ORDER_STATE LOT_LOCATION START_DATE

----------- ------------ ----------

Ship Shapers Inc. I Beams Size 10

Processing Hot Rolling 12/26/1994

1 record selected


TOCIndex