SQL/MX Programming Manual for Java

SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java523726-003
4-34
Using Distributed Database Statements in an SQLJ
Program
If you embed a REGISTER CATALOG statement in an SQLJ program, you must run
the program on the local node where the catalog is visible. Before executing the SQLJ
program, verify that a catalog with an identical name does not already exist on the
remote node. You cannot register a catalog on a node where an individual catalog with
the same name already exists.
For example, this SQLJ program creates a catalog on the local node, \local, and
then registers the locally visible catalog on the remote node, \remote:
#sql {CREATE CATALOG samdbcat
LOCATION \local.$samdb};
#sql {REGISTER CATALOG samdbcat
ON \remote.$samdb};
#sql {CREATE SCHEMA samdbcat.persnl
AUTHORIZATION hr.dba};
#sql {CREATE TABLE samdbcat.persnl.job
( jobcode NUMERIC (4) UNSIGNED
NO DEFAULT
NOT NULL NOT DROPPABLE
HEADING 'Job/Code'
,jobdesc VARCHAR (18)
DEFAULT 0
HEADING 'Job Description'
,PRIMARY KEY (jobcode) NOT DROPPABLE
)
LOCATION \local.$samdb
};
...
After running the SQLJ program, a catalog reference of the SAMDBCAT catalog exists
on the remote node,
\remote. Because the catalog is visible, users can query the
JOB table from the remote node,
\remote.
For the syntax of the REGISTER CATALOG statement, see the SQL/MX Reference
Manual.
Embedding an UNREGISTER CATALOG Statement
The UNREGISTER CATALOG statement removes an empty catalog reference from a
node, making the catalog invisible on that node.
If you embed an UNREGISTER CATALOG statement in an SQLJ program, you must
run the program on any node where the catalog is visible. The catalog reference on the
target node must be empty, the catalog references and target node must be available
in an Expand network, and the target node must not have the only automatic catalog
reference.
Note. The CREATE CATALOG statement can only create a catalog on the local node. The
location of the node is restricted to the local node.