Subject | Re: [ib-support] UDF's and its arguments |
---|---|
Author | ibrahim Bulut |
Post date | 2001-11-15T09:53:35Z |
You can do it without the udf
Example
SET TERM !!;
CREATE PROCEDURE FIND_BY_DATE
(TT TIMESTAMP, NN INTEGER)
RETURNS (ID INTEGER, RDATE TIMESTAMP)
AS
BEGIN
FOR SELECT ID, MDATE FROM T1
WHERE MDATE < (:NN + :TT)
INTO :ID, :RDATE DO SUSPEND;
END !!
SET TERM ;!!
I tried this stored procedure in my database on the timestamp field.
It is workig true.
Bye
Example
SET TERM !!;
CREATE PROCEDURE FIND_BY_DATE
(TT TIMESTAMP, NN INTEGER)
RETURNS (ID INTEGER, RDATE TIMESTAMP)
AS
BEGIN
FOR SELECT ID, MDATE FROM T1
WHERE MDATE < (:NN + :TT)
INTO :ID, :RDATE DO SUSPEND;
END !!
SET TERM ;!!
I tried this stored procedure in my database on the timestamp field.
It is workig true.
Bye
----- Original Message -----
From: "IvanSS" <shijak@...>
To: <ib-support@yahoogroups.com>
Sent: Wednesday, November 14, 2001 11:13 PM
Subject: [ib-support] UDF's and its arguments
> Hi,
>
> the problem begin when i send parametar as argumet to some UDF. It
doesn't metter IB version or udf library, i tryed a lot of
> combinations, like Borland IB 6, FireBird 1, FireBird 0.9. libraris are
rfunc2 or FreeUDFLib, even i made one simple library.
>
> For example, If database looks like this:
>
> SET SQL DIALECT 3;
>
> CREATE DATABASE 'C:\one.GDB'
> USER 'SYSDBA' PASSWORD 'masterkey'
> PAGE_SIZE 4096
> DEFAULT CHARACTER SET WIN1251;
>
>
> /* External functions definition*/
>
> DECLARE EXTERNAL FUNCTION DAYSBETWEEN
> TIMESTAMP,
> TIMESTAMP
> RETURNS INTEGER BY VALUE
> ENTRY_POINT 'fn_daysbetween' MODULE_NAME 'rfunc';
>
>
> /* Tables definitions */
>
> CREATE TABLE T1 (
> ID INTEGER NOT NULL,
> MDATE TIMESTAMP);
>
> COMMIT WORK;
>
> INSERT INTO T1 (ID, MDATE) VALUES (1, '01/01/2002');
> INSERT INTO T1 (ID, MDATE) VALUES (2, '12/30/2001');
> INSERT INTO T1 (ID, MDATE) VALUES (3, '01/04/2002');
> INSERT INTO T1 (ID, MDATE) VALUES (4, '10/10/2001');
>
> COMMIT WORK;
>
> /* Unique keys definition */
>
> ALTER TABLE T1 ADD PRIMARY KEY (ID);
>
>
> SET TERM ^ ;
>
> /* Stored procedures definition */
>
>
> /* Stored Procedure: FIND_BY_DATE */
> CREATE PROCEDURE FIND_BY_DATE (
> ADATE TIMESTAMP)
> RETURNS (
> ID INTEGER,
> RDATE TIMESTAMP)
> AS
> BEGIN
> FOR SELECT ID, MDATE
> FROM T1
> WHERE DAYSBETWEEN(:ADATE, MDATE) < 30
> INTO :ID, :RDATE
> DO
> SUSPEND;
> END
> ^
>
> SET TERM ; ^
> /**************************************************************/
>
> And if i execute this :
>
> select * from FIND_BY_DATE('1/1/2002')
>
> from QuickDesk if ISQL, the result is
>
> ID RDATE
> 1 1/1/2002
> 2 12/30/2001
> 3 1/4/2002
> 4 10/10/2001
>
> This is not good! The row 4 does not belong here!
> When i'm trying to debug the procedure FIND_BY_DATE in QuickDesk, an
exception is thrown:
> SQL Error code -804
> Unknown data type
>
>
> The same exception is thrown if i exec an application that contents this
code:
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> Q1->SQL->Clear();
> Q1->SQL->Add("SELECT * FROM T1 WHERE DAYSBETWEEN(:dd, :pp) < 30");
> Q1->Prepare();
> Q1->ParamByName("dd")->AsDateTime = DateTimePicker1->DateTime;
> Q1->ParamByName("pp")->AsDateTime = DateTimePicker2->DateTime;
> Q1->Open();
> }
>
> In line where i prepare the query an exception is thrown:
> *************************************************
> 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 DAYSBETWEEN('1/1/2002', '1/4/2002')
< 30");
> Q1->Open();
> }
>
> This result shows that this udf function works good, but the problem is
when parametar is passed as argument!
> Can somebody explain me how can i fix this?
>
> regards,
> ivan
>
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>