ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaik_5.4.0.1/rzaikclcmd.htm

87 lines
4.5 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: Call CL command stored procedures" />
<meta name="abstract" content="It is possible to run iSeries server commands by using stored procedures. The two examples that are provided here apply to ODBC programs." />
<meta name="description" content="It is possible to run iSeries server commands by using stored procedures. The two examples that are provided here apply to ODBC programs." />
<meta name="DC.Relation" scheme="URI" content="rzaikspex.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="clcmd" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Call CL command stored procedures</title>
</head>
<body id="clcmd"><a name="clcmd"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Call CL command stored procedures</h1>
<div><p>It is possible to run iSeries™ server commands by using stored
procedures. The two examples that are provided here apply to ODBC programs.</p>
<div class="section"><p>Simply call <span class="cmdname">Execute Command (QCMDEXC)</span> to run
the command. The process is relatively simple, but ensure that you include
all of the zeros in the length parameter. Use the <span class="apiname">Remote Command</span> API
as an alternative.</p>
</div>
<div class="section"><p>The first example enables the powerful SQL tracing facility that
writes data into the joblog for the job running the SQL (in this case, the
server job). </p>
</div>
<div class="section"><p>The second example overcomes a restriction in SQL: its limited
ability to work with multi-member files. You cannot create a multi-member
file through CREATE TABLE. However, the following example shows you how to
access with ODBC anything but the first member of a file that is created through
DDS:</p>
</div>
<div class="example"> <pre> Dim hStmt As Long
rc = SQLAllocHandle(SQL_HANDLE_STMT, ghDbc, hStmt)
If rc &lt;&gt; SQL_SUCCESS Then
Call DspSQLError(SQL_HANDLE_DBC, ghDbc, "Problem: Allocating Debug Statement Handle")
End If
' Note that the string within single quotes 'STRDBG UPDPROD(*YES)' is exactly 20 bytes
cmd = "call qsys.qcmdexc('STRDBG UPDPROD(*YES)',0000000020.00000)"
' Put the iSeries job in debug mode
rc = SQLExecDirect(hStmt, cmd, SQL_NTS)
If rc &lt;&gt; SQL_SUCCESS Then
Call DspSQLError(SQL_HANDLE_STMT, hStmt, "Problem: Start Debug")
End If
rc = SQLAllocHandle(SQL_HANDLE_STMT, ghDbc, ovrhstmt)
If rc &lt;&gt; SQL_SUCCESS Then
Call DspSQLError(SQL_HANDLE_DBC, ghDbc, "Problem: Allocating Override Statement Handle")
End If
' Note that the string within single quotes 'OVRDBF FILE(BRANCH)... OVRSCOPE(*JOB)'
is exactly 68 bytes
cmd = "call qsys.qcmdexc('OVRDBF FILE(BRANCH) TOFILE(HOALIB/BRANCH) MBR(FRANCE)
OVRSCOPE(*JOB)',0000000068.00000)"
' Override the iSeries file to point to the 'france' member
rc = SQLExecDirect(hStmt, cmd, SQL_NTS)
If rc &lt;&gt; SQL_SUCCESS Then
Call DspSQLError(SQL_HANDLE_STMT, hStmt, "File Override")
End If</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaikspex.htm" title="View examples of stored procedures.">Examples: Stored procedures</a></div>
</div>
</div>
</body>
</html>