Documentation Index

Fetch the complete documentation index at: https://docs.lobster-world.com/llms.txt

Use this file to discover all available pages before exploring further.

DefaultSQLCron

Prev Next

Description

Class name: com.ebd.hub.datawizard.util.DefaultSQLCron

DefaultSQLCron reads data from multiple database tables simultaneously. The class reads SQL statements and table dependencies from a configuration file.

Assign the SQL statements ascending names select.<n>. Use all numbers without gaps. Start at 0. Define dependencies between the SQL statements using the syntax dependencies.<n>=<s>:<m>:

  • s is the index of the SQL statement.

  • m is the index of the column within the result set.

  • n is the index of the dependency.

Example: dependencies.1=0:2 defines that the SQL statement select.1 depends on the second column from the result set of select.0. To define multiple columns, separate them with commas, for example dependencies.1=0:2,0:3.

Configuration: in the Business Connector (Input Agent cron).

IMPORTANT Creating the configuration file manually for the first time is not easy. Use the SQL Wizard instead.

NOTE You can create the source structure for the input file from the source structure menu.

Parameters

Parameter

Description

db_alias

Sets the database alias for database access. See section Databases/connectors (Configuration). You can also use variables from previous profiles or parameter values from HTTP triggers. Example: db_alias=@MSG_CALL_DB_ALIAS@.

pre.statement

You can define multiple pre-statements. Separate them with a semicolon (;).

post.statement

You can define multiple post-statements. Separate them with a semicolon (;).

save_as_csv

Specify a file path. The system creates a CSV file with the source data at that path.

result.split

Values: true or false. If true, the system creates a new job for each row of select.0. This only works under two conditions. First, at least two SQL statements (select.0 and select.1) must exist. Second, a dependency (dependencies.1) must exist.

NOTE If you only have one SQL statement, use this trick. Create a dummy statement select.1 with a condition that is never true. This avoids creating an additional result row. Then set any dependencies.1.

Example:

result.split=true
select.0=select 'T001', date_at, order_no from orders where amount>10
select.1=select 1 from dual where 1=2
dependencies.1=0:2

select.<n>

Defines the SQL statements. Start at 0 and increment by 1.

NOTE Use \ to indicate line breaks.

Example:

select.1=select 1 from dual \
where 1=2

dependencies.<n>

Defines the dependencies of the respective select.<n>.

limit.<n>

Sets a limit for the number of rows of select.<n>. A limit of 0 means no limit. You get the same result if you omit the parameter.

empty.<n>

Defines a dummy result for select.<n> if select.<n> returns no result.

MSG_CALL_<VARNAME>

See explanations below.

encode_blob

Values: true or false. If true, the system encodes BLOB and CLOB fields with Base64.

use_raw_content

If false (default), the system returns the result set as CSV rows. For example, with four result columns and three result rows:

T001;1253698848119000;0;ASM
T001;1256310126906000;0;Lobster
T001;1304947631473000;0;CONRAD

If true, the system returns the entire result set in one line, without CSV delimiters:

T00112536988481190000ASMT00112563101269060000LobsterT00113049476314730000CONRAD

In the WHERE clauses of select.<n>, use placeholders to reference the dependencies. The placeholder @1:i@ replaces the first column from the associated dependencies. The placeholder @2:i@ replaces the second column. The i stands for the data type, here Integer. The following table lists all data types.

You can also use values from variables. Only variables from previous profiles or parameter values from HTTP triggers are allowed. The variables must be defined in the profile. Example: Define MSG_CALL_MYVAR=100 in the configuration file. The value of the variable then fills the placeholder @100:i@.

IMPORTANT The placeholder number for variables must not be smaller than 100.

Abbreviation

Data type

i

Integer

f

Float

r

Real

d

Date

t

Timestamp

s

String

l

Long

v

Boolean

b

Blob

x

Textstream

You can also use the time of the last successful profile start in a WHERE clause. Three placeholders are available.

Placeholder

Meaning

@0:t@

Time of the last profile run as a timestamp.

@0:d@

Time of the last profile run as a date.

@0:s#<template>@

Time as a formatted string. Example: @0:s#yyyyMMdd@ returns 20150310 for March 10, 2015. For a W3C-compliant date and time format, use @0:s#yyyyMMdd'T'HH:mm:ss.SSS@ or @0:s#.

IMPORTANT @0:s#<template>@ is only resolved once. A further occurrence of @0:s#<template>@ with a different template has no effect. Instead, the system uses the cached value of the first occurrence. Examples for W3C-compliant format: @0:s#yyyyMMdd'T'HH:mm:ss.SSS@ returns e.g. 20260315T093045.123 for 15 March 2026 at 09:30:45.123. The short form @0:s# uses the system-internal W3C standard format.

Example

NOTE  You can also use system constants with the syntax %CONSTANT%.

IMPORTANT Suppose you have a string variable MSG_CALL_MYVAR with the content 'USA','UK'. In the configuration file shown below, you define MSG_CALL_MYVAR=100. The SQL query SELECT id, name FROM supplier WHERE country IN (@100:s@) does not work.

The reason: the placeholder represents a string. The query does not resolve to SELECT id, name FROM supplier WHERE country IN ('USA','UK'). Instead, it resolves to SELECT id, name FROM supplier WHERE country IN (''USA','UK'').

You can only solve such queries with dependencies, as shown below. The SQL Wizard helps you with this.

# 
# Sample config file for DefaultSQLCron
#
 
#Which db connection to use
db_alias=hub
 
#You can define multiple pre- and post-statements here (separated by ";"), like:
#pre.statement=lock table table_a in exclusive mode;lock table_b in exclusive mode
#post.statement=
 
#Create CSV file for debugging - uncomment if needed.
#save_as_csv=/tmp/sqldump.csv
 
#For each row of select.0 create a new request (job) if param is set to true.
result.split=false
 
#If BLOB columns are selected, you may want to encode the content with Base64.
#encode_blob=true
 
#
#Here are the statements... must start with 0, step size is 1!
# 
select.0=select 'A',id,name from order where date_at > @0:d@
select.1=select 'B',id,item_number from item where order_id = @1:i@
select.2=select 'C',id,text from item_text where item_id = @1:i@
#
#select.1 needs value (column at position 2) from statement 0 (select.0) for execution (join); multiple columns are separated by ','.
#select.2 needs value (column at position 2) from statement 1 (select.1) for execution (join); multiple columns are separated by ','.
#Offset for counting column positions is always 1. First dependency references to @1:xxx@, etc.
#Note: To use the time of the last time a cron job was executed, use tag @0:d@ or @0:t@ for date or timestamp.
#
dependencies.1=0:2
dependencies.2=1:2
#
#(Passed) variables can be used as well, if defined in the profile.
MSG_CALL_MYVAR=100
# This will replace filler @100:i@ in any SQL select statement by the integer value of the named variable.
#
#
#Use limit.xxx to limit the result set, e.g.
#limit.0 = 500
#will limit select.0 to 500 rows. If not set, no limit is given.
 
#If an SQL statement returns no results, you can define a dummy result instead.
#Define a valid CSV line with delimiter ';'.
#An example for a 'dummy' result for select.0:
#empty.0=A;0;Nothing

You want to read three tables: order, item, and item_text. The tables are linked by 1:n relations. An order (order) can have any number of items (item). An item can have any number of item texts (item_text).

The order table:

id

name

date_at

10

order_1

01.01.2014

11

order_2

01.01.2014

The item table:

id

item_number

order_id

20

item_1

10

21

item_1

11

22

item_2

11

The item_text table:

id

text

item_id

30

text_1

20

31

text_2

20

32

text_3

22

The system executes the first SQL statement select.0. It replaces the variable @0:d@ with the date of the last profile run. The database returns the following result:

A

10

order_1

A

11

order_2

The first row

A

10

order_1

of the result set of select.0 creates the dependencies.1:

10

The system runs select.1 with the dependencies.1:

B

20

item_1

From this result set, the system creates the dependencies.2:

20

The system runs select.2 with the dependencies.2:

C

30

text_1

C

31

text_2

The system combines the result rows into the first result subset:

A

10

order_1

B

20

item_1

C

30

text_1

C

31

text_2

The system processes the second row

A

11

order_2

of the result set of select.0 in the same way.

The dependencies.1 become:

11

Then select.1 returns:

B

21

item_1

B

22

item_2

The dependencies.2 become:

21

22

select.2 returns no result for the first row of dependencies.2. For the second row of dependencies.2, select.2 returns:

C

32

text_3

The system combines these result rows into a second result subset:

A

11

order_2

B

21

item_1

B

22

item_2

C

32

text_3

The system combines the result subsets into the overall result set and passes it to the profile:

A

10

order_1

B

20

item_1

C

30

text_1

C

31

text_2

A

11

order_2

B

21

item_1

B

22

item_2

C

32

text_3

Blanks in query results (MSSQL/Informix)

In MSSQL and Informix databases, the system trims leading and trailing spaces from SQL result values by default. Use the skipTrimResultValues parameter to change this behavior. Set the parameter in the configuration file of the database alias.