Update statement getting ORA-00904 invalid identifier

I am getting this ORA error when I try to conduct an update statement from a column value in one table to a like-named column in another table.
For instance, in my select, shown below, this query runs like a champ, returning all of my records
SELECT
b.ID,
b.ZIP, a.ZIP,
a.NAME,
a.LOCATION
FROM TBL_ARCHIVE a
INNER JOIN TBL_UAT b ON
a.ID = b.ID
WHERE
b.ID > 470000  And b.ID <470100;However, if I try to run an update statement with any of the following, I get this error. It seems so strange to me that I'd get an error using the same columns in the update statement, but would return the desired results effectively from the select statement!
one version of UPDATE
UPDATE TBL_ARCHIVE a
SET a.ZIP = TBL_UAT.ZIP
WHERE TBL_UAT.ID = a.ID;and another
UPDATE TBL_ARCHIVE
SET a.ZIP  =
(SELECT b.ZIP
FROM TBL_UAT b
WHERE b.ID <472500 And b.ID >471000)
FROM TBL_ARCHIVE a
WHERE a.ID = b.ID)
WHERE ID IN
(SELECT ID
FROM TBL_UAT b
WHERE b.ID  <472500 And b.ID >471000
);^ - this one produces a SQL not properly ended. Error ORA-00933: SQL command not properly ended.
I'm really unsure though, how what I thought was a fairly basic update statement wouldn't work. I'm using Oracle 11g but through either Toad or SQL Plus. I've gotten these same errors in both.
Though MS Access runs slow as snails, I can manage to run the update statement successfully with it, a thousand records or so at a time. Problem is, I've got about 300K records needing updating.
I've looked around for similar problems but haven't found one where someone wasn't either using a reserved word for a column, which I'm not, I don't believe, or a problem that really dealt with this error in the context of an update statement.
But I'd welcome any enlightenment on this.

rp0428 wrote:
UPDATE TBL_ARCHIVE a
SET a.ZIP = TBL_UAT.ZIP
WHERE TBL_UAT.ID = a.ID;That isn't a valid query and neither is the other one.
Please post the actual query you are using and the actual complete error message you are getting (everything about the error that is displayed).^^
That is NOT a valid query?
How else would you have an UPDATE statement created to set the value of a column in table A to the value of a (in this case, same named) column in table B?
And keep them in order to update the records appropriately?
I'll append the create statements momentarily.
Thanks!
CREATE TABLE TBL_UAT
( ID NUMBER(6),
ZIP VARCHAR2(10 BYTE) ) and
CREATE TABLE TBL_ARCHIVE
( ID NUMBER(6) NOT NULL, NAME VARCHAR2(50 BYTE),
EMAIL VARCHAR2(50 BYTE),
LOCATION VARCHAR2(50 BYTE),
DEPARTMENT VARCHAR2(50 BYTE),
PRIORITY VARCHAR2(50 BYTE),
APPROVING_MGR_NAME VARCHAR2(50 BYTE),
TYPE1 VARCHAR2(50 BYTE),
TYPE2 VARCHAR2(50 BYTE),
CONTACT_NAME VARCHAR2(50 BYTE),
CONTACT_PHN_NO VARCHAR2(50 BYTE),
LOAN_NUM VARCHAR2(50 BYTE),
REF_ID VARCHAR2(50 BYTE),
BORROWER_NAME VARCHAR2(50 BYTE),
ADDRESS VARCHAR2(50 BYTE),
CITY VARCHAR2(50 BYTE),
ST VARCHAR2(50 BYTE),
ZIP VARCHAR2(10 BYTE),
SALE_DATE DATE,
COMMENTS VARCHAR2(800 BYTE),
TIME_REQ DATE,
ACCTLOC VARCHAR2(50 BYTE),
OTHER_ACCTLOC VARCHAR2(50 BYTE)) Hope this can be of assistance.
Thanks, folks!
Edited by: user515689 on Feb 7, 2012 11:59 AM

Similar Messages

  • Why do I get a "DATE1 : ORA-00904 Invalid identifier" error ?

    Hi,
    Despite my efforts, I can't see why I get a "DATE1 : ORA-00904 Invalid identifier' error whith this request.
    {code}With S1 as (
    SELECT TRUNC(DATE1, 'MM'),
    ROUND(SUM(VALEUR), 2)
    FROM EVV_E036
    GROUP BY TRUNC(DATE1, 'MM')
    ORDER BY TRUNC(DATE1, 'MM'))
    SELECT n,
    NVL(ROUND(SUM(Valeur),2), 0)
    FROM (select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n FROM dual connect by level <= 12) months
    LEFT JOIN S1
    ON months.n = TRUNC(DATE1, 'MM')
    GROUP BY n
    ORDER BY n{code}
    The line in error is this one : {code}ON months.n = TRUNC(DATE1, 'MM'){code}
    Any idea much appreciated !
    Regards,
    Christian

    hi,
    I have done this and get no more errors. Now I see that the values I get are equal to 0. Or, I do get values different from 0 in my table ! I can't see why the left join gives 0. I have to dig this and come back tomorrow.
    With S1 as (
    SELECT TRUNC(DATE1, 'MM') Date1,
           ROUND(SUM(VALEUR), 2) Debit
    FROM   EVV_E036
    WHERE  CLEF_VAR = (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE = 'E036')
    AND    DATE1 BETWEEN TO_DATE ('01/01/2007000000', 'DD/MM/YYYYHH24MISS') AND TO_DATE ('31/12/2007235959', 'DD/MM/YYYYHH24MISS')
    GROUP  BY TRUNC(DATE1, 'MM')
    ORDER  BY TRUNC(DATE1, 'MM'))
    SELECT n,
           NVL(ROUND(SUM(Debit),2), 0)
    FROM   (select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n FROM dual connect by level <= 12) months
    LEFT JOIN S1
         ON months.n = date1
    GROUP BY n
    ORDER BY n

  • Internal SYS_OP_ATG function generates "ORA-00904: : invalid identifier"

    After gathering system statistics a MERGE statement within a PLSQL block now always raises "ORA-00904: : invalid identifier". Investigation points to internal SQL executed by the CBO using the SYS_OP_ATG function to be the culprit. What is this function and why does it raise "ORA-00904: : invalid identifier"? As a temporary solution deleting system statistics has made the problem disappear. My concern is that it will reappear.
    Merge statement is within a procedure within a package. Nothing had been re-compiled. System statistics were gathered then the following statement errors every time. There is an exception handler around it which raises the "ORA-00904: : invalid identifier". Delete system stats and it all works fine again:
    MERGE INTO lp_data lp
    USING (
    SELECT
    f.ubimsg_id ubimsg_id,
    f.endpoint_id endpoint_id,
    f.msg_created_date msg_created_date,
    t.end_time end_time,
    DECODE(t.units_used,255,0, t.units_used) units_used,
    DECODE(t.units_used,255,'N', 'Y') reading_received
    FROM TABLE (CAST (tab_lp_values AS load_profiles)) t,
    (SELECT ubirec.ubimsg_id ubimsg_id ,ubirec.endpoint_id endpoint_id, ubirec.msg_created_date msg_created_date FROM dual) f
    ) lp_rec
    on (lp.endpoint_id = lp_rec.endpoint_id
    and lp.end_time = lp_rec.end_time)
    when matched then
    update set lp.entry_date = lp_rec.msg_created_date,
    lp.ubimsg_id = lp_rec.ubimsg_id,
    lp.units_used = lp_rec.units_used / 10,
    lp.reading_received = lp_rec.reading_received
    when not matched then
    insert (lp.endpoint_id,
    lp.end_time,
    lp.entry_date,
    lp.ubimsg_id,
    lp.units_used,
    lp.reading_received)
    values (lp_rec.endpoint_id,
    lp_rec.end_time,
    lp_rec.msg_created_date,
    lp_rec.ubimsg_id,
    lp_rec.units_used / 10,
    lp_rec.reading_received );
    The line FROM TABLE (CAST (tab_lp_values AS load_profiles)) t casts a plsql object collection. An SQL trace showed the following SQL which must be internal SQL generated for the MERGE statement.
    SELECT distinct TBL$OR$IDX$PART$NUM("LP_DATA", 0, 1, 0, "END_TIME") FROM
    (SELECT "LP_REC"."END_TIME" "END_TIME" FROM (SELECT :B1 "UBIMSG_ID",:B2 "ENDPOINT_ID",:B3 "MSG_CREATED_DATE",
    SYS_OP_ATG(VALUE(KOKBF$),1,2,2) "END_TIME",
    DECODE(SYS_OP_ATG(VALUE(KOKBF$),2,3,2),255,0,SYS_OP_ATG(VALUE(KOKBF$),2,3,2)) "UNITS_USED",
    DECODE(SYS_OP_ATG(VALUE(KOKBF$),2,3,2),255,'N','Y') "READING_RECEIVED"
    FROM TABLE(CAST(:B4 AS "LOAD_PROFILES") ) "KOKBF$","SYS"."DUAL" "DUAL") "LP_REC") ORDER BY 1
    Without system statistics the trace did not have this statement in it, and the explain plan for the MERGE differed.
    Oracle 11.1.0.7.0 Windows 32-BIT.
    select * from v$version;
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    SQL> show parameter compatible
    compatible string 11.1.0.0.0
    Any help to explain / resolve this issue would be much appreciated.

    Duplicate thread: CBO on 11G generates ORA-00904 with SYS_OP_ATG

  • Advanced Conditions causing ORA-00904 invalid identifier

    I have another weird thing going on...
    It may be the complexity of the data I'm pulling, but I'm going to simplify the problem first...
    I have several conditions in my workbook that I need to be true regardless then I need the following (this is a payroll thing):
    ((Total Regular Hours > 40 AND Total Overtime = 0) OR (Total Overtime > 0 AND (Total Regular Hours - Total Overtime Hours) <> 40))
    So, I'm using Discoverer Plus 10g and if I create separate conditions for Total Overtime > 0 and (Total Regular Hours - Total Overtime Hours) <> 40) it will work, but if I try to combine them into one condition (so I can then add my OR and the other 2 conditions) it gives me the "ORA-00904 invalid identifier" error and will not run.
    The only way I've been able to do it is to create 3 conditions and 2 worksheets. That way, I can add (Total Regular Hours > 40 AND Total Overtime = 0) in one condition and apply it to one sheet; then I the other 2 separate conditions can be applied to the other worksheet.
    I hate having to have 2 worksheets when I should be able to create an advanced condition... anyone have any ideas?
    Regards,
    Emily

    It is actually a typo in the message because I have a calculated column that calculates the difference... sorry.
    I did try the idea of running the SQL that was generated in SQL Developer and it doesn't look right.
    It did all my other conditions under the where, but then where I would have thought it should do another and it did a WHERE.... see below. (I only pasted from the from statement on to save room)
    FROM HRBG_PEOPLE_ASSIGNMENT o393615, APPS.PTEN_PAY_BEE_V o393616
    WHERE ( (o393616.ASSIGNMENT_ID = o393615.ASSIGNMENT_ID))
    AND (o393615.BG_SECURITY_FLAG_CODE = 'Y')
    AND (o393616.DATE_EARNED BETWEEN o393615.ASSIGNMENT_START_DATE AND o393615.ASSIGNMENT_END_DATE AND o393616.DATE_EARNED BETWEEN o393615.RECORD_START_DATE AND o393615.RECORD_END_DATE)
    AND (o393616.DATE_EARNED IN (:"Date Earned Dates"))
    AND (o393616.EFFECTIVE_DATE = :"Period End Date")))))
    WHERE ( ( NP100 ) > 40 AND ( NP101 ) = 0)
    AND ( ( NP104 ) <> 40 AND ( NP105 ) > 0)
    ORDER BY E393849 ASC ;
    Do you see the WHERE that I marked in BOLD? That should be an AND...
    I even tried creating one crazy long condition to include everything in one and still got the same error and it produced the same SQL. I am thinking it has to do with the fact that I'm actually showing group totals for Regular Hours and Overtime and then subtracting them to get the difference. It all breaks when I add that difference in with the others. If I keep it separate, it does fine.
    By the way, the error I get when running just the SQL is "not all variables bound"
    Thanks,
    Emily

  • Discoverer report :ORA -00904 Invalid Identifier

    Hi ,
    we are using an apps mode EUL (version4i) ,
    in the business area "Account Receivables"--->Customer Transaction Lines Folder,
    when we pull up any item from this folder to create a report, it shows a
    "ORA-00904 Invalid Identifier " error
    how to fix it , whether the Item might be Deleted in view definition of this folder,
    just a refresh of the folder is enough ?
    thanks in advance

    Hi,
    Refreshing the folder should be your first step.
    Rod West

  • IR: ORA-20001: get_dbms_sql_cursor error ORA-00904: : invalid identifier

    Hi everyone,
    has anyone else had this error which has been driving me round the bend during the last three days?
    I have an interactive report which used to work fine.
    Now it happens (when the page loads/a filter is en- or disabled) that - from time to time, but unpredictable - I receive
    ORA-20001: get_dbms_sql_cursor error ORA-00904: : invalid identifier
    The report is based on a table function.
    I will try to set up a testcase and post the link here, but so far I haven't managed to force the error to occur.
    But maybe someone else has already bumped into this kind of error? I would be grateful for any hints!
    Best regards,
    Sabine
    Application Express 4.1.0.00.32
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

    Hi Jari,
    I changed the type definition (the return type of the table function) and extended the select list in the source of the IR.
    I do not use 'select *' but reference every column explicitly. So APEX easked me whether to add the new column.
    I also tried deleting in recreating the region, but no luck.
    Any more ideas?
    Best regards,
    Sabine

  • Getting ora:00904 invalid indentifier error while running i query

    Hi,
    I have a remote database and local database both are oracle 10gR2.Now i have written the below mentioned query in my local database and is working fine,but in case remote database it is throughing error ora:00904 invalid indentifier.
    I had export the dump from remote db and import it on my local db and i tried the same and it is working fine on local after that also.
    As i believe that this error usually come for column name not exist or column name or it's length or for any special character in column name of the table.But as i said it is working fine on local db but not in remote db though i am using the same dump for local and remote.
    Though when i am querying the table i can able to fetch data for the any record but when i am using the below mentioned query for the same i am getting the error.As i am doing this to fecth the data for child parent related relationship.
    Can any one suggest is there anything related to configaration or something else.
    Please do let me know if you do want some more information on the query what i am doing inside of it.
    Rgds,
    Anit
    Edited by: Anit A. on Sep 1, 2008 2:32 AM
    Edited by: Anit A. on Sep 1, 2008 2:33 AM

    WITH t
    AS
    SELECT decode(t.spnlevel
    ,3,t.u_quotesdtlid
    ,2,decode((select count(*)
    from u_quotesdtl t2
    where t2.u_quotesdtlid = t.u_quotesdtlid
    and t2.parentspn = (t2.jobgroupid||':'||t2.jobtype)
    ),0,(select t1.u_quotesdtlid
    from u_quotesdtl t1
    where t1.spnitemcode = t.parentspn
    and t1.spnlevel = '3'
    and t1.jobtype = t.jobtype
    and t1.jobgroupid = t.jobgroupid
    and t1.QUOTEID = t.QUOTEID
    ),t.u_quotesdtlid
    ,1,decode((select count(*)
    from u_quotesdtl t2
    where t2.QUOTEID = t.QUOTEID
    and t2.parentspn = (t2.jobgroupid||':'||t2.jobtype)
    ),0,t.u_quotesdtlid,decode((select count(*)
    from u_quotesdtl t3
    where t3.QUOTEID = t.QUOTEID
    and t3.parentspn = (t3.jobgroupid||':'||t3.jobtype)
    and t3.u_quotesdtlid in (select t1.u_quotesdtlid
    from u_quotesdtl t1
    where t1.spnitemcode = t.parentspn
    and t1.spnlevel = '2'
    and t1.jobtype = t.jobtype
    and t1.jobgroupid = t.jobgroupid
    and t1.QUOTEID = t.QUOTEID
    ),0,(select t4.u_quotesdtlid
    from u_quotesdtl t4
    ,(select t1.parentspn
    ,t1.jobtype
    ,t1.jobgroupid
    from u_quotesdtl t1
    where t1.spnitemcode = t.parentspn
    and t1.spnlevel = '2'
    and t1.jobtype = t.jobtype
    and t1.jobgroupid = t.jobgroupid
    and t1.QUOTEID = t.QUOTEID
    ) t5
    where t4.spnitemcode = t5.parentspn
    and t4.spnlevel = '3'
    and t4.jobtype = t5.jobtype
    and t4.jobgroupid = t5.jobgroupid
    and t4.QUOTEID = t.QUOTEID
    (select t1.u_quotesdtlid
    from u_quotesdtl t1
    where t1.spnitemcode = t.parentspn
    and t1.spnlevel = '2'
    and t1.jobtype = t.jobtype
    and t1.jobgroupid = t.jobgroupid
    and t1.QUOTEID = t.QUOTEID
    ,null,t.u_quotesdtlid) as parentquoteid
    ,t.u_quotesdtlid as quotesdtlid
    ,t.spnlevel as spnlevel
    FROM u_quotesdtl t
    WHERE t.QUOTEID ='som key id'
    ORDER BY parentquoteid,t.spnlevel desc
    select * from t;

  • PL/SQL: ORA-00904: invalid identifier (DG4ODBC 11.2.0.2 & MySQL)

    I have a PL/SQL script processing information between Oracle database and MySQL database. My script ran perfectly with DG4ODBC 11.1.0.7. Then we upgraded Oracle to 10.2.0 and DG4ODBC 11.2.0.2. Now if I run my script from Solaris command line like ./myscript.shl, I get the following errors:
    PL/SQL: ORA-00904: "cmswhit_moodle1"."mdl_grade_grades"."finalgrade": invalid identifier
    PL/SQL: ORA-00904: "cmswhit_moodle1"."mdl_question_states"."attempt": invalid identifier
    The strange thing is if I run the same query by cut and paste into sqlplus from command line, the query works perfectly without any problems.
    What is the cause of this problem?
    Any help would be greatly appreciated.
    Jeffrey

    Hi Klaus,
    The problem was solved after I updated MySQL ODBC to a new version from 5.1.8 to 5.1.13.
    Summary of the problem and its solution:
    The Problem: It appears that dg4odbc 11.2.0.2 requires a newer version of MyODBC. Previously I used MyODBC 5.1.8 which ran into problems with dg4odbc 11.20.0.2.
    The Solution: After I updated MyODBC to 5.1.13, my PL/SQL scripts all work.
    I need to point out that with MyODBC 5.1.8, I can run queries and updates from SQL*Plus console, but now PL/SQL scripts.
    I'll close this thread.
    Once again, thank you and happy holidays.
    Jeffrey

  • Error ORA-00904  invalid identifier

    There are so many different employee rates colums in the employee table .
    e.g)
    emp_rate_1 column has all different salaries(10,20,30)
    emp_rate_2 column has all different salaries(20,30,40)
    If I do pick up one rate , it works fine as below
    select
         SUM(emp_rate_1) as emp_rate_1
                   from employee_t
    result $60
    but i have to summarize all different rate amount using loop. before looping method,
    I tried as simple like below
    declare
    V_emp_rate_1_ID number;
    begin
    V_emp_rate_1_ID :=1;
    select
         SUM(emp_rate_||trim(V_emp_rate_1_ID)) as emp_rate_1
                   from employee_t ;
    end;
    I have an error message;
    PL/SQL: ORA-00904: "emp_rate_": invalid identifier
    ORA-06550: line 5, column 1:
    PL/SQL: SQL Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    how can I put dynamic column into Sum() in the query?
    or would you give me your advice to solve the solution.

    Not clear whether you are trying to get two sums (one for each column) or one sum that totals both columns)
    select
    SUM(emp_rate_1) as emp_rate_1
    from employee_t
    result $60But you can do all three with one query
    select
    SUM(emp_rate_1) as emp_rate_1, sum(emp_rate_2) as emp_rate_2, sum (emp_rate_1 + emp_rate_2) as sum_both
    from employee_t

  • Multi-row sub query returns  ORA-00904 :invalid identifier error

    I am creating a report from two tables that I am not joining. I want a single line for every row in table1 that meets a date range. Table2 can contain none or many rows for each recored in table1. I want to get up to two fields from table2.
    I was using a case statement to check if there was data and then an in-line query or subquery. Once again, the idea is to have a single line on the report for each table1 record.
    I get this error with the code below. It seems the nested multi-row subquery can not see the a.cr_mas_cr_no identifier.
    ORA-00904: "a"."cr_mas_cr_no": invalid identifier
    Any help is greatly appreciated,
    Sam
    select
    a.cr_mas_cr_no "CRNO", a.cr_mas_type "TYPE", a.cr_mas_status "CR Status",
    a.cr_mas_date_logged "Logged date", a.CR_REL_REQ_APP_DATE "RTP approved",a.CR_REL_REQ_RTP_DATE "RTP Date",
    a.cr_accepted_date "Complete", a.cr_mas_submitted_by "Requester",
    select doc_user FROM crrm_cr_documents WHERE doc_cr_number =a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'BD' ) "Bus Design",
    (select doc_user FROM crrm_cr_documents WHERE doc_cr_number = a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'TD' ) "Tech Design",
    (select doc_user FROM crrm_cr_documents WHERE doc_cr_number = a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'TE' ) "User acceptance test",
    case
    when (select count(appr_user) from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') > 0
    then (select appr_user from (select * from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
    end
    "RTP #1",
    case
    when (select count(appr_user) from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') > 1
    then (select appr_user from (select * from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 2)
    end
    "RTP #2",
    a.CR_REL_REQ_RTP_BY "Released by",
    a.CR_ACCEPTED_BY "Post RTP User Acceptance",
    a.cr_mas_title "Title", a.cr_mas_id "ID"
    from
    crrm_crmaster a
    where
    (a.CR_REL_REQ_RTP_DATE >= :P1109_BEGDATE and (a.CR_REL_REQ_RTP_DATE <= :P1109_ENDDATE) and
    (a.cr_mas_status = 'Complete' or (a.cr_mas_status = 'Release Approved'and a.CR_REL_REQ_APP_DATE < :P1109_ENDDATE))
    Message was edited by:
    slavanaway

    Iceman,
    Thanks for the reply I will try your suggestion.
    I will try and explain why I think two subqueries (an in-line query with a subquery?) are required. I will use the creation of the column RTP #1 as the example as the RTP #2 column is only different in the rownum selected.
    Looking only at the lines that fail, here is my analysis. (If I rem out the two case lines the query runs, I just don't get two columns of data I need.) I will only examine the first case as the second is changed to extract the second approval via the rownum = 2 criteria. The first statement checks there is at least one RTP approval stored for the request and then gets the user who approved the request if the test is true.
    case when
    (select count(appr_user) from crrm_cr_approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP') > 0
    then
    The above part works fine and the correct count of approvals is returned.
    (select appr_user from (select * from crrm_cr_approvals where appr_cr_no=a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
    end
    "RTP #1",
    I moved the parenthesis to the correct location. There can be multiple approvals for a given parent record. Some parent records need one, some need two approvals. If I replace
    (select appr_user from (select * from crrm_cr_approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
    with
    (select appr_user from approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP' and rownum = 1)
    The correct result is returned because it returns exactly one row as rownum=1 limits the query. When rownum = 2 then the query returns null as the rownum never gets to two as the rownum column is built via the set created by the second subquery.
    The subquery builds a set of approvals for a specific "cr_no" and appr_type of "RTP". the outer query then looks at the rownum of the second query
    Here is where I got the rownum information from;
    http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
    So here is what I think is happening;
    1. Main query From and Where are processed. This should provide the "set" for the query
    2.The from subqueries for RTP #1 and RTP #2 should be able to access the a.cr_mas_cr_no field and build a set from the approvals table.
    3.The RTP #1/2 subquery (inline maybe a better description?) would then get the correct row from the from subquery.
    The error "invalid identifier" refers to the a.cr_mas_cr_no field. I assume it means it can not resolve the table alias inside the subquery.
    So maybe your grouping would help, I will try.
    Sam

  • ORA-00904 invalid identifier error

    Here are the steps to reproduce this. My DB version is 9i R2.
    1) create table xmlsun1 of xmltype;
    2) create table xmlsun2 as select * from xmlsun1;
    Two Tables of XML Type created successfully
    3) insert into xmlsun1 values(xmltype('<employees><employee id="35"><FirstName>Tom</FirstName><LastName>Kyte</LastName></employee></employees>'));
    4) insert into xmlsun2 values(xmltype('<employees><employee id="35"><FirstName>Tom</FirstName><LastName>Kyte</LastName></employee></employees>'));
    Now when i query, i can see one record in each tables.
    The problem is only when updation.
    5) update xmlsun1 x
    set value(x) = updatexml(value(x),'/employees/employee/@id','37')
    where existsnode(value(x),'/employees/employee[FirstName = "Tom"]') = 1;
    1 row updated
    6) update xmlsun2 x
    set value(x) = updatexml(value(x),'/employees/employee/@id','37')
    where existsnode(value(x),'/employees/employee[FirstName = "Tom"]') = 1;
    This updation fails with the error : ORA-01775: looping chain of synonyms
    I tried to change alias of xmlsun2 to y
    update xmlsun2 y
    set value(y) = updatexml(value(y),'/employees/employee/@id','37')
    where existsnode(value(y),'/employees/employee[FirstName = "Tom"]') = 1;
    I get an error saying that Y is an invalid identifier. Now, how can i update the table xmlsun2? I can't use the alias x nor any other alias.
    Thanks,
    Sundar

    I've filed bug 5560960 for this behavoir, which is still not what you are describing.. Do you have SYNONYMS defined somewhere in your example ?
    $ sqlplus scott/tiger @testcase3
    SQL*Plus: Release 9.2.0.6.0 - Production on Fri Sep 22 11:59:46 2006
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    SQL> drop table xmlsun1
    2 /
    Table dropped.
    SQL> create table xmlsun1 of xmltype
    2 /
    Table created.
    SQL> drop table xmlsun2
    2 /
    Table dropped.
    SQL> create table xmlsun2 as select * from xmlsun1
    2 /
    Table created.
    SQL> insert into xmlsun1 values( xmltype ('<employees><employee id="35"><FirstName>Tom</FirstName><LastName>Kyte</LastName></employee></employees>') )
    2 /
    1 row created.
    SQL> insert into xmlsun2 values( xmltype ('<employees><employee id="35"><FirstName>Tom</FirstName><LastName>Kyte</LastName></employee></employees>') )
    2 /
    1 row created.
    SQL> update xmlsun1 x
    2 set value(x) = updatexml(value(x),'/employees/employee/@id','37')
    3 where existsnode(value(x),'/employees/employee[FirstName = "Tom"]') = 1
    4 /
    1 row updated.
    SQL> update xmlsun2 x
    2 set value(x) = updatexml(value(x),'/employees/employee/@id','37')
    3 where existsnode(value(x),'/employees/employee[FirstName = "Tom"]') = 1
    4 /
    where existsnode(value(x),'/employees/employee[FirstName = "Tom"]') = 1
    ERROR at line 3:
    ORA-00904: "X": invalid identifier
    SQL> update xmlsun2 y
    2 set value(y) = updatexml(value(y),'/employees/employee/@id','37')
    3 where existsnode(value(y),'/employees/employee[FirstName = "Tom"]') = 1
    4 /
    where existsnode(value(y),'/employees/employee[FirstName = "Tom"]') = 1
    ERROR at line 3:
    ORA-00904: "Y": invalid identifier
    SQL>

  • Dynamic SQL Error -ORA-00904: invalid identifier

    Hello!
    I'm really hoping I can get some fast help on this. In the interest of honesty, this is for a university oracle programming assignment. I've searched everywhere I can for the answer and haven't had any luck.
    Anyway, the problem in a nutshell. I have to write a package to write a text file. The formatting information for the file is held in a table, which has columns to define the various characteristics like justification, padding character and field value.
    RECORDTYPE FIELDNAME FIELDVALUE FIELDSIZE FIELDORDER PADDINGCHAR JUSTIFICATION DATASOURCE
    7 CreditTotal v_credit 10 5 '0' LPAD PROGRAM
    7 RecordType '7' 1 1 ' ' RPAD HARDCODE
    I can build the whole file except this footer. the FieldValue "v_credit" references a variable that has the calculated total of the credit amounts for the file. There are also "v_debit", and "(v_credit-v_debt)" entries.
    My question seems simple... How can I use this VARCHAR2 value from the table, and have it reference the variable within a Dynamic SQL string? If I use the textvalue of the column in the SQL string it gives me the invalid identifier error when it hits the EXECUTE IMMEDIATE statement. There is another row for the header which has "to_char(sysdate,'DDMMYYYY')" in it, and that runs fine. I'm assuming because they are native SQL statements and variables.
    I have tried encapsulating the v_credit in "s, and using dynamica bind variables but had the same problem passing the names to the USING clause.
    The SQL string created by the procedure is: SELECT LPAD(v_credit,10,'0' ) FROM dual
    The full error is:
    ORA-00904: "V_CREDIT": invalid identifier
    ORA-06512: at "BWOOD.PKG_BRIAN", line 108
    ORA-06512: at line 2
    Line 108 is the EXECUTE IMMEDIATE statement
    I would really appreciate someones help! I'm happy to post the procedure I've written, with the caveat that it's sloppy student work and needs cleaning up of all the experimental commented attempts:)
    Edited by: user5426606 on 20-May-2009 03:34 - Added a few more facts.

    Thank you for the fast replies. I'll post a short chunk of code to demonstrate.
    The actual procedure is quite a bit longer, but this should give you the idea.
    PROCEDURE build_dbfile (p_settlement_date IN DATE, p_settlement_key IN VARCHAR2, p_type IN VARCHAR2) AS
    v_sqlString    VARCHAR2(4000) := 'SELECT ';
    v_rectype     NUMBER := 7;
    v_line           LONG;
    v_debit        NUMBER := 0;
    v_credit       NUMBER := 0;
    v_nrRecords    NUMBER := 0;
      CURSOR c_settlement IS... -- to select records for data rows
    -- cursor to select the rows with the file formatting and data info
      CURSOR c_header IS   SELECT   NVL(fieldvalue,fieldname) db_field, <---- selects the data column
                                                   fieldsize,
                                                   NVL(paddingchar, ''' ''') paddingchar,
                                                   NVL(justification,'LPAD') justification,
                                                  datasource
                                      FROM     FSS_DESKBANK_REF
                                      WHERE    recordtype = r_rec_types.recordtype
                                      ORDER BY recordType, fieldorder;
    -- SELECT to get the SUM of datarows for v_credit
      SELECT      SUM(transactionamount)
      INTO      v_credit...
    -- SELECT to get the SUM of datarows for v_debit
      SELECT      SUM(transactionamount)
      INTO      v_debit....
    FOR r_head IN c_header LOOP
    v_sqlString := v_sqlString  || r_head.justification|| '('
                                         || r_head.db_field ||','
                                         || r_head.fieldsize || ','
                                         || r_head.paddingchar || ')';
    v_sqlString := v_sqlString || ' FROM ' || v_tbl_name;
    DBMS_OUTPUT.PUT_LINE('SQL --> '||v_sqlString);
    EXECUTE IMMEDIATE v_sqlString INTO v_line;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE(v_line);
    END build_dbfile;So the loop goes through the table rows, grabs each data value and formatting column, and builds the sql string, which is then passed to the execute statement. The issue is the ones where the datarow contains a reference to v_credit, and the error is generated. ie r_head.db_field contains the string "v_credit"
    Satish, the sql does look like that in the string, but the string is built from the table, not hardcoded. ie v_sqlString = "SELECT LPAD(v_credit,10,'0' ) FROM dual" when it is passed to the EXECUTE IMMEDIATE.
    Edited by: user5426606 on 20-May-2009 05:19

  • OIM11gR2 - ORA-00904 invalid identifier ORA-00904 OIM_SP_RECONBLKUSERAUDIT

    env: OIM11gR2 + connector SAP-ER 9.1.2.4.4
    During UDF customization I created an attribute named "USR_UDF_SKY2_DATA_SCAD_CONTR", this does not generate any error but the related column was not created into USR table because the attribute name is longer that 30 character (I was not aware of this OIM limitation).
    Anyway, because OIM11.1.2 release lost the feature to delete UDF, I created another attribute for the same purpose and ignore the issue.
    At least until I try to run a Trusted Source reconciliation (SAP-ER connector) because if the result is the task "Reconciliation Update Received" (that is: user exists and must be updated) I get the the following error and the reconciliation event is not created:
    oracle.iam.platform.utils.SuperRuntimeException: oracle.iam.platform.tx.OIMTransactionException: java.sql.SQLSyntaxErrorException: ORA-00904: "USR_UDF_SKY2_DATA_SCAD_CONTR": invalid identifier
    ORA-06512: at "COL05_OIM.OIM_SP_RECONBLKUSERAUDIT", line 66
    ORA-06512: at "COL05_OIM.OIM_SP_RECONBLKUSERCRUD", line 448
    ORA-06512: at "COL05_OIM.OIM_SP_RECONBLKUSRMLSWRAPPER", line 71
    ... (full log attached) ...
    Note: no error if the result is the task "Reconciliation Insert Received" that is user does not exist and must be created.
    My thinking is the initial UDF issue leave some table/s dirty but I don't know how fix it; in addition the wrong attribute named "USR_UDF_SKY2_DATA_SCAD_CONTR" is not mapped into the SAP HRMS Trusted User Process Definition object so no reference should be invoked during the reconciliation process...
    Edited by: user1175296 on Nov 22, 2012 2:36 AM

    Following the steps for issue solving:
    1. export SandBox, unzip SandBox archive, remove all entries of the wrong attribute into all the XML files of the SandBox, zip updated SandBox archive, re-import the SandBox (thanks Nishith Nayan)
    2. ALTER TABLE USR DROP COLUMN <wrong attribute name>
    E.g. ALTER TABLE USR DROP COLUMN USR_UDF_SKY2_DATA_SCAD_CONTR
    3. DELETE FROM SDC WHERE SDC_NAME = '<wrong attribute name>'
    E.g. DELETE FROM SDC WHERE SDC_NAME = 'USR_UDF_SKY2_DATA_SCAD_CONTR'
    4. DELETE FROM MV_USER_COLS WHERE COLUMN_NAME = '<wrong attribute name>'
    E.g. DELETE FROM MV_USER_COLS WHERE COLUMN_NAME = 'USR_UDF_SKY2_DATA_SCAD_CONTR'
    Regards,
    Gabriele.

  • ORA-00904 - invalid identifier when adding new column to the report query

    Hi,
    I am trying to add a new field to an existing bespoke report query. When I click on ok, I get the following error
    message: "ORA-00904: <field name> : invalid identifier ==> <field_name>
    Any ideas what is causing this problem? Version of the report builder is : 6.0.8 and is connected to a 10.2 db.
    Any help appreciated.
    Many Thanks,
    Praveen
    Edited by: praveenrn on May 21, 2009 2:38 PM

    What is the field name ? Maybe a reserved word ? Change to "my_new_variable" to check...
    Cheers,
    Jens Rettig

  • Dynamic SQL Issue ORA-00904:invalid identifier error

    Here is my SP
    create or replace procedure srini_ref_cursor_test(p_county_code IN VARCHAR2,
    p_ref_cur out PK_FR_TYPES.cursor_type) is
    query_str varchar2(5000);
    begin
    query_str := 'SELECT * FROM dw_county where county_name = :P ';
    open p_ref_cur for query_str USING p_county_code;
    insert into srini_query_str_test values (query_str);
    commit;
    end srini_ref_cursor_test;
    When I pass the p_county_code = Adams working find.
    create or replace procedure srini_ref_cursor_test(p_county_code IN VARCHAR2,
    p_ref_cur out PK_FR_TYPES.cursor_type) is
    query_str varchar2(5000);
    begin
    query_str := 'SELECT * FROM dw_county where county_name in ('||p_county_code||')';
    open p_ref_cur for query_str;
    insert into srini_query_str_test values (query_str);
    commit;
    end srini_ref_cursor_test;
    When I pass the p_county_code = Adams for above SP I got the following error
    ORA-00904: "ADAMS": invalid identifier error
    With out Bind variables how Can I pass the Char type values in Dynamic SQL ?
    I would like to pass multipule values to p_county_code like 'Adams','Ashley' etc
    How Can I do this ?
    Thank for great help.
    Srini

    How do I write the Dynamic SQL for
    SELECT * FROM DW_COUNTY WHERE COUNTY_NAME LIKE 'Ad%'
    The usual way...
    hr@ORA10G>
    hr@ORA10G> var str varchar2(1000);
    hr@ORA10G> var cr refcursor;
    hr@ORA10G>
    hr@ORA10G> exec :str := 'select * from employees where first_name like ''A%''';
    PL/SQL procedure successfully completed.
    hr@ORA10G> -- note the escape character for each single quote
    hr@ORA10G> print str
    STR
    select * from employees where first_name like 'A%'
    hr@ORA10G>
    hr@ORA10G> exec open :cr for :str;
    PL/SQL procedure successfully completed.
    hr@ORA10G> print cr
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER      HIRE_DATE JOB_ID    SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
            103 Alexander            Hunold                    AHUNOLD                   590.423.4567         03-JAN-90 IT_PROG          9000                       102            60
            115 Alexander            Khoo                      AKHOO                     515.127.4562         18-MAY-95 PU_CLERK         3100                       114            30
            121 Adam                 Fripp                     AFRIPP                    650.123.2234         10-APR-97 ST_MAN           8200                       100            50
            147 Alberto              Errazuriz                 AERRAZUR                  011.44.1344.429278   10-MAR-97 SA_MAN          12000             .3        100            80
            158 Allan                McEwen                    AMCEWEN                   011.44.1345.829268   01-AUG-96 SA_REP           9000            .35        146            80
            167 Amit                 Banda                     ABANDA                    011.44.1346.729268   21-APR-00 SA_REP           6200             .1        147            80
            175 Alyssa               Hutton                    AHUTTON                   011.44.1644.429266   19-MAR-97 SA_REP           8800            .25        149            80
            185 Alexis               Bull                      ABULL                     650.509.2876         20-FEB-97 SH_CLERK         4100                       121            50
            187 Anthony              Cabrio                    ACABRIO                   650.509.4876         07-FEB-99 SH_CLERK         3000                       121            50
            196 Alana                Walsh                     AWALSH                    650.507.9811         24-APR-98 SH_CLERK         3100                       124            50
    10 rows selected.
    hr@ORA10G>
    hr@ORA10G>pratz

Maybe you are looking for

  • Problem when pushing IDOC from SAP to XI

    Hi,     I am trying to push an IDOC from SAP R/3 system to XI. When I processed the IDOC using test tool(WE19), it's showing message that IDOC sent succesfully to R/3 or External system. But in SM58 Transaction it gave error message that in Trabsacti

  • JSF1091: No mime type could be found for file image_name.png

    Hi Experts, JDEV 11.1.2 why this message shown in the log......? also how can i add a mime-type mapping ? <ExternalContextImpl> <getMimeType> JSF1091: No mime type could be found for file image_name.png. To resolve this, add a mime-type mapping to th

  • TRFC Queue

    Hi, Is there any job that can check the trfc queues for any error entries and remove it automatically so that it process the next one in the queue. Regards Krish

  • Handling BW variables/BO prompts

    Hi, What is the best-practice way of handling prompts/input variables in a BW/BO scenario when it comes to the time characteristic/dimension? I want to report on Cost Center Company Code Value Current Fiscal Period (user input) Value Year to date (ba

  • Get info - adding fields

    despite advising fields can be added, the option only allows "comments" field to be added to the list, how do I add the " grouping" field to my get info criteria?