델파이와 인터베이스를 연결하는데 자꾸만 이런 에러 메시지가 보이내요.
General SQL error.
Column unknown
SALE_DATE
Client SQL dialect 1 does not support reference to DATE datatype.
그런데 IBConsole에서는 SQL을 던지면 잘보이거든요. 그런데 SQL Explorer나 델파이
에서는 위와같은 에러가 나오네요.
생성구문을 함께 올립니다.
CREATE DOMAIN DCUSTOMERID AS INTEGER;
CREATE DOMAIN DCREDITLINE AS SMALLINT default 0 CHECK (VALUE BETWEEN 0 AND 3000);
CREATE DOMAIN DNAME AS CHAR(20);
CREATE DOMAIN DADDRESS AS VARCHAR(50);
CREATE DOMAIN DCITY AS VARCHAR(20);
CREATE DOMAIN DSTATE AS VARCHAR(20);
CREATE DOMAIN DZIP AS VARCHAR(10);
CREATE DOMAIN DPHONE AS VARCHAR(20);
CREATE DOMAIN DPRICE AS NUMERIC(15, 2) default 0.00; /* 15는 유효자리수 2는 소수점 자리 */
CREATE table CUSTOMER (
CUSTOMER_ID INTEGER NOT NULL,
FNAME DNAME NOT NULL,
LNAME DNAME NOT NULL,
CREDIT_LINE DCREDITLINE NOT NULL,
WORK_ADDRESS DADDRESS,
ALT_ADDRESS DADDRESS,
CITY DCITY,
STATE DSTATE,
ZIP DZIP,
WORK_PHONE DPHONE,
ALT_PHONE DPHONE,
COMMENTS BLOB SUB_TYPE TEXT SEGMENT SIZE 80,
COMPANY VARCHAR(40),
CONSTRAINT PCUSTOMER_ID PRIMARY KEY (CUSTOMER_ID)
);
CREATE TABLE PART (
PART_NUMBER VARCHAR(10) NOT NULL,
DESCRIPTION VARCHAR(18),
QUANTITY SMALLINT NOT NULL,
LIST_PRICE DPRICE NOT NULL,
RETAIL_PRICE DPRICE NOT NULL,
DEALER_PRICE DPRICE NOT NULL,
JOBBER_PRICE DPRICE NOT NULL,
CONSTRAINT PPART_NUMBER PRIMARY KEY (PART_NUMBER)
);
CREATE TABLE SALES (
SALE_NUMBER INTEGER,
CUSTOMER_ID INTEGER,
SALE_DATE DATE,
TOTAL_PRICE DOUBLE PRECISION
);
ALTER TABLE SALES ADD FOREIGN KEY (CUSTOMER_ID)
REFERENCES CUSTOMER(CUSTOMER_ID);
CREATE TABLE ITEMS (SALE_NUMBER INTEGER,
ITEM_NO INTEGER,
PART_NO VARCHAR(10),
QTY SMALLINT
);
ALTER TABLE ITEMS ADD FOREIGN KEY (PART_NO)
REFERENCES PART(PART_NUMBER);
CREATE GENERATOR GEN_CUSTID;
CREATE GENERATOR GEN_ITEMNO;
CREATE GENERATOR GEN_SALENO;
CREATE TRIGGER TCUSTOMER_ID FOR CUSTOMER
ACTIVE BEFORE INSERT POSITION 0
as begin
new.customer_id = gen_id(gen_custid, 1);
end
set term ^;
CREATE TRIGGER TITEM_NO FOR ITEMS
ACTIVE BEFORE INSERT POSITION 0
as begin
new.item_no = gen_id(gen_itemno, 1);
end; ^
SET TERM ^; /* 저장프로시저의 종료 (;) SQL 종료문자 (;) 그래서 SQL 종료 문자를 ^로 바꿈 */
CREATE PROCEDURE INSERT_SALE as begin exit; end ^
ALTER PROCEDURE INSERT_SALE (
ICUSTOMER_ID INTEGER,
ISALE_DATE DATE,
ITOTAL_PRICE DOUBLE PRECISION)
RETURNS (
RSALE_NUMBER INTEGER)
AS
BEGIN
/* 우선, GEN_SALENO 생성기로부터 새 판매 번호를 얻는다 */
/* 그리고 그 번호를 리턴값을 뜻하는 rSale인자에 넣는다 */
/* 따라서, 이 저장 프로시저를 호출한 클라이언트는 rSale에 담긴 */
/* 판매 번호를 돌려 받게 된다 */
rSALE_NUMBER = gen_id(GEN_SALENO, 1);
/* 이제 SALES 테이블에 레코드를 추가한다 */
INSERT INTO SALES(
SALE_NUMBER,
CUSTOMER_ID,
SALE_DATE,
TOTAL_PRICE)
VALUES(
:rSALE_NUMBER,
:iCUSTOMER_ID,
:iSALE_DATE,
:iTOTAL_PRICE);
END; ^
CREATE PROCEDURE INSERT_SALE_ITEM AS BEGIN EXIT; END^
ALTER PROCEDURE INSERT_SALE_ITEM (
ISALE_NUMBER INTEGER,
IPART_NO VARCHAR(10),
IQTY SMALLINT)
AS
DECLARE VARIABLE Actual_Qty VARCHAR(10);
BEGIN
/* PARTS 테이블에 iQTY 개수만큼의 부품이 남아 있는지 확인 */
SELECT QUANTITY FROM PART
WHERE PART_NUMBER = :iPART_NO
INTO Actual_Qty;
IF (Actual_Qty < iQTY) THEN
EXCEPTION EXP_EXCESS_ORDER;
ELSE BEGIN
/* PART 테이블의 해당 부품 개수를 판매된 개수만큼 감소기킨다 */
UPDATE PART
SET QUANTITY = (:Actual_Qty - :iQty)
WHERE PART_NUMBER = :iPART_NO;
/* 새 주문을 삽입한다 */
INSERT INTO ITEMS (
SALE_NUMBER,
PART_NO,
QTY)
VALUES(
:iSALE_NUMBER,
:iPART_NO,
:iQTY);
END
END
GRANT SELECT, UPDATE ON CUSTOMER TO PUBLIC WITH GRANT OPTION;
GRANT ALL ON SALES TO PUBLIC WITH GRANT OPTION;
GRANT ALL ON PART TO PUBLIC WITH GRANT OPTION;
GRANT ALL ON ITEMS TO PUBLIC WITH GRANT OPTION;
GRANT EXECUTE ON PROCEDURE INSERT_SALE TO PUBLIC;
GRANT EXECUTE ON PROCEDURE INSERT_SALE_ITEM TO PUBLIC;
돌맹이 wrote:
> 델파이와 인터베이스를 연결하는데 자꾸만 이런 에러 메시지가 보이내요.
>
>
> General SQL error.
> Column unknown
> SALE_DATE
> Client SQL dialect 1 does not support reference to DATE datatype.
>
> 그런데 IBConsole에서는 SQL을 던지면 잘보이거든요. 그런데 SQL Explorer나 델파이
> 에서는 위와같은 에러가 나오네요.
>
>
> 생성구문을 함께 올립니다.
>
> CREATE DOMAIN DCUSTOMERID AS INTEGER;
> CREATE DOMAIN DCREDITLINE AS SMALLINT default 0 CHECK (VALUE BETWEEN 0 AND 3000);
> CREATE DOMAIN DNAME AS CHAR(20);
> CREATE DOMAIN DADDRESS AS VARCHAR(50);
> CREATE DOMAIN DCITY AS VARCHAR(20);
> CREATE DOMAIN DSTATE AS VARCHAR(20);
> CREATE DOMAIN DZIP AS VARCHAR(10);
> CREATE DOMAIN DPHONE AS VARCHAR(20);
> CREATE DOMAIN DPRICE AS NUMERIC(15, 2) default 0.00; /* 15는 유효자리수 2는 소수점 자리 */
>
> CREATE table CUSTOMER (
> CUSTOMER_ID INTEGER NOT NULL,
> FNAME DNAME NOT NULL,
> LNAME DNAME NOT NULL,
> CREDIT_LINE DCREDITLINE NOT NULL,
> WORK_ADDRESS DADDRESS,
> ALT_ADDRESS DADDRESS,
> CITY DCITY,
> STATE DSTATE,
> ZIP DZIP,
> WORK_PHONE DPHONE,
> ALT_PHONE DPHONE,
> COMMENTS BLOB SUB_TYPE TEXT SEGMENT SIZE 80,
> COMPANY VARCHAR(40),
> CONSTRAINT PCUSTOMER_ID PRIMARY KEY (CUSTOMER_ID)
> );
>
> CREATE TABLE PART (
> PART_NUMBER VARCHAR(10) NOT NULL,
> DESCRIPTION VARCHAR(18),
> QUANTITY SMALLINT NOT NULL,
> LIST_PRICE DPRICE NOT NULL,
> RETAIL_PRICE DPRICE NOT NULL,
> DEALER_PRICE DPRICE NOT NULL,
> JOBBER_PRICE DPRICE NOT NULL,
> CONSTRAINT PPART_NUMBER PRIMARY KEY (PART_NUMBER)
> );
>
> CREATE TABLE SALES (
> SALE_NUMBER INTEGER,
> CUSTOMER_ID INTEGER,
> SALE_DATE DATE,
> TOTAL_PRICE DOUBLE PRECISION
> );
>
> ALTER TABLE SALES ADD FOREIGN KEY (CUSTOMER_ID)
> REFERENCES CUSTOMER(CUSTOMER_ID);
>
> CREATE TABLE ITEMS (SALE_NUMBER INTEGER,
> ITEM_NO INTEGER,
> PART_NO VARCHAR(10),
> QTY SMALLINT
> );
>
> ALTER TABLE ITEMS ADD FOREIGN KEY (PART_NO)
> REFERENCES PART(PART_NUMBER);
>
> CREATE GENERATOR GEN_CUSTID;
> CREATE GENERATOR GEN_ITEMNO;
> CREATE GENERATOR GEN_SALENO;
>
> CREATE TRIGGER TCUSTOMER_ID FOR CUSTOMER
> ACTIVE BEFORE INSERT POSITION 0
> as begin
> new.customer_id = gen_id(gen_custid, 1);
> end
>
> set term ^;
>
> CREATE TRIGGER TITEM_NO FOR ITEMS
> ACTIVE BEFORE INSERT POSITION 0
> as begin
> new.item_no = gen_id(gen_itemno, 1);
> end; ^
>
> SET TERM ^; /* 저장프로시저의 종료 (;) SQL 종료문자 (;) 그래서 SQL 종료 문자를 ^로 바꿈 */
>
> CREATE PROCEDURE INSERT_SALE as begin exit; end ^
> ALTER PROCEDURE INSERT_SALE (
> ICUSTOMER_ID INTEGER,
> ISALE_DATE DATE,
> ITOTAL_PRICE DOUBLE PRECISION)
> RETURNS (
> RSALE_NUMBER INTEGER)
> AS
> BEGIN
> /* 우선, GEN_SALENO 생성기로부터 새 판매 번호를 얻는다 */
> /* 그리고 그 번호를 리턴값을 뜻하는 rSale인자에 넣는다 */
> /* 따라서, 이 저장 프로시저를 호출한 클라이언트는 rSale에 담긴 */
> /* 판매 번호를 돌려 받게 된다 */
> rSALE_NUMBER = gen_id(GEN_SALENO, 1);
> /* 이제 SALES 테이블에 레코드를 추가한다 */
> INSERT INTO SALES(
> SALE_NUMBER,
> CUSTOMER_ID,
> SALE_DATE,
> TOTAL_PRICE)
> VALUES(
> :rSALE_NUMBER,
> :iCUSTOMER_ID,
> :iSALE_DATE,
> :iTOTAL_PRICE);
> END; ^
>
> CREATE PROCEDURE INSERT_SALE_ITEM AS BEGIN EXIT; END^
> ALTER PROCEDURE INSERT_SALE_ITEM (
> ISALE_NUMBER INTEGER,
> IPART_NO VARCHAR(10),
> IQTY SMALLINT)
> AS
> DECLARE VARIABLE Actual_Qty VARCHAR(10);
> BEGIN
> /* PARTS 테이블에 iQTY 개수만큼의 부품이 남아 있는지 확인 */
> SELECT QUANTITY FROM PART
> WHERE PART_NUMBER = :iPART_NO
> INTO Actual_Qty;
> IF (Actual_Qty < iQTY) THEN
> EXCEPTION EXP_EXCESS_ORDER;
> ELSE BEGIN
> /* PART 테이블의 해당 부품 개수를 판매된 개수만큼 감소기킨다 */
> UPDATE PART
> SET QUANTITY = (:Actual_Qty - :iQty)
> WHERE PART_NUMBER = :iPART_NO;
> /* 새 주문을 삽입한다 */
> INSERT INTO ITEMS (
> SALE_NUMBER,
> PART_NO,
> QTY)
> VALUES(
> :iSALE_NUMBER,
> :iPART_NO,
> :iQTY);
> END
> END
>
>
>
> GRANT SELECT, UPDATE ON CUSTOMER TO PUBLIC WITH GRANT OPTION;
> GRANT ALL ON SALES TO PUBLIC WITH GRANT OPTION;
> GRANT ALL ON PART TO PUBLIC WITH GRANT OPTION;
> GRANT ALL ON ITEMS TO PUBLIC WITH GRANT OPTION;
>
> GRANT EXECUTE ON PROCEDURE INSERT_SALE TO PUBLIC;
> GRANT EXECUTE ON PROCEDURE INSERT_SALE_ITEM TO PUBLIC;
>