Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i can't run this

Status
Not open for further replies.

ancheswaroop

Programmer
Apr 25, 2006
12
US
select
substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,5,2) || substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,7,2)
|| substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,3,2) as CHDATE,
TEDCLZ.CA_AUTH_DLY_FILE.LG3_TIME,
TEDCLZ.CA_AUTH_DLY_FILE.LG3_TRANSACTION_AMOUNT,
TEDCLZ.CA_AUTH_DLY_FILE.LG3_APPROVAL_CODE,
TEDCLZ.CA_AUTH_DLY_FILE.LG3_MERCHANT_ID,
TEDCLZ.CA_AUTH_DLY_FILE.HASH_SRC_CRCD_I
from
TEDCLZ.CA_AUTH_DLY_FILE
left join
TEDCLZ.NEW_DAILY_AUTH_REC_IN
on
CHDATE = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_TRANSACTION_TIME
and TEDCLZ.CA_AUTH_DLY_FILE.LG3_TRANSACTION_AMOUNT = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_TRANSACTION_AMOUNT
and TEDCLZ.CA_AUTH_DLY_FILE.LG3_APPROVAL_CODE = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_APPROVAL_CODE
and TEDCLZ.CA_AUTH_DLY_FILE.LG3_MERCHANT_ID = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_MERCHANT_ID
and TEDCLZ.CA_AUTH_DLY_FILE.HASH_SRC_CRCD_I = TEDCLZ.NEW_DAILY_AUTH_REC_IN.HASH_SRC_CRCD_I
and TEDCLZ.CA_AUTH_DLY_FILE.BATCH_LOAD_NUMBER = TEDCLZ.NEW_DAILY_AUTH_REC_IN.BATCH_LOAD_NUMBER
where TEDCLZ.CA_AUTH_DLY_FILE.BATCH_LOAD_NUMBER =1100
and TEDCLZ.NEW_DAILY_AUTH_REC_IN.BATCH_LOAD_NUMBER =1100

and this is the error message

DB2 SQL error: SQLCODE: -206, SQLSTATE: 42703, SQLERRMC: CHDATE
Message: "CHDATE" is not valid in the context where it is used. 
 
If CHDATE is a field, what is its data type? What is the data type of TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_TRANSACTION_TIME?
 
Dan,
It looks to me as if CHDATE is a temporary column named defined from the 1st column built in the select.

Can you do a left join on a temporary column? I think this may be the problem.

Marc
 
Marc,

That sounds right. You cannot use any field aliases in the from clause or the were clause. There scope is limited to the select clause. The following might work:
Code:
select
  substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,5,2) || substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,7,2)
    || substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,3,2) as CHDATE,
  TEDCLZ.CA_AUTH_DLY_FILE.LG3_TIME,
  TEDCLZ.CA_AUTH_DLY_FILE.LG3_TRANSACTION_AMOUNT,
  TEDCLZ.CA_AUTH_DLY_FILE.LG3_APPROVAL_CODE,
  TEDCLZ.CA_AUTH_DLY_FILE.LG3_MERCHANT_ID,
  TEDCLZ.CA_AUTH_DLY_FILE.HASH_SRC_CRCD_I
from TEDCLZ.CA_AUTH_DLY_FILE
  left join TEDCLZ.NEW_DAILY_AUTH_REC_IN on
    (substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,5,2) || substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,7,2)
    || substr(TEDCLZ.CA_AUTH_DLY_FILE.LG3_DATE,3,2)) = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_TRANSACTION_TIME
    and TEDCLZ.CA_AUTH_DLY_FILE.LG3_TRANSACTION_AMOUNT = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_TRANSACTION_AMOUNT
    and TEDCLZ.CA_AUTH_DLY_FILE.LG3_APPROVAL_CODE = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_APPROVAL_CODE
    and TEDCLZ.CA_AUTH_DLY_FILE.LG3_MERCHANT_ID = TEDCLZ.NEW_DAILY_AUTH_REC_IN.IN_MERCHANT_ID
    and TEDCLZ.CA_AUTH_DLY_FILE.HASH_SRC_CRCD_I = TEDCLZ.NEW_DAILY_AUTH_REC_IN.HASH_SRC_CRCD_I
    and TEDCLZ.CA_AUTH_DLY_FILE.BATCH_LOAD_NUMBER = TEDCLZ.NEW_DAILY_AUTH_REC_IN.BATCH_LOAD_NUMBER
where TEDCLZ.CA_AUTH_DLY_FILE.BATCH_LOAD_NUMBER =1100
  and TEDCLZ.NEW_DAILY_AUTH_REC_IN.BATCH_LOAD_NUMBER =1100
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top