473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ORA-00904 error with create or replace view

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_code as "Term"
,tbraccd_detail_code as "Detail_Code"
,tbbdetc_desc as "Detc_Desc"
,tbraccd_tran_number as "Tran_Number"
,DECODE(tbbdetc_type_ind, 'C', tbraccd_amount, 0.00) as "Charge_Amount"
,DECODE(tbbdetc_type_ind, 'P', tbraccd_amount, 0.00) as "Payment_Amount"
,tbraccd_activity_date as "Activity_Date"
,tbraccd_desc as "TBRACCD_DESC1"
,MAX (tbracct.TBRACCT_DETC_EFF_DATE)
KEEP (DENSE_RANK LAST order by (tbracct.TBRACCT_DETC_EFF_DATE)) max_detc_eff_date
from creditcard, tbraccd, tbbdetc, tbracct
where pidm = tbraccd_pidm
and tbr_chg_tran_num = tbraccd_tran_number
and tbbdetc_detail_code = tbraccd_detail_code
and pidm = '20'
and tbraccd_detail_code = tbracct_detail_code
group by
pidm
,tbraccd_term_code
,tbraccd_detail_code
,tbbdetc_desc
,tbraccd_tran_number
,DECODE(tbbdetc_type_ind, 'C', tbraccd_amount, 0.00)
,DECODE(tbbdetc_type_ind, 'P', tbraccd_amount, 0.00)
,tbraccd_activity_date
,tbraccd_desc
order by pidm, tbraccd_tran_number

Then I try to run:

create or replace view creditcard2 as
select
creditcard1.pidm
,creditcard1.Term
,creditcard1.Detail_Code
,creditcard1.Detc_Desc
,creditcard1.Tran_Number
,creditcard1.Charge_Amount
,creditcard1.Payment_Amount
,creditcard1.Activity_Date
,creditcard1.TBRACCD_DESC1
,creditcard1.max_detc_eff_date
,tbracct_b_fund_code as "Charge_Fund"
,tbracct_b_orgn_code as "Charge_Orgn"
,tbracct_b_acct_code as "Charge_Acct"
from creditcard1, tbracct
where creditcard1.Detail_Code = tbracct_detail_code
and creditcard1.max_detc_eff_date = tbracct_detc_eff_date

and get this error message:

ORA-00904: "CREDITCARD1"."DETAIL_CODE":invalid 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_Code" - 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_eff_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_eff_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
Apr 7 '06 #1
2 8905
I found the answer to my problem from another source, but thought I would post it here in case it could benefit someone else:

"I think the problem is in your use of explicit capitalization in the aliases for the columns of your views. Once you put double quotes around a column alias you must put double quotes around any reference to it and match the capitalization exactly from then on. So you must change all your WHERE clauses and any GROUP BYs or ORDER BYs... As a matter of coding style I would recommend leaving off all the double quotes; then by default the Oracle SQL engine will promote all references to upper case making coding much easier."
Apr 7 '06 #2
i am getting a major problem in running shell script by using dbms_scheduler package. if i write only echo in the shell script then it is running but if i want to execute normal linux command like 'ls -l' , 'chmod' etc , shell script is not executing properly. if possible then pls help me.
I found the answer to my problem from another source, but thought I would post it here in case it could benefit someone else:

"I think the problem is in your use of explicit capitalization in the aliases for the columns of your views. Once you put double quotes around a column alias you must put double quotes around any reference to it and match the capitalization exactly from then on. So you must change all your WHERE clauses and any GROUP BYs or ORDER BYs... As a matter of coding style I would recommend leaving off all the double quotes; then by default the Oracle SQL engine will promote all references to upper case making coding much easier."
Apr 7 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John | last post by:
Hi Right password -> ORA-12154: TNS:Could not resolve service name wrong password => ORA-01017: invalid username/password; logon denied Tested on a Windows XP client connecting to Oracle on...
2
by: Ping | last post by:
Where can i find the initialization file to change some parameters? This file used to be init<sid>.ora in previous versions of oracle. Oracle 9.2 on xp is in question. Thanks in advance ...
1
by: Adam Ruth | last post by:
I'm using OCI on Mac OS X and I've run into a strange problem with my TNSNAMES.ORA file. My TNSNAMES.ORA file has one entry INV4II and it works fine. However, it will only work if that is the...
6
by: bdj | last post by:
Hello! I have at set of tnsnames.ora. I wich to make an union, e.g. a single file of it. How can I do that easy? Greetings Bjørn
1
by: Paul Green | last post by:
What might cause the following behavior? We have a set of front-end programs accessing an Oracle database on the server. Things work fine on our older computers and mostly OK on our new computers...
5
by: jstmehr4u3 | last post by:
I just installed ODP.net 10.2.02 on my local machine (Windows XP Pro) running IIS. I have created a sample webservice in VS2003, connecting to localhost. I am getting:...
2
by: Dwie | last post by:
Dear All, I'm a new in Oracle DB. I'm using Windows 2000 as server and Windows XP as client. I installed Oracle Enterprise on server and Oracle 8.1 on clients. I have some client with 2 different...
7
by: lrg | last post by:
I'm writing an application in ASP.NET using C# for code behind and i'm also using oracle 10g. I thought when i retrieve data from the DB first tnsnames.ora is referred. But my experience is that...
5
by: Nitvar | last post by:
When i am trying to connect to oracle it is giving me these two errors ORA-12224: TNS:no listener ORA-01034: ORACLE not available I am new to oracle ,plz help I am using solaris 5.6 and...
1
by: bacterium | last post by:
Hi, Is there any way to solve the question :'ORA-12154: TNS:could not resolve service name' ,I import database in Oracle , but I can not logon into the database , while login through the SQL PLUS,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.