Updated on 2024-06-03 GMT+08:00

DBE_DESCRIBE

Data Types

The advanced package DBE_DESCRIBE has two built-in data types. The two data types used for the return values of the DESCRIBE_PROCEDURE API.

  • DBE_DESCRIBE.NUMBER_TABLE
  • DBE_DESCRIBE.VARCHAR2_TABLE

API Description

The advanced package DBE_DESCRIBE provides the DESCRIBE_PROCEDURE API to return the parameter information (such as parameter names and parameter data types) of functions or stored procedures in a list.

Table 1 DBE_DESCRIBE overview

API

Description

DBE_DESCRIBE.DESCRIBE_PROCEDURE

Displays the parameters of a stored procedure or function.

DBE_DESCRIBE.DESCRIBE_PROCEDURE

The stored procedure DESCRIBE_PROCEDURE is used to display the parameter information of a stored procedure or function, such as the parameter name, parameter mode, and parameter location. The parameter information of a function or stored procedure is returned in a list.

The prototype of the DBE_DESCRIBE.DESCRIBE_PROCEDURE function is as follows:

DBE_DESCRIBE.DESCRIBE_PROCEDURE(
  object_name                IN  VARCHAR2,
  reserved1                  IN  VARCHAR2,
  reserved2                  IN  VARCHAR2,
  overload                   OUT DBE_DESCRIBE.NUMBER_TABLE,
  dataposition               OUT DBE_DESCRIBE.NUMBER_TABLE,
  datalevel                  OUT DBE_DESCRIBE.NUMBER_TABLE,
  argument_name              OUT DBE_DESCRIBE.VARCHAR2_TABLE,
  datatype                   OUT DBE_DESCRIBE.NUMBER_TABLE,
  default_value              OUT DBE_DESCRIBE.NUMBER_TABLE,
  in_out                     OUT DBE_DESCRIBE.NUMBER_TABLE,
  datalength                 OUT DBE_DESCRIBE.NUMBER_TABLE,
  dataprecision              OUT DBE_DESCRIBE.NUMBER_TABLE,
  scale                      OUT DBE_DESCRIBE.NUMBER_TABLE,
  radix                      OUT DBE_DESCRIBE.NUMBER_TABLE,
  spare                      OUT DBE_DESCRIBE.NUMBER_TABLE,
  include_string_constraints OUT BOOLEAN
);
Table 2 DBE_DESCRIBE.DESCRIBE_PROCEDURE API

Parameter

Type

Whether NULL Is Allowed

Description

object_name

varchar2

No

Stored procedure name. The syntax format of this parameter is [[schema.]]function[@dblink], in which:

  • schema (optional): schema name.
  • function (required): name of a function or stored procedure.
  • dblink (optional): remote connection name.

reserved1

varchar2

Yes

Reserved parameter.

reserved2

varchar2

Yes

Reserved parameter.

overload

number_table

Yes

Unique ID assigned to a stored procedure or function. If a stored procedure or function is overloaded, overload is each overload of the stored procedure or function. Overload is numbered from 1 in ascending order based on the entire stored procedure or function. If a stored procedure or function is not overloaded, overload is set to 0.

dataposition

number_table

Yes

Position of a specified parameter in the parameter list.

datalevel

number_table

Yes

It is set to 0.

argument_name

varchar2_table

Yes

Name of the parameter associated with the specified stored procedure.

datatype

number_table

Yes

OID of the data type of the specified parameter.

default_value

number_table

Yes

If the specified parameter has a default value, the value is 1. Otherwise, the value is 0.

in_out

number_table

Yes

Parameter mode. The options are as follows:

  • 0: IN
  • 1: OUT
  • 2: IN OUT

datalength

number_table

Yes

Not supported. Set it to 0 by default.

dataprecision

number_table

Yes

Not supported. Set it to 0 by default.

scale

number_table

Yes

Not supported. Set it to 0 by default.

radix

number_table

Yes

If the value is of the numeric type (such as NUMBER and INTEGER), 10 is returned. Otherwise, 0 is returned. For details about the numeric type, see numeric types.

spare

number_table

Yes

Reserved parameter. Set it to 0 by default.

include_string_constraints

Boolean

Yes

Reserved parameter, which does not need to be processed.

  • The data type of the datatype parameter is different from that of the ORA-compatible database. The GaussDB returns the OID of the data type, and the ORA-compatible database returns the number of the data type in the ORA-compatible database.
  • The include_string_constraints parameter does not take effect on the stored procedure. The value of the include_string_constraints parameter does not change, and the return values of other parameters are not affected.
  • The OIDs of the data types created by the create type operation are uncertain. Therefore, do not use these OIDs for fixed judgment.
  • For the dataposition parameter, if a stored procedure is specified, the return value starts from 1. If a function is specified, the return value starts from 0. 0 indicates the position sequence number of the return value of the function.
  • For the argument_name parameter, if a function is specified, the first position of the return value is empty. This position indicates the name of the return value of the described function (that is, the empty name).
  • If you do not have the execute permission on a stored procedure, function, or package, the system considers that the stored procedure, function, or package does not exist and reports an error.
  • The input parameters reserved1 and reserved2 are not involved in internal processing. Entering any character string does not affect the returned result.
  • The advanced package cannot specify the stored procedures or functions obtained through DBLINK.
  • You are advised to add the schema prefix before the specified stored procedure or function. If the schema prefix is omitted, the advanced package uses the current schema of the session to search for the entity to which the advanced package belongs. In this case, you need to change the value of behavior_compat_options to bind_procedure_searchpath for the advanced package to take effect.
  • If the %type operation is used to obtain the data type from a table column, the constraint on the data type (such as NUMBER(3) and VARCHAR2(10)) is not retained.

Example:

-- Create a stored procedure to encapsulate the advanced package for printing return values.
CREATE PROCEDURE PRINT_DESCRIBE (obj_name IN VARCHAR2)
AS
  a_overload     DBE_DESCRIBE.NUMBER_TABLE;
  a_position     DBE_DESCRIBE.NUMBER_TABLE;
  a_level        DBE_DESCRIBE.NUMBER_TABLE;
  a_arg_name     DBE_DESCRIBE.VARCHAR2_TABLE;
  a_dty          DBE_DESCRIBE.NUMBER_TABLE;
  a_def_val      DBE_DESCRIBE.NUMBER_TABLE;
  a_mode         DBE_DESCRIBE.NUMBER_TABLE;
  a_length       DBE_DESCRIBE.NUMBER_TABLE;
  a_precision    DBE_DESCRIBE.NUMBER_TABLE;
  a_scale        DBE_DESCRIBE.NUMBER_TABLE;
  a_radix        DBE_DESCRIBE.NUMBER_TABLE;
  a_spare        DBE_DESCRIBE.NUMBER_TABLE;
  a_include_string_constraints BOOLEAN;
BEGIN
  DBE_DESCRIBE.DESCRIBE_PROCEDURE(
    obj_name,
    null,
    null,
    a_overload,
    a_position,
    a_level,
    a_arg_name,
    a_dty,
    a_def_val,
    a_mode,
    a_length,
    a_precision,
    a_scale,
    a_radix,
    a_spare,
    a_include_string_constraints
  );
  dbe_output.print('overload                ' || chr(9));
  for indx in 1 .. a_overload.count 
  loop 
    dbe_output.print(a_overload(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('dataposition            ' || chr(9));
  for indx in 1 .. a_position.count 
  loop 
    dbe_output.print(a_position(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('datalevel               ' || chr(9));
  for indx in 1 .. a_level.count 
  loop 
    dbe_output.print(a_level(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('argument_name           ' || chr(9));
  for indx in 1 .. a_arg_name.count 
  loop 
    dbe_output.print(a_arg_name(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('default_value           ' || chr(9));
  for indx in 1 .. a_def_val.count 
  loop 
    dbe_output.print(a_def_val(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('in_out                  ' || chr(9));
  for indx in 1 .. a_mode.count 
  loop 
    dbe_output.print(a_mode(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('length                  ' || chr(9));
  for indx in 1 .. a_length.count 
  loop 
    dbe_output.print(a_length(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('precision               ' || chr(9));
  for indx in 1 .. a_precision.count 
  loop 
    dbe_output.print(a_precision(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('scale                   ' || chr(9));
  for indx in 1 .. a_scale.count 
  loop 
    dbe_output.print(a_scale(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');

  dbe_output.print('radix                   ' || chr(9));
  for indx in 1 .. a_radix.count 
  loop 
    dbe_output.print(a_radix(indx) || chr(9)); 
  end loop;

  dbe_output.print_line(' ');
END;
/