Here's my version in ESQL/C, should work in 4GL as well:
======================================================
exec sql include sqlca;
EXEC SQL INCLUDE sqlhdr;
exec sql include datetime;
#include <stdio.h>
#include <unistd.h>
int main() {
exec sql begin declare section;
dtime_t created_dt;
dtime_t *p_created_dt;
int da;
string buff[128];
exec sql end declare section;
p_created_dt = &created_dt;
exec sql database art;
ifx_strdate( "12/13/2020", &da, 'R' );
exec sql declare dt_c cursor for
select extend( :da::DATE, YEAR TO MINUTE) as created_dt FROM systables WHERE tabid = 5;
printf( "Declare: sqlcode: %d, sqlca.sqlerrd[1] = %d.\n", sqlca.sqlcode, sqlca.sqlerrd[1] );
exec sql open dt_c;
printf( "Open: sqlcode: %d, sqlca.sqlerrd[1] = %d.\n", sqlca.sqlcode, sqlca.sqlerrd[1] );
exec sql fetch dt_c into :created_dt;
printf( "Fetch: sqlcode: %d, sqlca.sqlerrd[1] = %d.\n", sqlca.sqlcode, sqlca.sqlerrd[1] );
dttoasc( &created_dt, buff );
printf( " created: %s.\n", buff );
exec sql close dt_c;
printf( "Close: sqlcode: %d, sqlca.sqlerrd[1] = %d.\n", sqlca.sqlcode, sqlca.sqlerrd[1] );
}
=======================================================
Test run:
art@Elbereth:~$ esql -o testdt testdt.ec
art@Elbereth:~$ ./testdt
Declare: sqlcode: 0, sqlca.sqlerrd[1] = 0.
Open: sqlcode: 0, sqlca.sqlerrd[1] = 0.
Fetch: sqlcode: 0, sqlca.sqlerrd[1] = 0.
created: 2020-12-13 00:00.
Close: sqlcode: 0, sqlca.sqlerrd[1] = 0.
art@Elbereth:~$
Art
Art S. Kagel, President and Principal Consultant
ASK Database Management
Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves.