decimal(20, 0) to handle MySQL bigint end with ,

I’m trying to store the result of a sql query in the variable $g_max_row_num using data type decimal(20,0).

$g_max_row_num = sql( 'ig_src', 'select max(row_num) from av.event_new' );

print( 'Processing records where row_number <= ' || to_char( $g_max_row_num ) );

Output of the print

10424	6688	PRINTFN	23-1-2015 11:31:28	Processing records where row_number <= 385560597,

Why there is a , at he end?


bas_vdl :netherlands: (BOB member since 2012-11-08)

I am not sure why are you getting that but it is not coming for me when I tried executing the similar script. It just gave me the number as below;

PRINTFN: Processing records where row_number <= 69


BOBJFan (BOB member since 2011-09-24)

Keep in mind that the return value of the sql() function is VARCHAR. The result of the query itself is a number but DS does an implicit conversion to VARCHAR.

If you were to write query like this (assuming Oracle):

$g_max_row_num = sql( ‘ig_src’, ‘select cast(max(row_num) as VARCHAR2(10)) from av.event_new’ );

The variable may end up with a value without the comma.


eganjp :us: (BOB member since 2007-09-12)