ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajp_5.4.0.1/rzajpclobvar.htm

186 lines
11 KiB
HTML
Raw Permalink 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="LOB host variables in C and C++ applications that use SQL" />
<meta name="abstract" content="C and C++ do not have variables that correspond to the SQL data types for LOBs (large objects). To create host variables that can be used with these data types, use the SQL TYPE IS clause. The SQL precompiler replaces this declaration with a C language structure in the output source member." />
<meta name="description" content="C and C++ do not have variables that correspond to the SQL data types for LOBs (large objects). To create host variables that can be used with these data types, use the SQL TYPE IS clause. The SQL precompiler replaces this declaration with a C language structure in the output source member." />
<meta name="DC.subject" content="LOB host variable, C, C++, host variable, LOB, C program, C++ program, CLOB host variable, CLOB, DBCLOB host variable, DBCLOB, BLOB host variable, BLOB, LOB locator, locator, LOB file reference variable, file reference variable" />
<meta name="keywords" content="LOB host variable, C, C++, host variable, LOB, C program, C++ program, CLOB host variable, CLOB, DBCLOB host variable, DBCLOB, BLOB host variable, BLOB, LOB locator, locator, LOB file reference variable, file reference variable" />
<meta name="DC.Relation" scheme="URI" content="rzajpdeclaringhostc.htm" />
<meta name="DC.Relation" scheme="URI" content="../sqlp/rbafylobrefvar.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzajpclobvar" />
<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>LOB host variables in C and C++ applications that use SQL</title>
</head>
<body id="rzajpclobvar"><a name="rzajpclobvar"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">LOB host variables in C and C++ applications that use SQL</h1>
<div><p>C and C++ do not have variables that correspond to the SQL data
types for LOBs (large objects). To create host variables that can be used
with these data types, use the SQL TYPE IS clause. The SQL precompiler replaces
this declaration with a C language structure in the output source member.</p>
<div class="section"><h4 class="sectiontitle">LOB Host Variable</h4><pre><span><img src="./c.gif" border="0" alt="Read syntax diagram" longdesc="rzajpclobvarsyn1.htm" /></span><a href="#d0e175"><img src="./c.gif" border="0" alt="Skip visual syntax diagram" /></a>
>>-+--------+--+----------+--SQL TYPE IS--+-CLOB---+------------>
   +-auto---+ +-const----+ +-DBCLOB-+   
   +-extern-+ '-volatile-' '-BLOB---'   
   '-static-'    
>--(--<i>length</i>--+---+--)------------------------------------------>
    +-K-+    
    +-M-+    
    '-G-'    
   .-,----------------------------------------------------.    
   V |    
>----<i>variable-name</i>--+-----------------------------------+-+-- ; ->&lt;
    +- = --{--<i>init-len,"init-data"</i>--}---+    
    +- = --<i>SQL_CLOB_INIT("init-data")</i>---+    
    +- = --<i>SQL_DBCLOB_INIT("init-data")</i>-+    
    '- = --<i>SQL_BLOB_INIT("init-data")</i>---'    
</pre><a name="d0e175"></a></div>
<div class="section"> <div class="note"><span class="notetitle">Notes:</span> <ol><li>K multiplies <em>length</em> by 1024. M multiplies <em>length</em> by 1 048 576.
G multiplies <em>length</em> by 1 073 741 824.</li>
<li>For BLOB and CLOB, 1 ≤ <em>length</em> ≤ 2 147 483 647</li>
<li>For DBCLOB, 1 ≤<em> length</em> ≤ 1 073 741 823</li>
<li>SQL TYPE IS, BLOB, CLOB, DBCLOB, K, M, G can be in mixed case.</li>
<li>The maximum length allowed for the initialization string is 32 766
bytes.</li>
<li>The initialization length, <em>init-len</em>, must be a numeric constant
(that is, it cannot include K, M, or G).</li>
<li>If the LOB is not initialized within the declaration, then no initialization
will be done within the precompiler generated code.</li>
<li>The precompiler generates a structure tag which can be used to cast to
the host variable's type.</li>
<li>Pointers to LOB host variables can be declared, with the same rules and
restrictions as for pointers to other host variable types.</li>
<li>CCSID processing for LOB host variables will be the same as the processing
for other character and graphic host variable types.</li>
<li>If a DBCLOB is initialized, it is the user's responsibility to prefix
the string with an 'L' (indicating a wide-character string).</li>
</ol>
</div>
</div>
<div class="section"><h4 class="sectiontitle"><em>CLOB example</em></h4><p>The following declaration: </p>
<pre>SQL TYPE IS CLOB(128K) var1, var2 = {10, "data2data2"};</pre>
<p>The precompiler will generate for C: </p>
<pre>_Packed struct var1_t {
unsigned long length;
char data[131072];
} var1,var2={10,"data2data2"};</pre>
</div>
<div class="section"><h4 class="sectiontitle"><em>DBCLOB example</em></h4><p>The following declaration: </p>
<pre>SQL TYPE IS DBCLOB(128K) my_dbclob;</pre>
<p>The
precompiler will then generate: </p>
<pre>_Packed struct my_dbclob_t {
unsigned long length;
wchar_t data[131072]; } my_dbclob;</pre>
</div>
<div class="section"><h4 class="sectiontitle"><em>BLOB example</em></h4><p>The following declaration: </p>
<pre>static SQL TYPE IS BLOB(128K)
my_blob=SQL_BLOB_INIT("mydata");</pre>
<p>Results in the generation
of the following structure: </p>
<pre>static struct my_blob_t {
unsigned long length;
char data[131072];
} my_blob=SQL_BLOB_INIT("my_data");</pre>
</div>
<div class="section"><h4 class="sectiontitle">LOB Locator</h4><pre><span><img src="./c.gif" border="0" alt="Read syntax diagram" longdesc="rzajpclobvarsyn2.htm" /></span><a href="#d0e329"><img src="./c.gif" border="0" alt="Skip visual syntax diagram" /></a>
>>-+--------+--+----------+--SQL TYPE IS--+-CLOB_LOCATOR---+---->
   +-auto---+ +-const----+ +-DBCLOB_LOCATOR-+   
   +-extern-+ '-volatile-' '-BLOB_LOCATOR---'   
   '-static-'    
   .-,----------------------------------.    
   V |    
>----<i>variable-name</i>--+-----------------+-+-- ; ----------------->&lt;
    '- = --<i>init-value</i>-'    
</pre><a name="d0e329"></a></div>
<div class="section"> <div class="note"><span class="notetitle">Notes:</span> <ol><li>SQL TYPE IS, BLOB_LOCATOR, CLOB_LOCATOR, DBCLOB_LOCATOR can be in mixed
case.</li>
<li><em>init-value</em> permits the initialization of pointer locator variables.
Other types of initialization will have no meaning.</li>
<li>Pointers to LOB Locators can be declared, with the same rules and restrictions
as for pointers to other host variable types.</li>
</ol>
</div>
</div>
<div class="section"><h4 class="sectiontitle"><em>CLOB Locator Example</em></h4><p>The following declaration: </p>
<pre>static SQL TYPE IS CLOB_LOCATOR my_locator;</pre>
<p>Results in the following generation: </p>
<pre>static long int unsigned my_locator;</pre>
<p>BLOB
and DBCLOB locators have similar syntax.</p>
</div>
<div class="section"><h4 class="sectiontitle">LOB file reference variable</h4><pre><span><img src="./c.gif" border="0" alt="Read syntax diagram" longdesc="rzajpclobvarsyn3.htm" /></span><a href="#d0e395"><img src="./c.gif" border="0" alt="Skip visual syntax diagram" /></a>
>>-+--------+--+----------+--SQL TYPE IS--+-CLOB_FILE---+------->
   +-auto---+ +-const----+ +-DBCLOB_FILE-+   
   +-extern-+ '-volatile-' '-BLOB_FILE---'   
   '-static-'    
   .-,----------------------------------.    
   V |    
>----<i>variable-name</i>--+-----------------+-+-- ; ----------------->&lt;
    '- = --<i>init-value</i>-'    
</pre><a name="d0e395"></a></div>
<div class="section"> <div class="note"><span class="notetitle">Notes:</span> <ol><li>SQL TYPE IS, BLOB_FILE, CLOB_FILE, DBCLOB_FILE can be in mixed case.</li>
<li>Pointers to LOB File Reference Variables can be declared, with the same
rules and restrictions as for pointers to other host variable types.</li>
</ol>
</div>
</div>
<div class="section"><h4 class="sectiontitle"><em>CLOB File Reference Example</em></h4><p>The following
declaration: </p>
<pre>static SQL TYPE IS CLOB_FILE my_file;</pre>
<p>Results
in the generation of the following structure: </p>
<pre>static _Packed struct {
unsigned long name_length;
unsigned long data_length;
unsigned long file_options;
char name[255];
} my_file;</pre>
<p>BLOB and DBCLOB file reference variables have similar
syntax.</p>
</div>
<div class="section"><p>The precompiler will generate declarations for the following file
option constants. You can use these constants to set the file_options variable
when you use File Reference host variables. </p>
<ul><li>SQL_FILE_READ (2)</li>
<li>SQL_FILE_CREATE (8)</li>
<li>SQL_FILE_OVERWRITE (16)</li>
<li>SQL_FILE_APPEND (32)</li>
</ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpdeclaringhostc.htm" title="The C and C++ precompilers recognize only a subset of valid C and C++ declarations as valid host variable declarations.">Declare host variables in C and C++ applications that use SQL</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../sqlp/rbafylobrefvar.htm">LOB file reference variables</a></div>
</div>
</div>
</body>
</html>