SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Introduction
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
1-2
Embedding SQL Statements
SQLMP ALIAS statement within your application to create the needed mappings from
logical to physical names:
CREATE SQLMP ALIAS catalog.schema.name
[\node.]$volume.subvol.filename
When this statement is executed, a mapping is inserted as a row in the MPALIAS
table. Examples of the CREATE SQLMP ALIAS statement appear in the SQL/MX
Reference Manual.
Embedding SQL Statements
To code a 3GL application program to access data in an SQL/MX or in an SQL/MP
database, use embedded SQL statements to receive data from or to insert data into a
database. Use embedded SQL declarations to declare host language variables that
these SQL statements use.
Your embedded SQL host program might look something like this:
EXEC SQL embedded SQL declarations ...
...
host language statement
...
EXEC SQL embedded SQL statement ...
...
In C/C++ and COBOL programs, the keywords EXEC SQL begin an embedded SQL
declaration or statement.
In a C/C++ program, the semicolon (;) ends a declaration or statement. In a COBOL
program, the keywords END-EXEC end a declaration or statement.
You can embed static or dynamic SQL statements in a host language source file. You
code a static SQL statement as an actual SQL statement and run the SQL/MX
compiler to explicitly compile the statement before you run the program. For a dynamic
SQL statement, you code a placeholder variable for the statement and then construct,
compile, and execute the SQL statement at run time.
For a list of SQL statements you can embed in a program, see Section 2, Embedded
SQL Statements.
Declaring and Using Host Variables
Host variables are host language variables declared in a host language program and
used in both host language statements and embedded SQL statements. You use host
variables to provide communication between 3GL and SQL statements—to receive
data from a database or to insert data into a database. A host variable can be any valid
host language variable that has a corresponding SQL data type.
Note. NonStop SQL/MX does not support mixing embedded SQL calls to SQL/MX and
SQL/MP from the same application process.