Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

SQL_DIAG_SEQ_GET - SQLdsg

SQL_DIAG_SEQ_GET can be used to obtain the function of the RETURN INTO clause of static INSERT statements for dynamic INSERT statements.

SQL_DIAG SEQ_GET returns the value determined by SESAM/SQL while executing an INSERT statement with COUNT INTO or with '*' in the VALUES clause.

The function can also be used for static INSERT statements.

It is made available as LLM 'SQLDSG' in the SIPLIB.SESAM-SQL.091.CLI library. If it is to be used in an application program, this LLM must either be explicitly linked to it or the library must be specified as BLSLIBxx when the program is executed. The interfaces for this functions are made available in the library as S type elements sqldsg.h (for C) and sqldsg (for COBOL).

CLI declaration in C:

extern void SQL_DIAG_SEQ_GET( struct SQLda_t *SQLda
          ,char *SequenceValue
          ,signed short *RC);

CLI declaration in COBOL:

IDENTIFICATION DIVISION.
PROGRAM-ID. SQLdsg IS PROTOTYPE.
DATA DIVISION.
LINKAGE SECTION.
   COPY SQLCA .     *> for group item SQLda
   01 SequenceValue PIC X(34).
   01 RC PIC S9(4) BINARY.
PROCEDURE DIVISION USING SQLda, SQL_SequenceValue, RC.
END PROGRAM SQLdsg.


SQLda

SQL diagnostics area with which the INSERT statement was executed. If the SQLda of a COBOL/ESQL program is to be referenced from a C program, it must be specified in COBOL as EXTERNAL.


SequenceValue

Storage area into which the result is to be transferred. The area must be at least 34 Bytes in size.

If the transfer is successful (RC=0), 34 characters have been written into SequenceValue in the following format and with at least one digit:

[<space>...]{+|}[digit...][.][digit...]<space>

The format is selected in such a way:

    • that the numerical value suitable for C variables of integer and floating point types can be obtained with the C functions strtol(), atol(), srtod(), strtof(), and atof().

    • that the numerical value suitable for any numeric COBOL variable can be obtained with the COBOL function NUMVAL.

In the case of RC ≠ 0, the contents of SequenceValue are not modified.


RC

Return value:

0

The desired value has been transferred to the storage area to which
SequenceValue refers.

-1

The input parameters were incorrect or the SQLda was not recognized as
diagnostics area.

100

It was not possible to determine a value assigned by SESAM/SQL.
Possible causes:


  • The INSERT statement contained no COUNT INTO clause and no '*' in the
    VALUES clause.


  • Execution of the INSERT statement unsuccessful, with an SQLSTATE of the
    category exception condition.


  • The SQL statement last executed with the same SQLda was not an INSERT
    statement.