I have a script to generate the structure of a database for Firebird and use ISQL
I have problems with some of the statements I use due to the type of date TIMESTAMP
, for example with the external functions:
DECLARE EXTERNAL FUNCTION F_CUTTIME
TIMESTAMP
RETURNS TIMESTAMP FREE_IT
ENTRY_POINT 'fn_cuttime' MODULE_NAME 'SISUDFIB';
Or for example with the creation of domains:
CREATE DOMAIN D_DATE AS TIMESTAMP
CHECK ((VALUE IS NULL) OR (VALUE = F_CUTTIME (VALUE)));
It gives me error and from what I see is by the type TIMESTAMP
.
When I create the structure of my database I generate a script and I get errors in the declarations of external functions, but only in those I use TIMESTAMP tells me this error:
Stament failed, sqlstate = 39000
invalid request BLR offset 13
-function F_CUTTIME is not defined
I get in the functions where TIMESTAMP is, the rest of functions generates me well.
How do I create my script so that I do not get errors in Firebird with ISQL?
I give an example:
SET SQL DIALECT 1;
CREATE DATABASE 'C: \ SISCONIBSCT.fdb' PAGE_SIZE 8192
USER 'SISCONIB' PASSWORD 'telecoman'
DEFAULT CHARACTER SET WIN1252;
/ * External Function declarations * /
DECLARE EXTERNAL FUNCTION F_CUTTIME
TIMESTAMP
RETURNS TIMESTAMP FREE_IT
ENTRY_POINT 'fn_cuttime' MODULE_NAME 'SISUDFIB';
/ * Domain definitions * /
CREATE DOMAIN D_BOOLEAN AS CHAR (1)
DEFAULT 'T'
CHECK (VALUE IN ('F', 'T')) NOT NULL;
CREATE DOMAIN D_DATE AS TIMESTAMP
CHECK ((VALUE IS NULL) OR (VALUE = F_CUTTIME (VALUE)));
CREATE DOMAIN D_DATETIME AS TIMESTAMP;
CREATE DOMAIN D_TIME AS TIMESTAMP
CHECK ((VALUE IS NULL) OR (F_CUTTIME (VALUE) = F_TIMEBASE ()));
CREATE TABLE SISFASE
(
CODSCT SMALLINT NOT NULL,
CODEST CHAR (2) NOT NULL,
CODPRO SMALLINT NOT NULL,
CODFAS SMALLINT NOT NULL,
DESCREAS VARCHAR (30) COLLATE PXW_SPAN,
PERESP D_TIME,
CODPLA CHAR (1) NOT NULL,
CODETG SMALLINT NOT NULL,
PRIMARY KEY (CODSCT, CODEST, CODPRO, CODFAS)
);
Giving errors both in the declaration of the external function as in domains as in the creation of the table and always giving me error in the dates.
Do not understand the problem.
About function F_CUTTIME - if it was taken from InterBase 5, I mean, it was compiled for InterBase 5, then it MUST be recompiled for any new InterBase or Firebird. If it cannot be recompiled, then the only way is to move to Dialect 3, and use basic Firebird functions and CAST to work with separate DATE and TIME variables.