I have done a create or replace view called creditcard1. If I do a "select * from creditcard1" it retrieves the data just fine. If I try to do a statement where I am listing the column names it doesn't recognize them.
create or replace view creditcard1 as
select
pidm
,tbraccd_term_c ode as "Term"
,tbraccd_detail _code as "Detail_Cod e"
,tbbdetc_desc as "Detc_Desc"
,tbraccd_tran_n umber as "Tran_Numbe r"
,DECODE(tbbdetc _type_ind, 'C', tbraccd_amount, 0.00) as "Charge_Amo unt"
,DECODE(tbbdetc _type_ind, 'P', tbraccd_amount, 0.00) as "Payment_Amount "
,tbraccd_activi ty_date as "Activity_D ate"
,tbraccd_desc as "TBRACCD_DE SC1"
,MAX (tbracct.TBRACC T_DETC_EFF_DATE )
KEEP (DENSE_RANK LAST order by (tbracct.TBRACC T_DETC_EFF_DATE )) max_detc_eff_da te
from creditcard, tbraccd, tbbdetc, tbracct
where pidm = tbraccd_pidm
and tbr_chg_tran_nu m = tbraccd_tran_nu mber
and tbbdetc_detail_ code = tbraccd_detail_ code
and pidm = '20'
and tbraccd_detail_ code = tbracct_detail_ code
group by
pidm
,tbraccd_term_c ode
,tbraccd_detail _code
,tbbdetc_desc
,tbraccd_tran_n umber
,DECODE(tbbdetc _type_ind, 'C', tbraccd_amount, 0.00)
,DECODE(tbbdetc _type_ind, 'P', tbraccd_amount, 0.00)
,tbraccd_activi ty_date
,tbraccd_desc
order by pidm, tbraccd_tran_nu mber
Then I try to run:
create or replace view creditcard2 as
select
creditcard1.pid m
,creditcard1.Te rm
,creditcard1.De tail_Code
,creditcard1.De tc_Desc
,creditcard1.Tr an_Number
,creditcard1.Ch arge_Amount
,creditcard1.Pa yment_Amount
,creditcard1.Ac tivity_Date
,creditcard1.TB RACCD_DESC1
,creditcard1.ma x_detc_eff_date
,tbracct_b_fund _code as "Charge_Fun d"
,tbracct_b_orgn _code as "Charge_Org n"
,tbracct_b_acct _code as "Charge_Acc t"
from creditcard1, tbracct
where creditcard1.Det ail_Code = tbracct_detail_ code
and creditcard1.max _detc_eff_date = tbracct_detc_ef f_date
and get this error message:
ORA-00904: "CREDITCARD1"." DETAIL_CODE":in valid identifier
I have checked the spelling - in fact I just did a cut and paste so there wouldn't be spelling errors. When I do the "select * from creditcard1" it lists the column name of "Detail_Cod e" - the same column that the error message says doesn't exist. If I try just a select statement instead of "create or replace view creditcard2 as", I get the same error. The creditcard1 view is coming from a view I did called creditcard and it didn't have any problems recognizing the column names from the original view of creditcard.
If I comment out the where clause, it just gives the same error on a different column name - if I comment out that column name, then it errors on the next column name.
I am using SQL through TOAD against an Oracle 9i database.
Any ideas on why it won't recognize the columns from the view I created?
I am doing the creditcard2 view to pull in additional data for tbracct_b_fund_ code, tbracct_b_orgn_ code and tbracct_b_acct_ code because I was getting multiple rows in the results that I didn't want. In the table TBRACCT there can be multiple rows per tbracct_detail_ code. I only want to choose data from the row with the most recent tbracct_detc_ef f_date. The MAX statement does that, but if I also select tbracct_b_fund_ code in the same statement, it pulls a row for each different value that exists in tbracct_b_fund_ code (even if the tbracct_detc_ef f_date is not the most recent). So - if there was some way to code the creditcard1 view to also include tbracct_b_fund_ code, tbracct_b_orgn_ code and tbracct_b_acct_ code without getting the duplicate data that would be helpful also.
Thanks,
Wendy Hope
create or replace view creditcard1 as
select
pidm
,tbraccd_term_c ode as "Term"
,tbraccd_detail _code as "Detail_Cod e"
,tbbdetc_desc as "Detc_Desc"
,tbraccd_tran_n umber as "Tran_Numbe r"
,DECODE(tbbdetc _type_ind, 'C', tbraccd_amount, 0.00) as "Charge_Amo unt"
,DECODE(tbbdetc _type_ind, 'P', tbraccd_amount, 0.00) as "Payment_Amount "
,tbraccd_activi ty_date as "Activity_D ate"
,tbraccd_desc as "TBRACCD_DE SC1"
,MAX (tbracct.TBRACC T_DETC_EFF_DATE )
KEEP (DENSE_RANK LAST order by (tbracct.TBRACC T_DETC_EFF_DATE )) max_detc_eff_da te
from creditcard, tbraccd, tbbdetc, tbracct
where pidm = tbraccd_pidm
and tbr_chg_tran_nu m = tbraccd_tran_nu mber
and tbbdetc_detail_ code = tbraccd_detail_ code
and pidm = '20'
and tbraccd_detail_ code = tbracct_detail_ code
group by
pidm
,tbraccd_term_c ode
,tbraccd_detail _code
,tbbdetc_desc
,tbraccd_tran_n umber
,DECODE(tbbdetc _type_ind, 'C', tbraccd_amount, 0.00)
,DECODE(tbbdetc _type_ind, 'P', tbraccd_amount, 0.00)
,tbraccd_activi ty_date
,tbraccd_desc
order by pidm, tbraccd_tran_nu mber
Then I try to run:
create or replace view creditcard2 as
select
creditcard1.pid m
,creditcard1.Te rm
,creditcard1.De tail_Code
,creditcard1.De tc_Desc
,creditcard1.Tr an_Number
,creditcard1.Ch arge_Amount
,creditcard1.Pa yment_Amount
,creditcard1.Ac tivity_Date
,creditcard1.TB RACCD_DESC1
,creditcard1.ma x_detc_eff_date
,tbracct_b_fund _code as "Charge_Fun d"
,tbracct_b_orgn _code as "Charge_Org n"
,tbracct_b_acct _code as "Charge_Acc t"
from creditcard1, tbracct
where creditcard1.Det ail_Code = tbracct_detail_ code
and creditcard1.max _detc_eff_date = tbracct_detc_ef f_date
and get this error message:
ORA-00904: "CREDITCARD1"." DETAIL_CODE":in valid identifier
I have checked the spelling - in fact I just did a cut and paste so there wouldn't be spelling errors. When I do the "select * from creditcard1" it lists the column name of "Detail_Cod e" - the same column that the error message says doesn't exist. If I try just a select statement instead of "create or replace view creditcard2 as", I get the same error. The creditcard1 view is coming from a view I did called creditcard and it didn't have any problems recognizing the column names from the original view of creditcard.
If I comment out the where clause, it just gives the same error on a different column name - if I comment out that column name, then it errors on the next column name.
I am using SQL through TOAD against an Oracle 9i database.
Any ideas on why it won't recognize the columns from the view I created?
I am doing the creditcard2 view to pull in additional data for tbracct_b_fund_ code, tbracct_b_orgn_ code and tbracct_b_acct_ code because I was getting multiple rows in the results that I didn't want. In the table TBRACCT there can be multiple rows per tbracct_detail_ code. I only want to choose data from the row with the most recent tbracct_detc_ef f_date. The MAX statement does that, but if I also select tbracct_b_fund_ code in the same statement, it pulls a row for each different value that exists in tbracct_b_fund_ code (even if the tbracct_detc_ef f_date is not the most recent). So - if there was some way to code the creditcard1 view to also include tbracct_b_fund_ code, tbracct_b_orgn_ code and tbracct_b_acct_ code without getting the duplicate data that would be helpful also.
Thanks,
Wendy Hope
Comment