Updated on 2025-03-13 GMT+08:00

DBE_SESSION

APIs

Table 1 provides all APIs supported by the DBE_SESSION package. DBE_SESSION takes effect at the session level.

Table 1 DBE_SESSION

API

Description

DBE_SESSION.SET_CONTEXT

Sets the value of an attribute in a specified context.

DBE_SESSION.CLEAR_CONTEXT

Clears the value of an attribute in a specified context.

DBE_SESSION.SEARCH_CONTEXT

Queries the value of an attribute in a specified context.

  • DBE_SESSION.SET_CONTEXT

    Sets the value of an attribute in a specified namespace (context). The prototype of the DBE_SESSION.SET_CONTEXT function is as follows:

    1
    2
    3
    4
    5
    DBE_SESSION.SET_CONTEXT(
        namespace text,
        attribute text,
        value text
    )returns void;
    
    Table 2 DBE_SESSION.SET_CONTEXT API parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    namespace

    TEXT

    IN

    No

    Name of the context to be set. If the context does not exist, create a context. The value contains a maximum of 128 bytes. If the value exceeds 128 bytes, it will be truncated.

    attribute

    TEXT

    IN

    No

    Attribute name. The value contains a maximum of 1024 bytes. If the value exceeds 1024 bytes, it will be truncated.

    value

    TEXT

    IN

    No

    Name of the value to be set. The value contains a maximum of 1024 bytes. If the value exceeds 1024 bytes, it will be truncated.

  • DBE_SESSION.CLEAR_CONTEXT

    Clears the value of an attribute in a specified namespace (context). The prototype of the DBE_SESSION.CLEAR_CONTEXT function is as follows:

    1
    2
    3
    4
    5
    DBE_SESSION.CLEAR_CONTEXT (
        namespace text,
        client_identifier text default null,
        attribute text default null
    )returns void ;
    
    Table 3 DBE_SESSION.CLEAR_CONTEXT API parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    namespace

    TEXT

    IN

    No

    Context specified by the user. The value contains a maximum of 128 bytes. If the value exceeds 128 bytes, it will be truncated.

    client_identifier

    TEXT

    IN

    Yes

    Client authentication. The default value is null. Generally, you do not need to manually set this parameter.

    attribute

    TEXT

    IN

    Yes

    Attribute to be cleared. The default value is null, indicating that all attributes of the specified context are cleared. The value contains a maximum of 1024 bytes. If the value exceeds 1024 bytes, it will be truncated.

    CAUTION:

    To ensure forward compatibility, if the parameter value is 'null', all attributes of the specified context are cleared.

  • DBE_SESSION.SEARCH_CONTEXT

    Queries the value of an attribute in a specified namespace (context). The prototype of the DBE_SESSION.SEARCH_CONTEXT function is as follows:

    1
    2
    3
    4
    DBE_SESSION.SEARCH_CONTEXT (
        namespace text,
        attribute text
    )returns text;
    
    Table 4 DBE_SESSION.SEARCH_CONTEXT API parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    namespace

    TEXT

    IN

    No

    Context specified by the user. The value contains a maximum of 128 bytes. If the value exceeds 128 bytes, it will be truncated.

    attribute

    TEXT

    IN

    No

    Attribute to be searched for. The value contains a maximum of 1024 bytes. If the value exceeds 1024 bytes, it will be truncated.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
DECLARE
    a text;
BEGIN
    DBE_SESSION.set_context('test', 'gaussdb', 'one');   -- Set the gaussdb attribute in the test context to one.
    a := DBE_SESSION.search_context('test', 'gaussdb');
    DBE_OUTPUT.PRINT_LINE(a);
    DBE_SESSION.clear_context('test', 'test','gaussdb');
END;
/
-- The expected result is as follows:
one
ANONYMOUS BLOCK EXECUTE