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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

* Drop a table */<br />

’pipe lit /drop table jtest/| SQL execute|console’<br />

Using Multiple Concurrent SQL Stages<br />

Up to 10 SQL stages can run concurrently in all active pipelines. Use the<br />

NOCOMMIT option in concurrent operations. DB2 considers all SQL stages to be<br />

part of one unit of work; an implied commit by a stage causes errors when other<br />

stages resume. Explicit commit or rollback is done with SQL COMMIT and SQL<br />

ROLLBACK.<br />

/* Merge two tables */<br />

’PIPE (end ?)’,<br />

’SQL nocommit noclose select * from<br />

table1 |SEP| p: FANIN | CONS ?’,<br />

’SQL nocommit select * from table2 |SEP| p:’<br />

’PIPE SQL execute commit work’<br />

PIPE SQL<br />

Use NOCL<strong>OS</strong>E to leave the plan open from one pipe to another on the same<br />

<strong>NetView</strong> task. The plan closes when all concurrent SQL stages have terminated. A<br />

NOCL<strong>OS</strong>E option used in any (concurrent) stage of a pipe makes the plan stay<br />

open when the pipe ends.<br />

When accessing multiple DB2 subsystems from a <strong>NetView</strong> system, you cannot<br />

directly access multiple DB2 subsystems on a single task without having the SQL<br />

close and reopen the plan. Consider using multiple autotasks which interfaces with<br />

a different DB2 subsystem as servers <strong>for</strong> other tasks. You can use labeled<br />

commands and pipes to correlate the SQL requests running on the separate tasks.<br />

The plan closes when none of the SQL stages within the pipe specify NOCL<strong>OS</strong>E.<br />

For example, PIPE SQL COMMIT WORK | CONSOLE commits the unit of work and close<br />

the active plan.<br />

Note: If a plan is left open and the REXX procedure ends, the plan remains open<br />

until a subsequent pipe closes it or the task ends. A REXX procedure might<br />

use PIPE SQL COMMIT WORK | CONS at the start of SQL processing to ensure<br />

that any previous plan is closed. Alternatively, use PIPE SQL NOCL<strong>OS</strong>E<br />

CONNECT RESET | CONS to ensure that the local database is being used and<br />

the plan is open.<br />

Use NOCL<strong>OS</strong>E:<br />

v When using SQL CONNECT to a remote database, a NOCL<strong>OS</strong>E enables you to<br />

keep the remote connection between two pipes. You might find it convenient to<br />

open a remote connection in one pipe, do some processing in REXX, and then<br />

finish working with the remote connection in a second pipe. You specify<br />

NOCL<strong>OS</strong>E in the first pipe and omit the operand in the second pipe.<br />

v When using database locks in SQL, use NOCL<strong>OS</strong>E to keep the locks from one<br />

PIPE to the next.<br />

v When using applications requiring two pipes to implement one function,<br />

typically, with other (REXX) processing between the two pipes.<br />

Other Considerations When Using SQL<br />

When using SQL, consider that:<br />

v DB2 statements are read from the primary input stream when EXECUTE is used.<br />

The query results are written to the primary output stream. Error and diagnostic<br />

messages are written to the secondary output stream.<br />

v SQL terminates when the primary output stream is disconnected. It also<br />

terminates if a negative return code is received from DB2.<br />

Chapter 2. Pipeline Stages and Syntax 223

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

Saved successfully!

Ooh no, something went wrong!