Subject | RE: [firebird-support] Stored procedure, execute statement, & external tables |
---|---|
Author | Rick Debay |
Post date | 2009-04-21T16:01:44Z |
I added CASTs to the select statement's LTRIMs so it would prepare
stand-alone. Now the stored procedure can be prepared OK, and it
returns a plan.
However, when I execute the select, I get this error:
"VENDOR_SKU, CAST(LTRIM(UNIT_SIZE)' INTO does not match returned
column type"
I then added CAST to every column where the external table didn't match
the return type of the stored procedure. I now get this error:
"CAST(VENDOR_SKU AS NUMERIC(6,0)), ' INTO does not match returned
column type"
Here's the first part of the stored procedure, you can see the column
types match (all the variables prepended with 'T_' are temporary and
used to change the data before returning it):
CREATE PROCEDURE BERGEN_PRICE_FILE_S_TST returns (
VENDOR_SKU Numeric(6,0),
UNIT_SIZE VarChar(8),
SIZE_CODE Char(2),
STRENGTH_QTY VarChar(4),
STRENGTH_CODE VarChar(6),
ITEM_DESCRIPTION VarChar(13),
CASE_QUANTITY Numeric(9,0),
PURCHASE_UNITS Char(2),
ACQUISITION Numeric(9,2),
NDDF_PKG_SIZE Numeric(18,3),
FINELINE Char(3),
NDC Numeric(11,0),
GENERIC_DESCRIPTION VarChar(25),
GENERIC_NUMBER Char(6),
THERAPEUTIC_CLASS Char(6),
GENERIC_FORM_CODE VarChar(3),
GENERIC_STRENGTH_QUANTITY VarChar(5),
GENERIC_STRENGTH_CODE VarChar(6),
UNIT_DOSE VarChar(2),
FORM_CODE VarChar(3),
CONTRACT_NUMBER VarChar(5),
CONTRACT_START Date,
CONTRACT_EXPIRE Date,
CONTRACT_PRICE Numeric(9,2),
VENDOR_NUMBER Char(5),
VENDOR_NAME VarChar(30),
NDDF_AWP Numeric(9,2),
PACKAGE_SIZE_DIVISOR Numeric(9,3),
SUPERNET_PRICE_INDICATOR Char(1),
AWP Numeric(9,2),
NDC_UPC_FORMAT_CODE Char(1),
RETAIL_PRICE Numeric(9,2),
RECORD_TYPE Char(1))
AS
DECLARE VARIABLE T_CONTRACT_START CHAR(6);
DECLARE VARIABLE T_CONTRACT_EXPIRE CHAR(6);
DECLARE VARIABLE T_ACQUISITION CHAR(7);
DECLARE VARIABLE T_NDDF_PKG_SIZE CHAR(11);
DECLARE VARIABLE T_CONTRACT_PRICE CHAR(7);
DECLARE VARIABLE T_NDDF_AWP CHAR(7);
DECLARE VARIABLE T_PACKAGE_SIZE_DIVISOR CHAR(8);
DECLARE VARIABLE T_AWP CHAR(7);
DECLARE VARIABLE T_RETAIL_PRICE CHAR(7);
BEGIN
FOR EXECUTE STATEMENT 'SELECT
CAST(VENDOR_SKU AS NUMERIC(6,0)),
CAST(LTRIM(UNIT_SIZE) AS VARCHAR(8)),
SIZE_CODE,
CAST(LTRIM(STRENGTH_QTY) AS VARCHAR(4)),
CAST(STRENGTH_CODE AS VARCHAR(6)),
CAST(ITEM_DESCRIPTION AS VARCHAR(13)),
CAST(CASE_QUANTITY AS NUMERIC(9,0)),
PURCHASE_UNITS,
ACQUISITION,
NDDF_PKG_SIZE,
FINELINE,
CAST(NDC AS NUMERIC(11,0)),
CAST(GENERIC_DESCRIPTION AS VARCHAR(25)),
GENERIC_NUMBER,
THERAPEUTIC_CLASS,
CAST(GENERIC_FORM_CODE AS VARCHAR(3)),
CAST(LTRIM(GENERIC_STRENGTH_QUANTITY) AS VARCHAR(5)),
CAST(GENERIC_STRENGTH_CODE AS VARCHAR(6)),
CAST(UNIT_DOSE AS VARCHAR(2)),
CAST(FORM_CODE AS VARCHAR(3)),
CAST(CONTRACT_NUMBER AS VARCHAR(5)),
CONTRACT_START,
CONTRACT_EXPIRE,
CONTRACT_PRICE,
VENDOR_NUMBER,
CAST(VENDOR_NAME AS VARCHAR(30)),
NDDF_AWP,
PACKAGE_SIZE_DIVISOR,
SUPERNET_PRICE_INDICATOR,
AWP,
NDC_UPC_FORMAT_CODE,
RETAIL_PRICE,
SUBSTRING(CAST(LTRIM(RECORD_TYPE) AS VARCHAR(3)) FROM 1 FOR 1)
FROM BERGEN_PRICE_FILE'
INTO
:VENDOR_SKU,
:UNIT_SIZE,
:SIZE_CODE,
:STRENGTH_QTY,
:STRENGTH_CODE,
:ITEM_DESCRIPTION,
:CASE_QUANTITY,
:PURCHASE_UNITS,
:T_ACQUISITION,
:T_NDDF_PKG_SIZE,
:FINELINE,
:NDC,
:GENERIC_DESCRIPTION,
:GENERIC_NUMBER,
:THERAPEUTIC_CLASS,
:GENERIC_FORM_CODE,
:GENERIC_STRENGTH_QUANTITY,
:GENERIC_STRENGTH_CODE,
:UNIT_DOSE,
:FORM_CODE,
:CONTRACT_NUMBER,
:T_CONTRACT_START,
:T_CONTRACT_EXPIRE,
:T_CONTRACT_PRICE,
:VENDOR_NUMBER,
:VENDOR_NAME,
:T_NDDF_AWP,
:T_PACKAGE_SIZE_DIVISOR,
:SUPERNET_PRICE_INDICATOR,
:T_AWP,
:NDC_UPC_FORMAT_CODE,
:T_RETAIL_PRICE,
:RECORD_TYPE
DO BEGIN
Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.
stand-alone. Now the stored procedure can be prepared OK, and it
returns a plan.
However, when I execute the select, I get this error:
"VENDOR_SKU, CAST(LTRIM(UNIT_SIZE)' INTO does not match returned
column type"
I then added CAST to every column where the external table didn't match
the return type of the stored procedure. I now get this error:
"CAST(VENDOR_SKU AS NUMERIC(6,0)), ' INTO does not match returned
column type"
Here's the first part of the stored procedure, you can see the column
types match (all the variables prepended with 'T_' are temporary and
used to change the data before returning it):
CREATE PROCEDURE BERGEN_PRICE_FILE_S_TST returns (
VENDOR_SKU Numeric(6,0),
UNIT_SIZE VarChar(8),
SIZE_CODE Char(2),
STRENGTH_QTY VarChar(4),
STRENGTH_CODE VarChar(6),
ITEM_DESCRIPTION VarChar(13),
CASE_QUANTITY Numeric(9,0),
PURCHASE_UNITS Char(2),
ACQUISITION Numeric(9,2),
NDDF_PKG_SIZE Numeric(18,3),
FINELINE Char(3),
NDC Numeric(11,0),
GENERIC_DESCRIPTION VarChar(25),
GENERIC_NUMBER Char(6),
THERAPEUTIC_CLASS Char(6),
GENERIC_FORM_CODE VarChar(3),
GENERIC_STRENGTH_QUANTITY VarChar(5),
GENERIC_STRENGTH_CODE VarChar(6),
UNIT_DOSE VarChar(2),
FORM_CODE VarChar(3),
CONTRACT_NUMBER VarChar(5),
CONTRACT_START Date,
CONTRACT_EXPIRE Date,
CONTRACT_PRICE Numeric(9,2),
VENDOR_NUMBER Char(5),
VENDOR_NAME VarChar(30),
NDDF_AWP Numeric(9,2),
PACKAGE_SIZE_DIVISOR Numeric(9,3),
SUPERNET_PRICE_INDICATOR Char(1),
AWP Numeric(9,2),
NDC_UPC_FORMAT_CODE Char(1),
RETAIL_PRICE Numeric(9,2),
RECORD_TYPE Char(1))
AS
DECLARE VARIABLE T_CONTRACT_START CHAR(6);
DECLARE VARIABLE T_CONTRACT_EXPIRE CHAR(6);
DECLARE VARIABLE T_ACQUISITION CHAR(7);
DECLARE VARIABLE T_NDDF_PKG_SIZE CHAR(11);
DECLARE VARIABLE T_CONTRACT_PRICE CHAR(7);
DECLARE VARIABLE T_NDDF_AWP CHAR(7);
DECLARE VARIABLE T_PACKAGE_SIZE_DIVISOR CHAR(8);
DECLARE VARIABLE T_AWP CHAR(7);
DECLARE VARIABLE T_RETAIL_PRICE CHAR(7);
BEGIN
FOR EXECUTE STATEMENT 'SELECT
CAST(VENDOR_SKU AS NUMERIC(6,0)),
CAST(LTRIM(UNIT_SIZE) AS VARCHAR(8)),
SIZE_CODE,
CAST(LTRIM(STRENGTH_QTY) AS VARCHAR(4)),
CAST(STRENGTH_CODE AS VARCHAR(6)),
CAST(ITEM_DESCRIPTION AS VARCHAR(13)),
CAST(CASE_QUANTITY AS NUMERIC(9,0)),
PURCHASE_UNITS,
ACQUISITION,
NDDF_PKG_SIZE,
FINELINE,
CAST(NDC AS NUMERIC(11,0)),
CAST(GENERIC_DESCRIPTION AS VARCHAR(25)),
GENERIC_NUMBER,
THERAPEUTIC_CLASS,
CAST(GENERIC_FORM_CODE AS VARCHAR(3)),
CAST(LTRIM(GENERIC_STRENGTH_QUANTITY) AS VARCHAR(5)),
CAST(GENERIC_STRENGTH_CODE AS VARCHAR(6)),
CAST(UNIT_DOSE AS VARCHAR(2)),
CAST(FORM_CODE AS VARCHAR(3)),
CAST(CONTRACT_NUMBER AS VARCHAR(5)),
CONTRACT_START,
CONTRACT_EXPIRE,
CONTRACT_PRICE,
VENDOR_NUMBER,
CAST(VENDOR_NAME AS VARCHAR(30)),
NDDF_AWP,
PACKAGE_SIZE_DIVISOR,
SUPERNET_PRICE_INDICATOR,
AWP,
NDC_UPC_FORMAT_CODE,
RETAIL_PRICE,
SUBSTRING(CAST(LTRIM(RECORD_TYPE) AS VARCHAR(3)) FROM 1 FOR 1)
FROM BERGEN_PRICE_FILE'
INTO
:VENDOR_SKU,
:UNIT_SIZE,
:SIZE_CODE,
:STRENGTH_QTY,
:STRENGTH_CODE,
:ITEM_DESCRIPTION,
:CASE_QUANTITY,
:PURCHASE_UNITS,
:T_ACQUISITION,
:T_NDDF_PKG_SIZE,
:FINELINE,
:NDC,
:GENERIC_DESCRIPTION,
:GENERIC_NUMBER,
:THERAPEUTIC_CLASS,
:GENERIC_FORM_CODE,
:GENERIC_STRENGTH_QUANTITY,
:GENERIC_STRENGTH_CODE,
:UNIT_DOSE,
:FORM_CODE,
:CONTRACT_NUMBER,
:T_CONTRACT_START,
:T_CONTRACT_EXPIRE,
:T_CONTRACT_PRICE,
:VENDOR_NUMBER,
:VENDOR_NAME,
:T_NDDF_AWP,
:T_PACKAGE_SIZE_DIVISOR,
:SUPERNET_PRICE_INDICATOR,
:T_AWP,
:NDC_UPC_FORMAT_CODE,
:T_RETAIL_PRICE,
:RECORD_TYPE
DO BEGIN
Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.