Function db_query_col

This function executes a query from the current job configuration file and returns the first row/col value from the result set. This is typically used to execute a query that returns a single value.

Parameters

Parameters
Type Use Description

Scalar

Required

VCN

Scalar

Required

Key to SQL in Job Conf file

Array or LOS

Optional

Query Parameters

VCN: Virtual Connection Name
LOS: List of Scalars

Returns

Scalar value.

Examples

In this example, query params are passed as an array.

Example 1
my $value = db_query_col( $vcn, 'query', @params );
log_info( 'The value is', $value );

In this example, query params are passed as a list of scalars.

Example 2
my $value = db_query_col( $vcn, 'query', 'my_table', 'param1', 'param2' );
log_info( 'The value is', $value );

Job Configuration File

Example
sql:
    query: |
        select attrib
          from my_table
         where col1 = ?
           and col2 = ?

The values for ? are passed as parameters at runtime. The query is defined in the job configuration file as a multi-line text entry under the key values sql and query.

Additional Notes

None