|
Question : Trying to pass a SQL parameter to crystal reports in a command statement
|
|
The above solutions are not working. The parameter works in the SQL code it will not work when I get into Crystal Reports from the command. It tells me this is an invalid column name when trying to run the report in Crystal.
SELECT DETAIL.OPERATOR, DETAIL.ID, DETAIL.OPERATOR_NAME, DETAIL.ANALYST, DETAIL.SALE_ACCTG_PERIOD, SUM(DETAIL.VOLUME_CURR) VOLUME_CURR, SUM(DETAIL.DOLLARS_CURR) DOLLARS_CURR, CASE WHEN SUM(DETAIL.VOLUME_CURR) = 0 THEN 0 ELSE ((SUM(DETAIL.DOLLARS_CURR)) / (SUM(DETAIL.VOLUME_CURR))) END PRICE_PER_BARREL_CURR, SUM(DETAIL.VOLUME_LAST) VOLUME_LAST, SUM(DETAIL.DOLLARS_LAST) DOLLARS_LAST, CASE WHEN SUM(DETAIL.VOLUME_LAST) = 0 THEN 0 ELSE ((SUM(DETAIL.DOLLARS_LAST)) / (SUM(DETAIL.VOLUME_LAST))) END PRICE_PER_BARREL_LAST, SUM(DETAIL.VOLUME_NEXT) VOLUME_NEXT, SUM(DETAIL.DOLLARS_NEXT) DOLLARS_NEXT, CASE WHEN SUM(DETAIL.VOLUME_NEXT) = 0 THEN 0 ELSE ((SUM(DETAIL.DOLLARS_NEXT)) / (SUM(DETAIL.VOLUME_NEXT))) END PRICE_PER_BARREL_NEXT, NULL VS_KS, NULL VS_NYMEX, DETAIL.PROPERTY, DETAIL.PROPERTY_NAME, DETAIL.METHOD_TYPE, DETAIL.PRICE_BASIS, DETAIL.FORMULA, DETAIL.EFF_DATE, DETAIL.COUNTY, DETAIL.BONUS, DETAIL.MILEAGE, AVG(DETAIL.GRAVITY_CURR) GRAVITY_CURR, AVG(DETAIL.GRAVITY_LAST) GRAVITY_LAST, AVG(DETAIL.GRAVITY_NEXT) GRAVITY_NEXT FROM (SELECT DET.CONTRACTING_PARTY OPERATOR, dbo.OFP_NOT_ALLOCABLE(det.u2_id) ID, NAME.NAME1 OPERATOR_NAME, PROP.ANALYST ANALYST, DET.SALE_ACCTG_PERIOD, DET.GROSS_VOLUME_VOL1 VOLUME_CURR, DET.GROSS_VALUE DOLLARS_CURR, 0 VOLUME_LAST, 0 DOLLARS_LAST, 0 VOLUME_NEXT, 0 DOLLARS_NEXT, DET.PROPERTY, PROP.NAME PROPERTY_NAME, PCE.PRICE_PARAMS_METHOD_TYPES METHOD_TYPE, PCE.PRICE_PARAMS_BASIS PRICE_BASIS, DET.PRICE_METHOD FORMULA, PCE.PRICE_PARAMS_EFF_DATES EFF_DATE, CTY.NAME COUNTY, DET.BONUS_PRICE_ADJ BONUS, MILES.INJ_PT_MILES MILEAGE, GRAVITY GRAVITY_CURR, 0 GRAVITY_LAST, 0 GRAVITY_NEXT FROM OG_SALE_DET DET, NAME, OGP_PROP PROP, CTY, PRICE_CTRC_EFF_DT PCE, RUN_TICKET RT, OGP_PROP_INJ INJ, OGP_PROP_MILES MILES WHERE DET.SALE_ACCTG_PERIOD = '2009-09-30' AND PROP.ANALYST = {?Analyst} -- AND DET.CONTRACTING_PARTY = 'OP88' --AND DET.PROPERTY IN ('151*175197','151*175154','151*175156') AND DET.GROSS_VOLUME_VOL1 > 0 AND DET.CONTRACTING_PARTY = NAME.U2_ID AND DET.PROPERTY = PROP.U2_ID AND dbo.OFP_NOT_ALLOCABLE(DET.U2_ID) = '151' AND PROP.COUNTY = CTY.U2_ID AND DET.PRICE_CTRC = PCE.u2_id AND (PCE.EFF_DATES <= '2009-09-30' AND (PCE.PRICE_PARAMS_EXP_DATES >= '2009-09-30' OR PCE.PRICE_PARAMS_EXP_DATES IS NULL ) ) AND DET.PROPERTY = INJ.U2_ID AND DET.RUN_TICKET_ID = RT.U2_ID AND INJ.INJ_PTS = RT.INJ_PT AND INJ.OGP_PROP_INJ_ID = MILES.OGP_PROP_INJ_ID UNION ALL SELECT DET.CONTRACTING_PARTY OPERATOR, dbo.OFP_NOT_ALLOCABLE(det.u2_id) ID, NAME.NAME1 OPERATOR_NAME, PROP.ANALYST ANALYST, DET.SALE_ACCTG_PERIOD, 0 VOLUME_CURR, 0 DOLLARS_CURR, DET.GROSS_VOLUME_VOL1 VOLUME_LAST, DET.GROSS_VALUE DOLLARS_LAST, 0 VOLUME_NEXT, 0 DOLLARS_NEXT, DET.PROPERTY, PROP.NAME PROPERTY_NAME, PCE.PRICE_PARAMS_METHOD_TYPES METHOD_TYPE, PCE.PRICE_PARAMS_BASIS PRICE_BASIS, DET.PRICE_METHOD FORMULA, PCE.PRICE_PARAMS_EFF_DATES EFF_DATE, CTY.NAME COUNTY, DET.BONUS_PRICE_ADJ BONUS, MILES.INJ_PT_MILES MILEAGE, 0 GRAVITY_CURR, GRAVITY GRAVITY_LAST, 0 GRAVITY_NEXT FROM OG_SALE_DET DET, NAME, OGP_PROP PROP, CTY, PRICE_CTRC_EFF_DT PCE, RUN_TICKET RT, OGP_PROP_INJ INJ, OGP_PROP_MILES MILES WHERE DET.SALE_ACCTG_PERIOD = '2009-08-31' AND PROP.ANALYST = {?Analyst} -- AND DET.CONTRACTING_PARTY = 'OP88' -- AND DET.PROPERTY IN ('151*175197','151*175154','151*175156') AND DET.GROSS_VOLUME_VOL1 > 0 AND DET.CONTRACTING_PARTY = NAME.U2_ID AND DET.PROPERTY = PROP.U2_ID AND dbo.OFP_NOT_ALLOCABLE(DET.U2_ID) = '151' AND PROP.COUNTY = CTY.U2_ID AND DET.PRICE_CTRC = PCE.u2_id AND (PCE.EFF_DATES <= '2009-08-31' AND (PCE.PRICE_PARAMS_EXP_DATES >= '2009-08-31' OR PCE.PRICE_PARAMS_EXP_DATES IS NULL ) ) AND DET.PROPERTY = INJ.U2_ID AND DET.RUN_TICKET_ID = RT.U2_ID AND INJ.INJ_PTS = RT.INJ_PT AND INJ.OGP_PROP_INJ_ID = MILES.OGP_PROP_INJ_ID UNION ALL SELECT DET.CONTRACTING_PARTY OPERATOR, dbo.OFP_NOT_ALLOCABLE(det.u2_id) ID, NAME.NAME1 OPERATOR_NAME, PROP.ANALYST ANALYST, DET.SALE_ACCTG_PERIOD, 0 VOLUME_CURR, 0 DOLLARS_CURR, 0 VOLUME_LAST, 0 DOLLARS_LAST, DET.GROSS_VOLUME_VOL1 VOLUME_NEXT, DET.GROSS_VALUE DOLLARS_NEXT, DET.PROPERTY, PROP.NAME PROPERTY_NAME, PCE.PRICE_PARAMS_METHOD_TYPES METHOD_TYPE, PCE.PRICE_PARAMS_BASIS PRICE_BASIS, DET.PRICE_METHOD FORMULA, PCE.PRICE_PARAMS_EFF_DATES EFF_DATE, CTY.NAME COUNTY, DET.BONUS_PRICE_ADJ BONUS, MILES.INJ_PT_MILES MILEAGE, 0 GRAVITY_CURR, 0 GRAVITY_LAST, GRAVITY GRAVITY_NEXT FROM OG_SALE_DET DET, NAME, OGP_PROP PROP, CTY, PRICE_CTRC_EFF_DT PCE, RUN_TICKET RT, OGP_PROP_INJ INJ, OGP_PROP_MILES MILES WHERE DET.SALE_ACCTG_PERIOD = '2009-07-31' AND PROP.ANALYST = {?Analyst} --AND DET.CONTRACTING_PARTY = 'OP88' -- AND DET.PROPERTY IN ('151*175197','151*175154','151*175156') AND DET.GROSS_VOLUME_VOL1 > 0 AND DET.CONTRACTING_PARTY = NAME.U2_ID AND DET.PROPERTY = PROP.U2_ID AND dbo.OFP_NOT_ALLOCABLE(DET.U2_ID) = '151' AND PROP.COUNTY = CTY.U2_ID AND DET.PRICE_CTRC = PCE.u2_id AND (PCE.EFF_DATES <= '2009-07-31' AND (PCE.PRICE_PARAMS_EXP_DATES >= '2009-07-31' OR PCE.PRICE_PARAMS_EXP_DATES IS NULL ) ) AND DET.PROPERTY = INJ.U2_ID AND DET.RUN_TICKET_ID = RT.U2_ID AND INJ.INJ_PTS = RT.INJ_PT AND INJ.OGP_PROP_INJ_ID = MILES.OGP_PROP_INJ_ID ) DETAIL GROUP BY DETAIL.PROPERTY, DETAIL.SALE_ACCTG_PERIOD, DETAIL.OPERATOR, DETAIL.OPERATOR_NAME, DETAIL.ANALYST, DETAIL.PROPERTY_NAME, DETAIL.METHOD_TYPE, DETAIL.PRICE_BASIS, DETAIL.FORMULA, DETAIL.EFF_DATE, DETAIL.COUNTY, DETAIL.BONUS, DETAIL.MILEAGE, DETAIL.ID
|
|
Answer : Trying to pass a SQL parameter to crystal reports in a command statement
|
|
It may be that the Crystal SQL editor can't handle such a complex query. In particular the subquery.
mlmcc
|
|
|
|