Erro de chamada de DLL no FIREBIRD
Bom dia.
Creie a seguinte DLL abaixo no delphi.
No delphi fazendo a chamada da DLL funciona normalmente, mas quando declaro
uma UDF no FIRIBIRD dá erro. ***********************************************************************************************
***** Declaração da UDF no FIRBIRD ************************************************************ DECLARE EXTERNAL FUNCTION MYLIMPATEXTO VARCHAR(80)
RETURNS VARCHAR(80) FREE_IT
ENTRY_POINT 'LimpaTexto' MODULE_NAME 'ProjDll'; Copiei a DLL pra a pasta do FIREBIRD EM UDFs.
Quando faço a chamada no FIREBIRD ocorre o seguinte erro: select mylimpatexto(NOMERAZAO) from pessoas Erro:-------------------------------------------------------------------------------------
Unsuccessful execution by a system error that precludes
successful execution of subsequent statements. Error writing data to the connection.
**********************************************************************************************
***** DLL CRIADA NO DELPHI ******************************************************************* library ProjDll;
uses
SysUtils,
Classes; {$R *.res} function LimpaTexto(sTexto: String): String; Export; stdcall;
var
i: Integer;
Texto: String;
begin
sTexto := sTexto + StringOfChar(' ', 20);
Texto := ' ';
for i := 0 to Length(sTexto) do
begin
if not (sTexto[i] in [',', '.', '=', '/', '\', ' ', '_', '-', '+', ':', '?', ';', ')', '(']) then
begin
Texto := Texto + sTexto[i];
end;
end;
Result := Trim(Texto);
end; exports
LimpaTexto index 1; begin
end.
Creie a seguinte DLL abaixo no delphi.
No delphi fazendo a chamada da DLL funciona normalmente, mas quando declaro
uma UDF no FIRIBIRD dá erro. ***********************************************************************************************
***** Declaração da UDF no FIRBIRD ************************************************************ DECLARE EXTERNAL FUNCTION MYLIMPATEXTO VARCHAR(80)
RETURNS VARCHAR(80) FREE_IT
ENTRY_POINT 'LimpaTexto' MODULE_NAME 'ProjDll'; Copiei a DLL pra a pasta do FIREBIRD EM UDFs.
Quando faço a chamada no FIREBIRD ocorre o seguinte erro: select mylimpatexto(NOMERAZAO) from pessoas Erro:-------------------------------------------------------------------------------------
Unsuccessful execution by a system error that precludes
successful execution of subsequent statements. Error writing data to the connection.
**********************************************************************************************
***** DLL CRIADA NO DELPHI ******************************************************************* library ProjDll;
uses
SysUtils,
Classes; {$R *.res} function LimpaTexto(sTexto: String): String; Export; stdcall;
var
i: Integer;
Texto: String;
begin
sTexto := sTexto + StringOfChar(' ', 20);
Texto := ' ';
for i := 0 to Length(sTexto) do
begin
if not (sTexto[i] in [',', '.', '=', '/', '\', ' ', '_', '-', '+', ':', '?', ';', ')', '(']) then
begin
Texto := Texto + sTexto[i];
end;
end;
Result := Trim(Texto);
end; exports
LimpaTexto index 1; begin
end.
Gilberto Rezende
Curtidas 0
Respostas
Emerson Nascimento
04/01/2011
tente assim:
library ProjDll;
uses
SysUtils,
Classes;
{$R *.res}
function LimpaTexto(sTexto: PChar): PChar; cdecl;
var
i: Integer;
Texto: String;
begin
Texto := ' ';
Result := sTexto;
for i := 0 to Length(sTexto) do
begin
if not (sTexto[i] in [',', '.', '=', '/', '\', ' ', '_', '-', '+', ':', '?', ';', ')', '(']) then
begin
Texto := Texto + sTexto[i];
end;
end;
StrPCopy(sTexto, Trim(Texto));
end;
exports
LimpaTexto;
begin
end.
e, para registrar no Firebird:
DECLARE EXTERNAL FUNCTION MYLIMPATEXTO CSTRING(255)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'LimpaTexto' MODULE_NAME 'ProjDll';
library ProjDll;
uses
SysUtils,
Classes;
{$R *.res}
function LimpaTexto(sTexto: PChar): PChar; cdecl;
var
i: Integer;
Texto: String;
begin
Texto := ' ';
Result := sTexto;
for i := 0 to Length(sTexto) do
begin
if not (sTexto[i] in [',', '.', '=', '/', '\', ' ', '_', '-', '+', ':', '?', ';', ')', '(']) then
begin
Texto := Texto + sTexto[i];
end;
end;
StrPCopy(sTexto, Trim(Texto));
end;
exports
LimpaTexto;
begin
end.
e, para registrar no Firebird:
DECLARE EXTERNAL FUNCTION MYLIMPATEXTO CSTRING(255)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'LimpaTexto' MODULE_NAME 'ProjDll';
GOSTEI 0
Gilberto Rezende
04/01/2011
Está Tudo declarado certo.
Quando faço o seguinte select:
select mylimpatexto(NOMERAZAO) from pessoas
Ainda continua dando o mesmo erro.
Erro:-------------------------------------------------------------------------------------
Unsuccessful execution by a system error that precludes
successful execution of subsequent statements. Error writing data to the connection.
Unsuccessful execution by a system error that precludes
successful execution of subsequent statements. Error writing data to the connection.
GOSTEI 0
Emerson Nascimento
04/01/2011
da forma que eu te passei - tanto a dll quanto o registro dela estão diferentes do que você fez - funcionou direitinho na minha máquina, com FB 2.0
GOSTEI 0
Gilberto Rezende
04/01/2011
Então deve ter alguma coisa com o meu gerenciado do FIREBIRD. porque eu peguei a DLL que voce me retornou e a colei no Delphi no lugar da minha, compilei, copiei a DLL para \FIREBIRD\UDF ... redeclarei a UDF no FIREBIRD e executei e deu o mesmo erro. Não sei mais o que fazer.
Em todo o caso muito obrigado por sua atenção.
GOSTEI 0
Emerson Nascimento
04/01/2011
será que subsituiu?
para você poder substituir a DLL é preciso dropar a UDF e fechar o banco de dados. só depois disso a DLL estará disponível para manipuilação e poderá ser substituída.
para você poder substituir a DLL é preciso dropar a UDF e fechar o banco de dados. só depois disso a DLL estará disponível para manipuilação e poderá ser substituída.
GOSTEI 0