Using 'EXECUTE STATEMENT' with IBDAC and Firebird2.1

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dennis
Posts: 10
Joined: Tue 23 Oct 2007 14:10

Using 'EXECUTE STATEMENT' with IBDAC and Firebird2.1

Post by dennis » Wed 28 Jul 2010 22:15

I'm trying to 'execute' the following stored procedure:

CREATE PROCEDURE LOCATE (
TABLENAME Char(32),
COLUMNNAME Char(32),
FIELDVALUE Char(60) )
RETURNS (
"FOUND" Smallint )
AS
DECLARE VARIABLE RESULT CHAR(60);
BEGIN

RESULT = NULL;
EXECUTE STATEMENT 'SELECT DISTINCT ' || COLUMNNAME || ' FROM ' || TABLENAME || ' WHERE ' ||
COLUMNNAME || ' = ' ||''''||FIELDVALUE||'''' INTO RESULT;
IF (RESULT IS NOT NULL) THEN
FOUND=-1;
ELSE
FOUND=0;
SUSPEND;
END^

by using a IBCQuery component with the following SQL statement:

Select * from LOCATE(:TABLENAME, :COLUMNNAME,:FIELDVALUE);

When executed, I get the following error:

"Invalid argument in EXECUTE STATEMENT - cannot convert to string
At procedure 'LOCATE' line:13, col:1."

Does IBC components support the new 'EXECUTE STATEMENT' syntax?

Thanks,

Dennis

piotrt
Posts: 2
Joined: Fri 06 Nov 2009 11:05
Location: Poland

Post by piotrt » Thu 29 Jul 2010 07:45

Your problem has nothing to do with IBC. You are not running 'EXECUTE STATEMENT' in TIBCQuery but only simple select, so problem is in your stored procedure (IBC knows nothing about what's inside your procedure). Insure that all parameters of IBCQuery have assigned values. And test this query in your db tool (I recommend FlameRobin).

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 29 Jul 2010 13:24

piotrt wrote:Your problem has nothing to do with IBC. You are not running 'EXECUTE STATEMENT' in TIBCQuery but only simple select, so problem is in your stored procedure (IBC knows nothing about what's inside your procedure). Insure that all parameters of IBCQuery have assigned values. And test this query in your db tool (I recommend FlameRobin).
It's correct. This probelm is connected with the work of your Firebird server and not with IBDAC.

Post Reply