ibm-information-center/dist/eclipse/plugins/i5OS.ic.db2_5.4.0.1/rbafzmstincludesqlda.htm

297 lines
14 KiB
HTML

<?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 xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="dc.language" scheme="rfc1766" 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. -->
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<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="keywords" content="C, SQLDA (SQL descriptor area), SQLDA,
application program, COBOL, ILE COBOL, PL/I, ILE RPG" />
<title>INCLUDE SQLDA declarations</title>
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
<link rel="stylesheet" type="text/css" href="ic.css" />
</head>
<body>
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
<a name="includesqlda"></a>
<h2 id="includesqlda"><a href="rbafzmst02.htm#ToC_1505">INCLUDE SQLDA declarations</a></h2>
<a name="wq2025"></a>
<h3 id="wq2025"><a href="rbafzmst02.htm#ToC_1506">For C and C++</a></h3><a id="idx3462" name="idx3462"></a><a id="idx3463" name="idx3463"></a><a id="idx3464" name="idx3464"></a>
<p>In C and C++, INCLUDE SQLDA declarations are equivalent to the following:</p>
<a name="wq2026"></a>
<div class="fignone" id="wq2026"><span class="figcap">Figure 11. INCLUDE SQLDA Declarations for C and C++</span>
<pre class="xmp">#ifndef SQLDASIZE
struct sqlda
{
unsigned char sqldaid[8];
long sqldabc;
short sqln;
short sqld;
struct sqlvar
{
short sqltype;
short sqllen;
unsigned char *sqldata;
short *sqlind;
struct sqlname
{
short length;
unsigned char data[30];
} sqlname;
} sqlvar[1];
};
struct sqlvar2
{ struct
{ long sqllonglen;
char reserve1[28];
} len;
char *sqldatalen;
struct sqldistinct_type
{ short length;
unsigned char data[30];
} sqldatatype_name;
};
#define SQLDASIZE(n) (sizeof(struct sqlda)+(n-1) * sizeof(struct sqlvar))
#endif
</pre>
<pre class="xmp">/*********************************************************************/
/* Macros for using the sqlvar2 fields. */
/*********************************************************************/
/*********************************************************************/
/* '2' in the 7th byte of sqldaid indicates a doubled number of */
/* sqlvar entries. */
/* '3' in the 7th byte of sqldaid indicates a tripled number of */
/* sqlvar entries. */
/*********************************************************************/
#define SQLDOUBLED '2'
#define SQLSINGLED ' '
/*********************************************************************/
/* GETSQLDOUBLED(daptr) returns 1 if the SQLDA pointed to by */
/* daptr has been doubled, or 0 if it has not been doubled. */
/*********************************************************************/
#define GETSQLDOUBLED(daptr) (((daptr)->sqldaid[6]== \
(char) SQLDOUBLED) ? \
(1) : \
(0) )
/*********************************************************************/
/* SETSQLDOUBLED(daptr, SQLDOUBLED) sets the 7th byte of sqldaid */
/* to '2'. */
/* SETSQLDOUBLED(daptr, SQLSINGLED) sets the 7th byte of sqldaid */
/* to be a ' '. */
/*********************************************************************/
#define SETSQLDOUBLED(daptr, newvalue) \
(((daptr)->sqldaid[6] =(newvalue)))
/*********************************************************************/
/* GETSQLDALONGLEN(daptr,n) returns the data length of the nth */
/* entry in the sqlda pointed to by daptr. Use this only if the */
/* sqlda was doubled or tripled and the nth SQLVAR entry has a */
/* LOB datatype. */
/*********************************************************************/
#define GETSQLDALONGLEN(daptr,n) ((long) (((struct sqlvar2 *) \
&amp;((daptr)->sqlvar[(n) +((daptr)->sqld)])) ->len.sqllonglen))
/*********************************************************************/
/* SETSQLDALONGLEN(daptr,n,len) sets the sqllonglen field of the */
/* sqlda pointed to by daptr to len for the nth entry. Use this only */
/* if the sqlda was doubled or tripled and the nth SQLVAR entry has */
/* a LOB datatype. */
/*********************************************************************/
#define SETSQLDALONGLEN(daptr,n,length) { \
struct sqlvar2 *var2ptr; \
var2ptr = (struct sqlvar2 *) &amp;((daptr)->sqlvar[(n)+ \
((daptr)->sqld)]); \
var2ptr->len.sqllonglen = (long) (length); \
}
/*********************************************************************/
/* SETSQLDALENPTR(daptr,n,ptr) sets a pointer to the data length for */
/* the nth entry in the sqlda pointed to by daptr. */
/* Use this only if the sqlda has been doubled or tripled. */
/*********************************************************************/
#define SETSQLDALENPTR(daptr,n,ptr) { \
struct sqlvar2 *var2ptr; \
var2ptr = (struct sqlvar2 *) &amp;((daptr)->sqlvar[(n)+ \
((daptr)->sqld)]); \
var2ptr->sqldatalen = (char *) ptr; \
}
</pre>
<pre class="xmp">/*********************************************************************/
/* GETSQLDALENPTR(daptr,n) returns a pointer to the data length for */
/* the nth entry in the sqlda pointed to by daptr. Unlike the inline */
/* value (union sql8bytelen len), which is 8 bytes, the sqldatalen */
/* pointer field returns a pointer to a long (4 byte) integer. */
/* If the SQLDATALEN pointer is zero, a NULL pointer is be returned. */
/* */
/* NOTE: Use this only if the sqlda has been doubled or tripled. */
/*********************************************************************/
#define GETSQLDALENPTR(daptr,n) ( \
(((struct sqlvar2 *) &amp;(daptr)->sqlvar[(n) + \
(daptr)->sqld])->sqldatalen == NULL) ? \
((long *) NULL ) : ((long *) ((struct sqlvar2 *) \
&amp;(daptr)->sqlvar[(n) + (daptr) ->sqld])->sqldatalen))
</pre></div>
<a name="wq2027"></a>
<h3 id="wq2027"><a href="rbafzmst02.htm#ToC_1507">For COBOL</a></h3><a id="idx3465" name="idx3465"></a><a id="idx3466" name="idx3466"></a><a id="idx3467" name="idx3467"></a>
<p>In COBOL, INCLUDE SQLDA declarations are equivalent to the following:</p>
<a name="wq2028"></a>
<div class="fignone" id="wq2028"><span class="figcap">Figure 12. INCLUDE SQLDA Declarations for COBOL</span>
<pre class="xmp">1 SQLDA.
05 SQLDAID PIC X(8).
05 SQLDABC PIC S9(9) BINARY.
05 SQLN PIC S9(4) BINARY.
05 SQLD PIC S9(4) BINARY.
05 SQLVAR OCCURS 0 TO 409 TIMES DEPENDING ON SQLD.
10 SQLTYPE PIC S9(4) BINARY.
10 SQLLEN PIC S9(4) BINARY.
10 FILLER REDEFINES SQLLEN.
15 SQLPRECISION PIC X.
15 SQLSCALE PIC X.
10 SQLRES PIC X(12).
10 SQLDATA POINTER.
10 SQLIND POINTER.
10 SQLNAME.
49 SQLNAMEL PIC S9(4) BINARY.
49 SQLNAMEC PIC X(30).
</pre></div>
<a name="wq2029"></a>
<h3 id="wq2029"><a href="rbafzmst02.htm#ToC_1508">For ILE COBOL</a></h3><a id="idx3468" name="idx3468"></a><a id="idx3469" name="idx3469"></a><a id="idx3470" name="idx3470"></a>
<p>In ILE COBOL, INCLUDE SQLDA declarations are equivalent to the following:</p>
<a name="wq2030"></a>
<div class="fignone" id="wq2030"><span class="figcap">Figure 13. INCLUDE SQLDA Declarations for ILE COBOL</span>
<pre class="xmp">1 SQLDA.
05 SQLDAID PIC X(8).
05 SQLDABC PIC S9(9) BINARY.
05 SQLN PIC S9(4) BINARY.
05 SQLD PIC S9(4) BINARY.
05 SQLVAR OCCURS 0 TO 409 TIMES DEPENDING ON SQLD.
10 SQLVAR1.
15 SQLTYPE PIC S9(4) BINARY.
15 SQLLEN PIC S9(4) BINARY.
15 FILLER REDEFINES SQLLEN.
20 SQLPRECISION PIC X.
20 SQLSCALE PIC X.
15 SQLRES PIC X(12).
15 SQLDATA POINTER.
15 SQLIND POINTER.
15 SQLNAME.
49 SQLNAMEL PIC S9(4) BINARY.
49 SQLNAMEC PIC X(30).
10 SQLVAR2 REDEFINES SQLVAR1.
15 SQLVAR2-RESERVED-1 PIC S9(9) BINARY.
15 SQLLONGLEN REDEFINES SQLVAR2-RESERVED-1
PIC S9(9) BINARY.
15 SQLVAR2-RESERVED-2 PIC X(28).
15 SQLDATALEN POINTER.
15 SQLDATATYPE-NAME.
49 SQLDATATYPE-NAMEL PIC S9(4) BINARY.
49 SQLDATATYPE-NAMEC PIC X(30).
</pre></div>
<a name="wq2031"></a>
<h3 id="wq2031"><a href="rbafzmst02.htm#ToC_1509">For PL/I</a></h3><a id="idx3471" name="idx3471"></a><a id="idx3472" name="idx3472"></a><a id="idx3473" name="idx3473"></a>
<p>In PL/I, INCLUDE SQLDA declarations are equivalent to the following:</p>
<a name="wq2032"></a>
<div class="fignone" id="wq2032"><span class="figcap">Figure 14. INCLUDE SQLDA Declarations for PL/I</span>
<pre class="xmp">DCL 1 SQLDA BASED(SQLDAPTR),
2 SQLDAID CHAR(8),
2 SQLDABC BIN FIXED(31),
2 SQLN BIN FIXED,
2 SQLD BIN FIXED,
2 SQLVAR (99),
3 SQLTYPE BIN FIXED,
3 SQLLEN BIN FIXED,
3 SQLRES CHAR(12),
3 SQLDATA PTR,
3 SQLIND PTR,
3 SQLNAME CHAR(30) VAR,
1 SQLDA2 BASED(SQLDAPTR),
2 SQLDAID2 CHAR(8),
2 SQLDABC2 FIXED(31) BINARY,
2 SQLN2 FIXED(15) BINARY,
2 SQLD2 FIXED(15) BINARY,
2 SQLVAR2 (99),
3 SQLBIGLEN,
4 SQLLONGL FIXED(31) BINARY,
4 SQLRSVDL FIXED(31) BINARY,
3 SQLDATAL POINTER,
3 SQLTNAME CHAR(30) VAR;
DECLARE SQLSIZE FIXED(15) BINARY;
DECLARE SQLDAPTR PTR;
DECLARE SQLDOUBLED CHAR(1) INITIAL('2') STATIC;
DECLARE SQLSINGLED CHAR(1) INITIAL(' ') STATIC;
</pre></div>
<a name="wq2033"></a>
<h3 id="wq2033"><a href="rbafzmst02.htm#ToC_1510">For ILE RPG</a></h3><a id="idx3474" name="idx3474"></a><a id="idx3475" name="idx3475"></a><a id="idx3476" name="idx3476"></a>
<p>In ILE RPG, INCLUDE SQLDA declarations are equivalent to the following:</p>
<a name="wq2034"></a>
<div class="fignone" id="wq2034"><span class="figcap">Figure 15. INCLUDE SQLDA Declarations for ILE RPG</span>
<pre class="xmp">D* SQL Descriptor area
D SQLDA DS
D SQLDAID 1 8A
D SQLDABC 9 12B 0
D SQLN 13 14B 0
D SQLD 15 16B 0
D SQL_VAR 80A DIM(SQL_NUM)
D 17 18B 0
D 19 20B 0
D 21 32A
D 33 48*
D 49 64*
D 65 66B 0
D 67 96A
D*
D SQLVAR DS
D SQLTYPE 1 2B 0
D SQLLEN 3 4B 0
D SQLRES 5 16A
D SQLDATA 17 32*
D SQLIND 33 48*
D SQLNAMELEN 49 50B 0
D SQLNAME 51 80A
D*
D SQLVAR2 DS
D SQLLONGL 1 4B 0
D SQLRSVDL 5 32A
D SQLDATAL 33 48*
D SQLTNAMELN 49 50B 0
D SQLTNAME 51 80A
D* End of SQLDA</pre></div>
<p>The user is responsible for the definition of SQL_NUM. SQL_NUM must be
defined as a numeric constant with the dimension required for SQL_VAR.</p>
<p>Since RPG does not support structures within arrays, the SQLDA generates
three data structures. The second and third data structures are used to setup/reference
the part of the SQLDA which contains the field descriptions.</p>
<p>To set the field descriptions of the SQLDA the program sets up the field
description in the subfields of SQLVAR (or SQLVAR2) and then does a MOVEA
of SQLVAR (or SQLVAR2) to SQL_VAR, n where n is the number of the field in
the SQLDA. This is repeated until all the field descriptions are set.</p>
<p>When the SQLDA field descriptions are to be referenced the user does a
MOVEA of SQL_VAR, n to SQLVAR (or SQLVAR2) where n is the number of the field
description to be processed.</p>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstsqldaunrec.htm">Previous Page</a> | <a href="rbafzmstsidvals.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
<a href="rbafzmstindex.htm#index">Index</a> ]
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
</body>
</html>