Subject TIMESTAMP as UDF argument [2]
Author IvanSS
***********************************************************
DLL:
(Im using BCB5 DLL Wizard to compile this DLL)
***********************************************************

#include <windows.h>
#include <stdio.h>
#include <ibase.h>
#include <gds.h>

int __export __stdcall func(ISC_TIMESTAMP *SY);

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
int __export __stdcall func(ISC_TIMESTAMP *SY)
{
return 1;
}


***********************************************************
DataBase:
***********************************************************

SET SQL DIALECT 3;

CREATE DATABASE 'C:\PRB.GDB'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 4096
DEFAULT CHARACTER SET WIN1250;


DECLARE EXTERNAL FUNCTION DUMMY_UDF
TIMESTAMP
RETURNS INTEGER BY VALUE
ENTRY_POINT 'func' MODULE_NAME 'flib';


CREATE TABLE T1 ( ID INTEGER NOT NULL, MDATE TIMESTAMP);
ALTER TABLE T1 ADD PRIMARY KEY (ID);
COMMIT;

INSERT INTO T1 (ID, MDATE) VALUES (1, '01/01/2002');

COMMIT;


**************************************************************
Application:
In this unit im trying to use this udf:
Q1 is TIBQuery
**************************************************************
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Q1->SQL->Clear();
Q1->SQL->Add("SELECT * FROM T1 WHERE T1.ID=DUMMY_UDF(:dd)");

// Q1->Params[0 DataType = ftDateTime
Q1->Prepare();
Q1->ParamByName("dd")->AsDateTime = Date();
Q1->Open();
}

In line where i prepare the query, exception:
*************************************************
Dynamic SQL Error
SQL Error code =-804
Data type unknown
*************************************************

*********************************
Anyway, this code works:
*********************************
void __fastcall TForm1::Button1Click(TObject *Sender)
{

Q1->SQL->Clear();
Q1->SQL->Add("SELECT * FROM T1 WHERE DUMMY_UDF('01/01/2002')=1");
Q1->Open();
}


The same things happend if i use FreeUDFLib, or rfunc2.

Platform:
Wini2k, BCB5 and Firebird-1.0.0.448-Beta-2-Win32

regards,
ivan


[Non-text portions of this message have been removed]