Function db_query

This function executes a query from the current job configuration file and provides results from the query in the form of table row counts before and after the query is executed.

Sample Output
Rows in table before: 10
Rows in table after: 8
Difference: 2

Parameters

Parameters
Type Use Description

Scalar

Required

VCN

Scalar

Required

Key to SQL in Job Conf file

Scalar

Required

Table Name

Array or LOS

Optional

Query Parameters

VCN: Virtual Connection Name
LOS: List of Scalars

Returns

Address to an array of text.

Examples

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

Example 1
my $result = db_query( $vcn, 'query', 'my_table', @params );
log_info( 'The result is', $result );

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

Example 2
my $result = db_query( $vcn, 'query', 'my_table', 'param1', 'param2' );
foreach my $line ( @{$result} ) {
    print "$line\n";
}

Job Configuration File

Example
sql:
    query: |
        delete
          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

The return value from this function is an address.