28.11.2012 Views

IBM Tivoli NetView for z/OS Programming: Pipes - IBM notice

IBM Tivoli NetView for z/OS Programming: Pipes - IBM notice

IBM Tivoli NetView for z/OS Programming: Pipes - IBM notice

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using <strong>Tivoli</strong> <strong>NetView</strong> <strong>for</strong> z/<strong>OS</strong> SQL Stages <strong>for</strong> Access to DB2<br />

In this example, SSID DB2 defines the DB2 subsystem named DB2 as the subsystem<br />

this task references.<br />

Creating, Loading, and Querying a Table<br />

336 <strong>Programming</strong>: <strong>Pipes</strong><br />

Use SQL to query and maintain DB2 tables. The following examples show two<br />

ways to create a table. In the first example, a single DB2 statement is issued; in the<br />

second example, SQL EXECUTE reads statements from its primary input stream.<br />

The following example shows that you can supply multiple DB2 statements to a<br />

single invocation of the SQL stage:<br />

pipe SQL execute create table jtest (kwd char(8), text VARCHAR(80))<br />

in netview.xmydb | cons<br />

’pipe lit /create table ktest (kwd char(8), ’ ,<br />

’ text VARCHAR(80)) in netview.xmydb/’,<br />

’ | SQL execute ’,<br />

’ | cons ’<br />

/* Insert lines in a table */<br />

signal on novalue<br />

"PIPE",<br />

"lit /AAA Automated Banking System/",<br />

"| lit /BBB Network Program/",<br />

"| lit ’CCC TIVOLI <strong>NetView</strong> <strong>for</strong> <strong>OS</strong>/390 Automation’",<br />

"| edit /insert into jtest (kwd, text) values(’/ 1 ",<br />

"1.8 next /’, ’/ next 9.* next /’)/ next",<br />

"|SQL execute",<br />

"|CONS"<br />

exit RC<br />

Note: You receive error messages from SQL if you do not enter the names of the<br />

columns, even when you are setting all of them.<br />

The following example shows how to use SQL DESCRIBE SELECT to see the<br />

<strong>for</strong>mat of the input record or the result of a query:<br />

pipe SQL SSID DB2 describe select * from jtest | console<br />

453 CHAR 8 8 KWD<br />

449 VARCHAR 80 82 TEXT<br />

In the previous example, each line describes a column in the table. The first<br />

column of the record is the numeric DB2 field code. The field code is decoded in<br />

the next column. A third column is the length (or precision) of the field as<br />

perceived by DB2. The fourth column is the number of characters required to<br />

represent the field when loading with SQL INSERT and when queried with SQL<br />

SELECT. Note that the varying character field has two bytes reserved <strong>for</strong> the<br />

length prefix. Finally, the name of the column is shown. SSID DB2 defines that DB2<br />

is the name of the DB2 subsystem to access. Subsequent SQL requests access that<br />

DB2 unless the keyword SSID is used.<br />

The following is an example of an SQL SELECT query:<br />

pipe SQL select * from jtest | console<br />

""CCC """"TIVOLI NETVIEW FOR <strong>OS</strong>/390 AUTOMATION<br />

""BBB """"NETWORK PROGRAM<br />

""AAA """"AUTOMATED BANKING SYSTEM<br />

The double quotation marks represent unprintable binary data. The first two<br />

positions of each column contain the DB2 indicator word that specifies whether the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!