I wrote the next Pascal code
PROGRAM demo1 (OUTPUT);
%include "sqlr$include:sqlrdef.pas"
VAR
query : VARYING [50] OF CHAR;
BEGIN
query:= "select * from countries";
sqlr$test (query);
END.
"sqlrdef.pas" file consist
[EXTERNAL] FUNCTION sqlr$test (data : string) : INTEGER; EXTERNAL;
sqlr$test it is a C-function
unsigned long SQLR$TEST (char *data)
{
printf ("data is [%s] \n", data);
return SQLR$_NORMAL;
}
But when I execute my program on Pascal, I get the next output
data is []
What do I need to change for passing the argument to C-function from Pascal correctly?
You should use
%stdescr query_dsc : [CLASS_S] PACKED ARRAY [$L1..$U1: INTEGER] OF CHAR
and
query : PACKED ARRAY [1..40] OF CHAR VALUE 'select * from countries';