Top
Enterprise Postgres 17 SP1 Application Development Guide

G.3 DBMS_SQL Package for Fujitsu Enterprise Postgres 16 SPz and earlier

Describes the DBMS_SQL package that was provided prior to Fujitsu Enterprise Postgres 16 SPz.

The interface described here is a compatibility interface for applications prior to Fujitsu Enterprise Postgres 16 SPz. As it will no longer be supported in the future, do not use it for any purpose other than application compatibility.

Feature

Description

BIND_VARIABLE

Sets values in the host variable within the SQL statement.

CLOSE_CURSOR

Closes the cursor.

COLUMN_VALUE

Retrieves the value of the column in the select list extracted with FETCH_ROWS.

DEFINE_COLUMN

Defines the column from which values are extracted and the storage destination.

EXECUTE

Executes SQL statements.

FETCH_ROWS

Positions the specified cursor at the next row and extracts values from the row.

OPEN_CURSOR

Opens a new cursor.

PARSE

Parses SQL statements.

Note

  • In DBMS_SQL, the data types supported in dynamic SQL are limited, and therefore the user must consider this. The supported data types are:

    • INTEGER

    • DECIMAL

    • NUMERIC

    • REAL

    • DOUBLE PRECISION

    • CHAR(*1)

    • VARCHAR(*1)

    • NCHAR(*1)

    • NCHAR VARYING(*1)

    • TEXT

    • DATE

    • TIMESTAMP WITHOUT TIME ZONE

    • TIMESTAMP WITH TIME ZONE

    • INTERVAL(*2)

    • SMALLINT

    • BIGINT

      *1:
      The host variables with CHAR, VARCHAR, NCHAR, and NCHAR VARYING data types are treated as TEXT, to match the string function arguments and return values. Refer to "String Functions and Operators" in "Functions and Operators" in "The SQL Language" in the PostgreSQL Documentation for information on string functions.
      When specifying the arguments of the features compatible with Oracle databases NVL and/or DECODE, use CAST to convert the data types of the host variables to ensure that data types between arguments are the same.

      *2:
      When using COLUMN_VALUE to obtain an INTERVAL type value specified in the select list, use an INTERVAL type variable with a wide range such as when no interval qualifier is specified, or with a range that matches that of the variable in the select list. If an interval qualifier variable with a narrow range is specified, then the value within the interval qualifier range will be obtained, but an error that the values outside the range have been truncated will not occur.

      Example

      This example illustrates where a value expression that returns an INTERVAL value is set in the select list and the result is received with COLUMN_VALUE. Note that the SQL statement operation result returns a value within the INTERVAL DAY TO SECOND range.

      [Bad example]

      Values of MINUTE, and those after MINUTE, are truncated, because the variable(v_interval) is INTERVAL DAY TO HOUR.

          v_interval     INTERVAL DAY TO HOUR;
      ...
          PERFORM DBMS_SQL.PARSE(cursor, 'SELECT CURRENT_TIMESTAMP - ''2010-01-01'' FROM DUAL', 1);
      ...
          SELECT value INTO v_interval FROM DBMS_SQL.COLUMN_VALUE(cursor, 1, v_interval);
          result:1324 days 09:00:00

      [Good example]

      By ensuring that the variable(v_interval) is INTERVAL, the values are received correctly.

          v_interval     INTERVAL;
      ...
          PERFORM DBMS_SQL.PARSE(cursor, 'SELECT CURRENT_TIMESTAMP - ''2010-01-01'' FROM DUAL', 1);
      ...
          SELECT value INTO v_interval FROM DBMS_SQL.COLUMN_VALUE(cursor, 1, v_interval);
          result:1324 days 09:04:37.530623
Syntax
{ BIND_VARIABLE(cursor, varName, val [, len ])
| CLOSE_CURSOR(cursor)
| COLUMN_VALUE(cursor, colPos, varName)
| DEFINE_COLUMN(cursor, colPos, varName [, len ])
| EXECUTE(cursor)
| FETCH_ROWS(cursor)
| OPEN_CURSOR([parm1 ])
| PARSE(cursor, sqlStmt, parm1 [, parm2, parm3, parm4 ]) 
}