1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
<HTML
><HEAD
><TITLE
>SQL Communication Area</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.54"><LINK
REL="HOME"
TITLE="GNADE User's Guide"
HREF="gnade.html"><LINK
REL="UP"
TITLE="Embedded SQL Syntax Specification"
HREF="esqlsyntax.html"><LINK
REL="PREVIOUS"
TITLE="Handling of return codes"
HREF="x303.htm"><LINK
REL="NEXT"
TITLE="Connection Handling"
HREF="x320.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GNADE User's Guide: GNADE, The GNat Ada Database Environment; Version 1.2.0; Document Revision $Revision: 1.26 $</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x303.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 11. Embedded SQL Syntax Specification</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x320.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN308"
>SQL Communication Area</A
></H1
><P
>The GNU.DB.ESQL_SUPPORT package provides a so called SQL communication
area type. This area contains informations about the result of the
last query.
<PRE
CLASS="PROGRAMLISTING"
>Syntax:
<include_sqlca_clause> ::=
INCLUDE SQLCA </PRE
>
This statement will insert a SQLCA in the Ada 95 code. If this is
done in the declare section of a procedure as shown below, the SQLCA
will be declared local to the procedure.
<DIV
CLASS="EXAMPLE"
><P
><B
>Example 11-2. Local SQLCA in procedures</B
></P
><PRE
CLASS="PROGRAMLISTING"
> procedure Print_Departement(
departement : in Integer ) is
---
EXEC SQL BEGIN DECLARE SECTION END-EXEC
Name : CHAR(1..15) := (others=>32);
.............
Salary : DOUBLE_PRECISION := 0.0;
EXEC SQL END DECLARE SECTION END-EXEC
EXEC SQL INCLUDE SQLCA ; -- Make a private SQLCA
begin
.....
EXEC SQL AT DB01
DECLARE emp_cursor CURSOR FOR
SELECT EMPNO, FIRSTNAME, NAME, JOB, MANAGER, SALARY
FROM employees
WHERE deptno = :Depno ;
....
end;</PRE
></DIV
>
The application may access the contents by using the variable
name SQLCA in the application code. This method is
preferable in a multi thread environment, because it
avoids interferences between threads through the
global variables SQLCODE and SQLSTATE.</P
><P
>The SQLCA provides several fields containing usefull information about the
most recently executed query as shown below:</P
><PRE
CLASS="PROGRAMLISTING"
> type SQLCA_Type is record
Message : aliased String(1..255 );
State : aliased SQLSTATE_TYPE;
SqlCode : aliased SQLCODE_TYPE;
Affected_Rows : aliased Integer := 0;
end record; </PRE
><P
>The parameter Affected_Rows contains the number of rows affected by
the last query.</P
><P
>State and SqlCode do contain the result code of the last
query. The SqlCode should not be used any more because the
State information contains more information.</P
><P
>The field Message contains a string generated by the underlying
dbcs containing information bout the most recent error.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x303.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="gnade.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x320.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Handling of return codes</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="esqlsyntax.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Connection Handling</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|