# Introduction to SQL

Using SQL Directly Within PxPlus |

The generic SQL statements described in the previous pages can also be passed "as is" from PxPlus to the target database. There are two ways that this can be accomplished.

In the syntax examples below, [tag] represents one of the available database options, and < SQL > represents an actual SQL statement embedded within a PxPlus statement.

Example:

The following syntax sends the SQL statement through a channel tied to a table (limited to the size of the KNO used):

> OPEN (chan,IOL=*)"[ tag ] database ; table [;fileopt ]"
> READ (chan,KEY="!< SQL >")

SQL statements can be passed directly using a straight connection to the database without specifying the table name:

> OPEN (chan,IOL=*)"[ tag ] database ; [;fileopt ]"

To issue an SQL statement and retrieve the first result value:

> READ [RECORD] (chan,KEY="!< SQL >") iolist

To simply issue an SQL statement:

> WRITE RECORD (chan)"< SQL >"

To retrieve the results:

> READ [RECORD] (chan) iolist

#### Note:
Ensure that you are using the correct SQL syntax for the target database. Refer to specific product documentation for the database system being accessed.