SAP HANA Database – SQL Command Network Protocol Reference ?SAP HANA Platform SPS 07
Target Audience
■Developers
Public
Document Version 1.0 – 27-11-2013
Copyright
? 2013 SAP AG or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are trademarks or registered trademarks of Adobe Systems Incorporated in the United States and other countries.
Apple, App Store, FaceTime, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, Retina, Safari, Siri, and Xcode are trademarks or registered trademarks of Apple Inc.
Bluetooth is a registered trademark of Bluetooth SIG Inc.
Citrix, ICA, Program Neighborhood, MetaFrame now XenApp, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems Inc.
Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.
Edgar Online is a registered trademark of EDGAR Online Inc., an R.R. Donnelley & Sons Company.
Facebook, the Facebook and F logo, FB, Face, Poke, Wall, and 32665 are trademarks of Facebook.
Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps, Google Mobile Ads, Google Mobile Updater, Google Mobile, Google Store, Google Sync, Google Updater, Google Voice, Google Mail, Gmail, YouTube, Dalvik, and Android are trademarks or registered trademarks of Google Inc.
HP is a registered trademark of the Hewlett-Packard Development Company L.P.
HTML, XML, XHTML, and W3C are trademarks, registered trademarks, or claimed as generic terms by the Massachusetts Institute of Technology (MIT), European Research Consortium for Informatics and Mathematics (ERCIM), or Keio University.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, z10, z/VM, z/OS, OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems, POWER7, POWER6+, POWER6, POWER, PowerHA, pureScale, PowerPC, BladeCenter, System Storage, Storwize, XIV, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX, Intelligent Miner, WebSphere, Tivoli, Informix, and Smarter Planet are trademarks or registered trademarks of IBM Corporation.
Microsoft, Windows, Excel, Outlook, PowerPoint, Silverlight, and Visual Studio are registered trademarks of Microsoft Corporation.
INTERMEC is a registered trademark of Intermec Technologies Corporation.
IOS is a registered trademark of Cisco Systems Inc.
The Klout name and logos are trademarks of Klout Inc.
Linux is the registered trademark of Linus Torvalds in the United States and other countries. Motorola is a registered trademark of Motorola Trademark Holdings LLC.
Mozilla and Firefox and their logos are registered trademarks of the Mozilla Foundation. Novell and SUSE Linux Enterprise Server are registered trademarks of Novell Inc. OpenText is a registered trademark of OpenText Corporation.
Oracle and Java are registered trademarks of Oracle and its affiliates.
QR Code is a registered trademark of Denso Wave Incorporated.
RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold, BlackBerry Pearl, BlackBerry Torch, BlackBerry Storm, BlackBerry Storm2, BlackBerry PlayBook, and BlackBerry AppWorld are trademarks or registered trademarks of Research in Motion Limited.
SAVO is a registered trademark of The Savo Group Ltd.
The Skype name is a trademark of Skype or related entities.
Twitter and Tweet are trademarks or registered trademarks of Twitter.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Wi-Fi is a registered trademark of Wi-Fi Alliance.
SAP, R/3, ABAP, BAPI, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, SAP HANA, the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, Sybase, Adaptive Server, Adaptive Server Enterprise, iAnywhere, Sybase 365, SQL Anywhere, Crossgate, B2B 360° and B2B 360° Services, m@gic EDDY, Ariba, the Ariba logo, Quadrem, b-process, Ariba Discovery, SuccessFactors, Execution is the Difference, BizX Mobile Touchbase, It's time to love work again, SuccessFactors Jam and BadAss SaaS, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany or an SAP affiliate company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
Icons in Body Text
Icon Meaning
Caution
Example
Note
Recommendation
Syntax
Additional icons are used in SAP Library documentation to help you identify different types of information at a glance. For more information, see Help on Help→General Information
Classes and Information Classes for Business Information Warehouse on the first page of any version of SAP Library.
Typographic Conventions
Type Style Description
Example text Words or characters quoted from the screen. These include field
names, screen titles, pushbuttons labels, menu names, menu paths,
and menu options.
Cross-references to other documentation.
Example text Emphasized words or phrases in body text, graphic titles, and table
titles.
EXAMPLE TEXT Technical names of system objects. These include report names,
program names, transaction codes, table names, and key concepts of a
programming language when they are surrounded by body text, for
example, SELECT and INCLUDE.
Example text Output on the screen. This includes file and directory names and their
paths, messages, names of variables and parameters, source text, and
names of installation, upgrade and database tools.
Example text Exact user entry. These are words or characters that you enter in the
system exactly as they appear in the documentation.
words and characters with appropriate entries to make entries in the
system.
EXAMPLE TEXT Keys on the keyboard, for example, F2 or ENTER.
Introduction (8)
Content Overview (8)
Terminology (8)
Protocol Modification (9)
Message Format (10)
Message Header (10)
Segment Header (11)
Segment Kind (11)
Message Type (12)
Command Options (12)
Function Code (13)
Part Header (13)
Part Kind (13)
Part Attributes (14)
Use of Parts in Request Messages (15)
Use of Parts in Reply Messages (16)
Type Codes (17)
Part Data Format (19)
Option Part Format (19)
Multi-Line Option Part Format (20)
COMMAND (20)
RESULTSET (20)
ERROR (21)
STATEMENTID (21)
TRANSACTIONID (21)
ROWSAFFECTED (21)
RESULTSETID (22)
TOPOLOGYINFORMATION (22)
TABLELOCATION (23)
READLOBREQUEST (23)
READLOBREPLY (23)
ABAPISTREAM (24)
ABAPOSTREAM (24)
COMMANDINFO (24)
WRITELOBREQUEST (25)
WRITELOBREPLY (25)
PARAMETERS (25)
AUTHENTICATION (25)
SESSIONCONTEXT (26)
PARTITIONINFORMATION (27)
OUTPUTPARAMETERS (28)
CONNECTOPTIONS (28)
COMMITOPTIONS (32)
FETCHOPTIONS (32)
FETCHSIZE (33)
PARAMETERMETADATA (33)
RESULTSETMETADATA (34)
FINDLOBREQUEST (34)
FINDLOBREPLY (35)
ITABSHM (35)
CLIENTINFO (35)
STREAMDATA (36)
BATCHPREPARE (36)
BATCHEXECUTE (36)
TRANSACTIONFLAGS (36)
Input Field Format (36)
TINYINT (36)
SMALLINT (36)
INT (36)
BIGINT (37)
DECIMAL (37)
REAL (37)
DOUBLE (37)
STRING/NSTRING (37)
BINARY (37)
BLOB/CLOB/NCLOB (37)
DATE (38)
TIME (38)
TIMESTAMP (38)
ABAPSTRUCT (38)
LONGDATE (39)
SECONDDATE (39)
DAYDATE (39)
SECONDTIME (39)
Output Field Format (39)
TINYINT (39)
SMALLINT (40)
INT (40)
DECIMAL (40)
REAL (41)
DOUBLE (41)
STRING/NSTRING (41)
BINARY (41)
BLOB/CLOB/NCLOB (41)
DATE (42)
TIME (42)
TIMESTAMP (42)
ABAPITAB (42)
ABAPSTRUCT (42)
LONGDATE (42)
SECONDDATE (42)
DAYDATE (43)
SECONDTIME (43)
Usage Scenarios (43)
Communication Initialization (43)
Authentication and Connect (43)
SCRAMSHA256 Authentication (45)
GSS Authentication (46)
SAML Authentication (47)
Session Cookie Authentication (49)
Statement Execution (50)
Direct Statement Execution (50)
Preparing a Statement (51)
Executing a Statement (51)
Fetching Result Data (51)
Writing Large Object Data (52)
Reading Large Object Data (52)
ABAP Stream Handling (53)
Distributed Transaction Handling (53)
Statement Routing (53)
Definition (53)
Preconditions (54)
Glossary (54)
Introduction
This document describes the SQL Command Network Protocol of the SAP HANA database, the protocol used by SAP HANA database clients to communicate with the SAP HANA database.
Content Overview
This document is divided in to the following chapters:
Chapter 2: Message Format
This chapter describes the binary message format used in the communication, and explains the purpose of the various protocol elements.
Chapter 3: Usage Scenarios
This chapter discusses usage scenarios for the various messages defined in the SQL Command Network Protocol, and defines usage sequences to utilize certain functionalities of the database server, such as:
?User authentication and connect process
?Execution of prepared statements
?Handling of large object data
?Usage of distributed transaction handling
Terminology
Within this document, a message describes requests or replies exchanged between client and server. A request is always a message sent by the client, and a reply is always the message sent by the server.
The following abbreviations are used to describe data types in message formats:
Abbreviation Data Type C Data Type1
I1 1-byte integer value char
UI1 1-byte unsigned integer value unsigned char B 1-byte unsigned integer value, or “one byte” unsigned char I2 2-byte integer in little-endian format short
UI2 2-byte unsigned integer in little-endian format unsigned short BI2 2-byte integer in big-endian format unsigned short I4 4-byte integer in little-endian format int
NI4 4-byte integer in client native (big/little-endian) format int
UI4 4-byte unsigned integer in little-endian format unsigned int
I8 8-byte integer in little-endian format long
NUI8 8-byte unsigned integer in client native (big/little-
endian) format
unsigned long
FLOAT IEEE single precision floating point value in little-
endian format
float
1 For a Linux GCC in an x86-64 architecture environment
DOUBLE IEEE double precision floating point value in little-
endian format
double
X[n] Array of n elements of data type X. -
Protocol Modification
The SQL Command Network Protocol must be kept stable so that clients are able to communicate with recent version server software, and vice versa. A more recent client may have to degrade the usage of the protocol depending on the server version, and a more recent server may have to use only certain features if non-recent client software is detected. Detection is performed during connection by exchanging connect options, which specify the required behavior of the client, and getting the supported feature set from the server. This detection does not perform global versioning, but enables or disables feature flags, or modifies certain functionality.
Additions to the protocol usually require careful modification and extension of the exchanged connect options.
Message Format
This chapter discusses the format of messages exchanged between the client and the server. The communication between client and server is completely synchronous, such that the client can only send the next request once the reply of the previous request has been fully received.
A client is, however, free to continue with its own processing, or communicate with other servers of a SAP HANA database system while waiting for the answer.
A message consists of a fixed part, called the message header, and a variable length message buffer. The message buffer contains message segments, which, in turn, consist of a segment header and a segment buffer. The segment buffer contains parts, and the parts have a fixed length part header, and a variable length buffer.
+----------------------------+
| MESSAGE HEADER |
| +------------------------+ |
| | SEGMENT HEADER | |
| | +--------------------+ | |
| | | PART HEADER | | |
| | +--------------------+ | |
| | | PART BUFFER | | |
| | +--------------------+ | |
| | ... | |
| +------------------------+ |
| ... |
+----------------------------+
There is one exception to this format – during the communication initialization a different message pair is exchanged, which is necessary to distinguish the current and former protocol variants.
Message Header
The message header is a structure which has a size of 32-bytes, and consists of the following fields:
+---------+-----------+-------------+-----------+--------+-------------+--------+
|SESSIONID|PACKETCOUNT|VARPARTLENGTH|VARPARTSIZE|NOOFSEGM|PACKETOPTIONS|RESERVED|
+---------+-----------+-------------+-----------+--------+-------------+--------+
Field Data Type Description
SESSIONID I8 Session identifier
PACKETCOUNT I4 Packet sequence number in this session. Packets having the same sequence number belong to one
request/response pair.
VARPARTLENGTH UI4 Used space in packet, maximum is 2G -1 VARPARTSIZE UI4 Total space in packet, maximum is 2G -1 NOOFSEGM I2 Number of segments in packet PACKETOPTIONS I1 Reserved, do not use
RESERVED B[9] Reserved, do not use
Segment Header
The segment header has a length of 24-bytes. There are different segment header structures for request and reply, but both have the same definition for first 13-bytes of the structure. They are structured as follows:
Request Segment Header
+---------------+------------+-----------+-----------+-------------+
| SEGMENTLENGTH | SEGMENTOFS | NOOFPARTS | SEGMENTNO | SEGMENTKIND | . . .
+---------------+------------+-----------+-----------+-------------+
+-------------+--------+----------------+-----------+
. . . | MESSAGETYPE | COMMIT | COMMANDOPTIONS | RESERVED1 |
+-------------+--------+----------------+-----------+
Reply Segment Header
+---------------+------------+-----------+-----------+-------------+
| SEGMENTLENGTH | SEGMENTOFS | NOOFPARTS | SEGMENTNO | SEGMENTKIND | . . .
+---------------+------------+-----------+-----------+-------------+
+-----------+--------------+-----------+
. . . | RESERVED2 | FUNCTIONCODE | RESERVED3 |
+-----------+--------------+-----------+
Field Data Type Description
SEGMENTLENGTH I4 Length of the segment, including the header SEGMENTOFS I4 Offset of the segment within the message buffer NOOFPARTS I2 Number of contained parts
SEGMENTNO I2 Number of segments within packet
SEGMENTKIND I1 See Segment Kind
MESSAGETYPE I1 See Message Type
COMMIT I1 Whether the command is committed COMMANDOPTIONS I1 See Command Options
RESERVED1 B[8] Reserved, do not use
RESERVED2 I1 Reserved, do not use
FUNCTIONCODE I2 See Function Code
RESERVED3 B[8] Reserved, do not use
Segment Kind
This field is the last field of the segment header part, common to all types (kinds) of segments, and defines the segment kind, which further specifies the layout of the remaining segment header structure. The following values are defined:
Value Description
0 Reserved for invalid segments, do not use
1 Request segment
2 Reply segment
5 Error segment (reply segment containing error)
Message Type
The message type defines the action requested from the database server. The following values are defined:
Value Identifier Description
0 NIL Reserved for invalid messages, do not use
2 EXECUTEDIRECT Directly execute SQL statement
3 PREPARE Prepare an SQL statement
4 ABAPSTREAM Handle ABAP stream parameter of database procedure
5 XA_START Start a distributed transaction
6 XA_JOIN Join a distributed transaction
13 EXECUTE Execute a previously prepared SQL statement
16 WRITELOB Writes large object data
17 READLOB Reads large object data
18 FINDLOB Finds data in a large object
25 PING Reserved (was PING message)
65 AUTHENTICATE Sends authentication data
66 CONNECT Connects to the database
67 COMMIT Commits current transaction
68 ROLLBACK Rolls back current transaction
69 CLOSERESULTSET Closes result set
70 DROPSTATEMENTID Drops prepared statement identifier
71 FETCHNEXT Fetches next data from result set
72 FETCHABSOLUTE Moves the cursor to the given row number and fetches
the data.
73 FETCHRELATIVE Moves the cursor a number of rows relative to the
position, either positive or negative, and fetches the data.
74 FETCHFIRST Moves the cursor to the first row and fetches the data.
75 FETCHLAST Moves the cursor to the last row and fetches the data.
77 DISCONNECT Disconnects session
78 EXECUTEITAB Executes command in Fast Data Access mode
79 FETCHNEXTITAB Fetches next data for ITAB object in Fast Data Access mode
80 INSERTNEXTITAB Inserts next data for ITAB object in Fast Data Access
mode
81 BATCHPREPARE Reserved (was multiple statement preparation) Command Options
The command options field is a bit set that allows specific options for the sent message to be defined:
Bit Identifier Description
1 RESERVED_FIELD Reserved field, do not use
3 HOLD_CURSORS_OVER_COMMIT Keeps result set created by this command over commit time
4 EXECUTE_LOCALLY Executes command only on local partitions of affected partitioned table
5 SCROLL_INSENSITIVE Marks result set created by this command as scroll insensitive
Function Code
The function code identifies the nature of the statement or functionality that has been prepared or executed.
Value Identifier Description
0 NIL Invalid command or function
1 DDL DDL statement
2 INSERT INSERT statement
3 UPDATE UPDATE statement
4 DELETE DELETE statement
6 SELECTFORUPDATE SELECT … FOR UPDATE statement
7 EXPLAIN EXPLAIN statement
8 DBPROCEDURECALL CALL statement
9 DBPROCEDURECALLWITHRESULT CALL statement returning one or more
results
10 FETCH FETCH message
11 COMMIT COMMIT message or statement
12 ROLLBACK ROLLBACK message or statement
13 SAVEPOINT Reserved, do not use
14 CONNECT CONNECT or AUTHENTICATION message
15 WRITELOB WRITELOB message
16 READLOB READLOB message
17 PING Reserved, do not use
18 DISCONNECT DISCONNECT message
19 CLOSECURSOR CLOSECURSOR message
20 FINDLOB FINDLOB message
21 ABAPSTREAM ABAPSTREAM message
22 XASTART XA_START message
23 XAJOIN XA_JOIN message
Part Header
The part header is 16-bytes in length, and has the following structure:
+--------+--------------+-------------+----------------+------------+----------+
|PARTKIND|PARTATTRIBUTES|ARGUMENTCOUNT|BIGARGUMENTCOUNT|BUFFERLENGTH|BUFFERSIZE|
+--------+--------------+-------------+----------------+------------+----------+
The header fields are defined as follows:
Field Data Type Description
PARTKIND I1 Specifies nature of part data (see Part Kind) PARTATTRIBUTES I1 Further attributes of part (see Part Attributes) ARGUMENTCOUNT I2 Argument count, number of elements in part data
BIGARGUMENTCOUNT I4 Argument count, number of elements in part data (only for some part kinds)
BUFFERLENGTH I4 Length of part buffer in bytes (used space) BUFFERSIZE I4 Length in packet remaining without this part
Part Kind
The following values are defined for the PARTKIND field:
Value Identifier Description
0 NIL Reserved for invalid part, do not use
3 COMMAND SQL Command Data
5 RESULTSET Tabular result set data
6 ERROR Error information
10 STATEMENTID Prepared statement identifier
11 TRANSACTIONID Transaction identifier
12 ROWSAFFECTED Number of affected rows of DML statement
13 RESULTSETID Identifier of result set
15 TOPOLOGYINFORMATION Topology information
16 TABLELOCATION Location of table data
17 READLOBREQUEST Request data of READLOB message
18 READLOBREPLY Reply data of READLOB message
25 ABAPISTREAM ABAP input stream identifier
26 ABAPOSTREAM ABAP output stream identifier
27 COMMANDINFO Command information
28 WRITELOBREQUEST Request data of WRITELOB message
30 WRITELOBREPLY Reply data of WRITELOB message
32 PARAMETERS Parameter data
33 AUTHENTICATION Authentication data
34 SESSIONCONTEXT Session context information
39 STATEMENTCONTEXT Statement visibility context
40 PARTITIONINFORMATION Table partitioning information
41 OUTPUTPARAMETERS Output parameter data
42 CONNECTOPTIONS Connect options
43 COMMITOPTIONS Commit options
44 FETCHOPTIONS Fetch options
45 FETCHSIZE Number of rows to fetch
47 PARAMETERMETADATA Parameter metadata (type and length information)
48 RESULTSETMETADATA Result set metadata (type, length, and name information)
49 FINDLOBREQUEST Request data of FINDLOB message
50 FINDLOBREPLY Reply data of FINDLOB message
51 ITABSHM Information on shared memory segment used for ITAB transfer
53 ITABCHUNKMETADATA Reserved, do not use
55 ITABMETADATA Information on ABAP ITAB structure for ITAB transfer
56 ITABRESULTCHUNK ABAP ITAB data chunk
57 CLIENTINFO Client information values
58 STREAMDATA ABAP stream data
59 OSTREAMRESULT ABAP output stream result information
60 FDAREQUESTMETADATA Information on memory and request details for FDA
request
61 FDAREPLYMETADATA Information on memory and request details for FDA
reply
62 BATCHPREPARE Reserved, do not use
63 BATCHEXECUTE Reserved, do not use
64 TRANSACTIONFLAGS Transaction handling flags
65 ROWDATAPARTMETADATA Reserved, do not use
66 COLDATAPARTMETADATA Reserved, do not use
Part Attributes
The part attributes make up a bit set to indicate special features of a certain part. The following values are defined:
Bit Identifier Description
0 LASTPACKET Last part in a sequence of parts (FETCH, array command
EXECUTE)
1 NEXTPACKET Part in a sequence of parts
2 FIRSTPACKET First part in a sequence of parts
3 ROWNOTFOUND Empty part, caused by “row not found” error
4 RESULTSETCLOSED The result set that produced this part is closed
5 RESERVED5 Reserved, do not use
6 RESERVED6 Reserved, do not use
7 RESERVED7 Reserved, do not use
Use of Parts in Request Messages
The following table shows the parts that can be used in various request message types. The letter X denotes the default relationship between the part and message. Any letters other than X denote a conditional relationship, which are described in further detail below the table. MESSAGE TYPE PART KIND E X E C U T E D I R E C T P R E P A R E A B A P S
T R E A M X A _S T A R T X A _J O I N E X E C U T E W R I T E L O B
R E
A D L O
B F I N D L O B A U T H E N T I
C A T E C O N N E C T C O M M I T R O L
L B A C K F E
T C H
N E
X T
D I
S C O N N E C
T
C L O S E R E S U L T S E T
D R O P S T A T
E M E N T I D
E X E
C U T E
I
T A B F E
T C H N E X
T I T A
B
I
N S
E
R
T
N E
X
T
I T
A
B
NIL COMMAND X X RESULTSET ERROR STATEMENTID X X TRANSACTIONID X ROWSAFFECTED RESULTSETID X X TOPOLOGYINFORMATION TABLELOCATION READLOBREQUEST X READLOBREPLY ABAPISTREAM X ABAPOSTREAM X COMMANDINFO X X X WRITELOBREQUEST X WRITELOBREPLY PARAMETERS B AUTHENTICATION X X SESSIONCONTEXT A A A A A A A A A A A A A A A A A A A A STATEMENTCONTEXT A A A A A A A A A A A A A A A A A A A A PARTITIONINFORMATION OUTPUTPARAMETERS CONNECTOPTIONS X COMMITOPTIONS X X FETCHOPTIONS X FETCHSIZE X
PARAMETERMETADATA RESULTSETMETADATA FINDLOBREQUEST X FINDLOBREPLY ITABSHM ITABCHUNKMETADATA ITABMETADATA ITABRESULTCHUNK CLIENTINFO C C C C STREAMDATA X OSTREAMRESULT X FDAREQUESTMETADATA FDAREPLYMETADATA BATCHPREPARE BATCHEXECUTE TRANSACTIONFLAGS
A – This part can always be sent if distributed transaction handling requires it
B – Only in the case that the prepared statement has input parameters
C – In the case the client application did set information flags
Use of Parts in Reply Messages
The following table shows the parts that can be used in various reply message types. The letter X denotes the default relationship between the part and message. Any letters other than X denote a conditional relationship, which are described in further detail below the table. MESSAGE TYPE PART KIND E X E C U T E D I R E C T P R E P A R E
A B A P S T R E A M X A _S T A R T X A _J O I N E X E C U T E
W R I T E L O B R E A D L O B F I
N D L O
B A U T H E
N T I C A T E C O N N E C T
C O M M I T R O L L B A C K
F E T C H N E X T D I
S C
O
N N E C
T C L O S E R E S U L T S E T
D R O P S T A T
E M E N T I
D
E X E
C
U T
E
I
T
A
B F E
T
C H
N E
X
T I
T A
B
I
N S
E
R
T
N E
X
T I
T
A B
NIL COMMAND RESULTSET A A ERROR B B B B B B B B B
STATEMENTID X TRANSACTIONID X ROWSAFFECTED C C RESULTSETID A A TOPOLOGYINFORMATION TABLELOCATION E READLOBREQUEST READLOBREPLY X ABAPISTREAM X ABAPOSTREAM X COMMANDINFO WRITELOBREQUEST WRITELOBREPLY X PARAMETERS
AUTHENTICATION X
SESSIONCONTEXT
STATEMENTCONTEXT H H H H H H H H H
PARTITIONINFORMATION E
OUTPUTPARAMETERS G
CONNECTOPTIONS
COMMITOPTIONS
FETCHOPTIONS
FETCHSIZE
PARAMETERMETADATA F
RESULTSETMETADATA A A A
FINDLOBREQUEST
FINDLOBREPLY X
ITABSHM
ITABCHUNKMETADATA
ITABMETADATA
ITABRESULTCHUNK
CLIENTINFO
STREAMDATA X
OSTREAMRESULT X
FDAREQUESTMETADATA
FDAREPLYMETADATA
BATCHPREPARE
BATCHEXECUTE
TRANSACTIONFLAGS D D D D D D D D
A – Only in the case that the message yields one or more result sets
B – Always as a reply in case of errors while processing the statement
C – Only in the case that the statement generates a row count of affected rows
D – Always if the statement caused an action in transaction handling (commit, rollback, or
start of a new write transaction)
E – Only in the case that the server has information useful to applying statement routing (see the corresponding Usage Scenario Statement Routing)
F – Only in the case that the statement has input and/or output parameters
G – Only in the case that the statement has output parameters
H – Indicates a possible change of visible version
Type Codes
Type codes identify the type of a field transferred from or to the database. Not all type codes known and processed internally are used in the protocol, and clients may support a different level of type support depending on their version. The protocol mechanism (connect options)for connecting to the database is used to ensure that the client sends the server data it is able to process, and receives only data it can process from the server.
Type codes are in the range of 0-127, as the most significant bit is used on input to signal a NULL value of a certain type.
Value Identifier Description Support Level
0 NULL NULL value -
1 TINYINT TINYINT 1
2 SMALLINT SMALLINT 1
3 INT INTEGER 1
4 BIGINT BIGINT 1
5 DECIMAL DECIMAL, and
1
DECIMAL(p,s)
6 REAL REAL 1
7 DOUBLE DOUBLE 1
8 CHAR CHAR 1
9 VARCHAR VARCHAR 1
10 NCHAR NCHAR (Unicode character
1
type)
11 NVARCHAR NVARCHAR (Unicode
1
character type)
12 BINARY BINARY 1
13 VARBINARY VARBINARY 1
14 DATE DATE (deprecated type) 1 (deprecated with 3)
15 TIME TIME (deprecated type) 1 (deprecated with 3)
16 TIMESTAMP TIMESTAMP (millisecond
1 (deprecated with 3)
precision)
17 TIME_TZ Reserved, do not use -
18 TIME_LTZ Reserved, do not use -
19 TIMESTAMP_TZ Reserved, do not use -
20 TIMESTAMP_LTZ Reserved, do not use -
21 INTERVAL_YM Reserved, do not use -
22 INTERVAL_DS Reserved, do not use -
23 ROWID Reserved, do not use -
24 UROWID Reserved, do not use -
25 CLOB Character Large Object 1
26 NCLOB Unicode Character Large
1
Object
27 BLOB Binary Large Object 1
28 BOOLEAN Reserved, do not use -
29 STRING Character string 1
30 NSTRING Unicode character string 1
31 BLOCATOR Binary locator 1
32 NLOCATOR Unicode character locator 1
33 BSTRING Binary string 1
34 DECIMAL_DIGIT_ARRAY Reserved, do not use -
35 VARCHAR2 VARCHAR -
36 VARCHAR3 VARCHAR -
37 NVARCHAR3 NVARCHAR -
38 VARBINARY3 VARBINARY -
39 VARGROUP Reserved, do not use -
40 TINYINT_NOTNULL Reserved, do not use -
41 SMALLINT_NOTNULL Reserved, do not use -
42 INT_NOTNULL Reserved, do not use -
43 BIGINT_NOTNULL Reserved, do not use -
44 ARGUMENT Reserved, do not use -
45 TABLE Reserved, do not use -
46 CURSOR Reserved, do not use -
47 SMALLDECIMAL SMALLDECIMAL data type -
48 ABAPITAB ABAPSTREAM procedure
1
parameter
49 ABAPSTRUCT ABAP structure procedure
1
parameter
50 ARRAY Reserved, do not use -
51 TEXT TEXT data type 3
52 SHORTTEXT SHORTTEXT data type 3
53 BINTEXT BINTEXT data type 6
54 FIXEDPOINTDECIMAL Reserved, do not use -
55 ALPHANUM ALPHANUM data type 3
56 TLOCATOR Reserved, do not use -
61 LONGDATE TIMESTAMP data type 3
62 SECONDDATE TIMESTAMP type with
3
second precision
63 DAYDATE DATE data type 3
64 SECONDTIME TIME data type 3
65 CSDATE Reserved, do not use -
66 CSTIME Reserved, do not use -
71 BLOB_DISK Reserved, do not use -
72 CLOB_DISK Reserved, do not use -
73 NCLOB_DISK Reserved, do not use -
74 GEOMETRY Spatial data 5
75 POINT Spatial data 5
76 FIXED16 Reserved, do not use -
77 BLOB_HYBRID Reserved, do not use -
78 CLOB_HYBRID Reserved, do not use -
79 NCLOB_HYBRID Reserved, do not use -
80 POINTZ Spatial data 5
Part Data Format
This section describes the format of parts transmitted in messages between the client and the database server. The format of the data transmitted is uniquely identified by the part kind, some part kinds share the same format as the contained data.
Option Part Format
A common format is used to transmit options, that is, typed key-value pairs. An option part contains elements having the following structure:
+------------+------------+-------------+
| OPTIONNAME | OPTIONTYPE | OPTIONVALUE |
+------------+------------+-------------+
The fields are defined as follows:
Field Data Type Description
OPTIONNAME I1 Option key to identify the option
OPTIONTYPE I1 Type code of option value
OPTIONVALUE B[…] Option data
Only some type codes are understood for the option type field, and the data format of the option data is as follows:
Type Code Value Format
BOOLEAN 1-byte, zero for false, non-zero for true value
INT 4-byte signed integer (int), little-endian format
BIGINT 8-byte signed integer (long), little-endian format
STRING 2-byte signed integer (short) length information, little-endian format, followed by the string in CESU-8 encoding (number of bytes is specified by length information)
BSTRING 2-byte signed integer (short) length information, little-endian format, followed by the binary string (number of bytes is specified by length information)
DOUBLE IEEE double precision value, little-endian
Multi-Line Option Part Format
A common format is used to transmit collections of options (typed key-value pairs). An option part contains rows having the following structure. The number of rows is the part argument count value.
+----------+--------+--------+
| ARGCOUNT | OPTION | OPTION | . . .
+----------+--------+--------+
The fields are defined as follows:
Field Data Type Description
ARGCOUNT I2 Number of options in a row
OPTION Option element, as described in option part format
Different rows can have a different argument count, so the format is not completely tabular. COMMAND
The COMMAND part contains the text of an SQL command. The text is always encoded in CESU-8 encoding.
RESULTSET
A result set part contains row data of a result set. The fields of the individual rows are formatted as defined in the output field format section. One result set part contains as many rows as the argument count field indicates:
+-----------+-----------+-----+-----------+
| ROW1/COL1 | ROW1/COL2 | ... | ROW1/COLn |
+-----------+-----------+-----+-----------+
| ROW2/COL1 | . . . | ROW2/COLn |
+-----------+-----------------+-----------+
. . .
+-----------+-----------+-----+-----------+
| ROWm/COL1 | ROWn/COL2 | ... | ROWm/COLn |
+-----------+-----------+-----+-----------+
Note that the field values may have variable lengths, depending on the data type. Therefore, all the values in the current row must be scanned before moving to the next row.