Subject | "Column Unknown" in Stored Procedure |
---|---|
Author | Tim Ledgerwood |
Post date | 2003-10-23T09:18:59Z |
Hi everyone,
I keep on getting a "column unknown" when I try and create the following
stored procedure. What am i doing wrong? All the tables and table columns
are there ...
Thanks in advance,
Tim
ALTER PROCEDURE "INSERT_CREDIT_SUB_ACCOUNT"
(
"SUBACCOUNTNUMBER" INTEGER,
"DOCTYPE" INTEGER,
"REFERENCE" VARCHAR(128),
"TRANSDATE" DATE,
"TRANSTIME" TIME,
"FINMONTH" INTEGER,
"FINYEAR" INTEGER,
"DESCRIPTION" VARCHAR(128),
"TRANSAMOUNT" INTEGER,
"TRANSTYPE" INTEGER,
"TAXTYPE" INTEGER,
"MOP" INTEGER
)
AS
DECLARE VARIABLE "lvTAXRATE" NUMERIC(8,2);
DECLARE VARIABLE "lvTAXDESCRIP" VARCHAR(128);
DECLARE VARIABLE "lvTAXAMOUNT" INTEGER;
DECLARE VARIABLE "lvTRANSTYPEABBR" VARCHAR(3);
DECLARE VARIABLE "lvPMTTYPEABBR" VARCHAR(3);
DECLARE VARIABLE "lvDOCTYPEABBR" VARCHAR(3);
DECLARE VARIABLE "ACCOUNTNUMBER" INTEGER;
BEGIN
lvTAXRATE = 0;
lvTAXDESCRIP = 'NONE';
lvPMTTYPEABBR = 'NON';
lvTRANSTYPEABBR = 'NON';
lvDOCTYPEABBR = 'NON';
SELECT TAXRATE, DESCRIPTION
FROM TAXTYPETABLE
WHERE
TAXTYPETABLE.RECORDNO = :TAXTYPE
INTO
:lvTAXRATE, :lvTAXDESCRIP;
SELECT ABBREVIATION
FROM
PAYMENTTYPE
WHERE
PAYMENTTYPE.RECORDNO = :MOP
INTO
:lvPMTTYPEABBR;
SELECT ABBREVIATION
FROM
TRANSTYPETABLE
WHERE
TRANSTYPETABLE.RECORDNO = :TRANSTYPE
INTO
:lvTRANSTYPEABBR;
SELECT ABBREVIATION
FROM
DOCUMENTTYPE
WHERE
DOCUMENTTYPE.RECORDNO = :DOCTYPE
INTO
:lvDOCTYPEABBR;
ACCOUNTNUMBER = 0;
SELECT ACCOUNT_NUMBER
FROM SUB_ACCOUNTS
WHERE
SUB_ACCOUNT_NUMBER = :SUBACCOUNTNUMBER
INTO :ACCOUNTNUMBER;
IF (ACCOUNTNUMBER = 0) THEN
BEGIN
EXCEPTION EXP_SUB_ACCOUNT_NOT_FOUND;
EXIT;
END
ELSE
BEGIN
INSERT INTO JOURNAL
(
"ACCOUNT_NUMBER", "SUB_ACCOUNT_NUMBER", "DOCUMENTTYPE", "REFERENCE",
"TRANSDATE", "TRANSTIME", "FINMONTH", "FINYEAR", "DESCRIPTION",
"POSTED", "TRANSAMOUNT", "TRANSTYPE", "PMNTTYPE", "TAXRATE",
"TAXDESCRIP",
"TRANSTYPEABBR", "PMTTYPEABBR", "DOCTYPEABBR"
)
VALUES
(
:ACCOUNTNUMBER, :SUBACCOUNTNUMBER, :DOCTYPE, UPPER(:REFERENCE),
:TRANSDATE, :TRANSTIME, :FINMONTH, :FINYEAR,
UPPER(:DESCRIPTION), 'N',
:TRANSAMOUNT, :TRANSTYPE, :MOP, :lvTAXRATE, :lvTAXDESCRIP,
:lvTRANSTYPEABBR, :lvPMTTYPEABBR, :lvDOCTYPEABBR
);
END
END
^
[Non-text portions of this message have been removed]
I keep on getting a "column unknown" when I try and create the following
stored procedure. What am i doing wrong? All the tables and table columns
are there ...
Thanks in advance,
Tim
ALTER PROCEDURE "INSERT_CREDIT_SUB_ACCOUNT"
(
"SUBACCOUNTNUMBER" INTEGER,
"DOCTYPE" INTEGER,
"REFERENCE" VARCHAR(128),
"TRANSDATE" DATE,
"TRANSTIME" TIME,
"FINMONTH" INTEGER,
"FINYEAR" INTEGER,
"DESCRIPTION" VARCHAR(128),
"TRANSAMOUNT" INTEGER,
"TRANSTYPE" INTEGER,
"TAXTYPE" INTEGER,
"MOP" INTEGER
)
AS
DECLARE VARIABLE "lvTAXRATE" NUMERIC(8,2);
DECLARE VARIABLE "lvTAXDESCRIP" VARCHAR(128);
DECLARE VARIABLE "lvTAXAMOUNT" INTEGER;
DECLARE VARIABLE "lvTRANSTYPEABBR" VARCHAR(3);
DECLARE VARIABLE "lvPMTTYPEABBR" VARCHAR(3);
DECLARE VARIABLE "lvDOCTYPEABBR" VARCHAR(3);
DECLARE VARIABLE "ACCOUNTNUMBER" INTEGER;
BEGIN
lvTAXRATE = 0;
lvTAXDESCRIP = 'NONE';
lvPMTTYPEABBR = 'NON';
lvTRANSTYPEABBR = 'NON';
lvDOCTYPEABBR = 'NON';
SELECT TAXRATE, DESCRIPTION
FROM TAXTYPETABLE
WHERE
TAXTYPETABLE.RECORDNO = :TAXTYPE
INTO
:lvTAXRATE, :lvTAXDESCRIP;
SELECT ABBREVIATION
FROM
PAYMENTTYPE
WHERE
PAYMENTTYPE.RECORDNO = :MOP
INTO
:lvPMTTYPEABBR;
SELECT ABBREVIATION
FROM
TRANSTYPETABLE
WHERE
TRANSTYPETABLE.RECORDNO = :TRANSTYPE
INTO
:lvTRANSTYPEABBR;
SELECT ABBREVIATION
FROM
DOCUMENTTYPE
WHERE
DOCUMENTTYPE.RECORDNO = :DOCTYPE
INTO
:lvDOCTYPEABBR;
ACCOUNTNUMBER = 0;
SELECT ACCOUNT_NUMBER
FROM SUB_ACCOUNTS
WHERE
SUB_ACCOUNT_NUMBER = :SUBACCOUNTNUMBER
INTO :ACCOUNTNUMBER;
IF (ACCOUNTNUMBER = 0) THEN
BEGIN
EXCEPTION EXP_SUB_ACCOUNT_NOT_FOUND;
EXIT;
END
ELSE
BEGIN
INSERT INTO JOURNAL
(
"ACCOUNT_NUMBER", "SUB_ACCOUNT_NUMBER", "DOCUMENTTYPE", "REFERENCE",
"TRANSDATE", "TRANSTIME", "FINMONTH", "FINYEAR", "DESCRIPTION",
"POSTED", "TRANSAMOUNT", "TRANSTYPE", "PMNTTYPE", "TAXRATE",
"TAXDESCRIP",
"TRANSTYPEABBR", "PMTTYPEABBR", "DOCTYPEABBR"
)
VALUES
(
:ACCOUNTNUMBER, :SUBACCOUNTNUMBER, :DOCTYPE, UPPER(:REFERENCE),
:TRANSDATE, :TRANSTIME, :FINMONTH, :FINYEAR,
UPPER(:DESCRIPTION), 'N',
:TRANSAMOUNT, :TRANSTYPE, :MOP, :lvTAXRATE, :lvTAXDESCRIP,
:lvTRANSTYPEABBR, :lvPMTTYPEABBR, :lvDOCTYPEABBR
);
END
END
^
[Non-text portions of this message have been removed]