Merge query error in Where clause

Following error is coming when i execute the merge query. Anything wrong with this? I am using Oracle 9.2.0.1.
Query:
MERGE
     INTO incompletekalls ic
     USING live_small ls
     ON ((ls.callid = ic.callid) AND
     (ls.sdate = ic.sdate) AND
     (ls.stime = ic.stime))
WHEN MATCHED THEN
     UPDATE
     SET     ic.adate = ls.adate,
          ic.atime = ls.atime,
          ic.edate = ls.edate,
          ic.etime = ls.etime
     WHERE
          ls.sdate = '16-Apr-09' AND ls.stime >= '09:00:00' AND ls.stime <= '11:00:00' AND ((ls.adate IS NULL) OR
          (ls.edate IS NULL))
WHEN NOT MATCHED THEN
     INSERT (ic.callid,ic.cg,ic.cd,ic.re,ic.opc,ic.dpc,ic.sdate,ic.stime,ic.adate,ic.atime,ic.edate,ic.etime)
     VALUES (ls.callid,ls.cg,ls.cd,ls.re,ls.opc,ls.dpc,ls.sdate,ls.stime,ls.adate,ls.atime,ls.edate,ls.etime)
     WHERE ls.sdate >= '16-Apr-09' AND ls.stime >= '09:00:00' AND ls.stime <= '11:00:00'
Error:
SQL> /
WHERE
ERROR at line 13:
ORA-00905: missing keyword

Hi,
From looking at the documented examples
http://www.oracle.com/pls/db92/db92.drilldown?levelnum=2&toplevel=a96540&method=FULL&chapters=0&book=&wildcards=1&preference=&expand_all=&verb=&word=MERGE#a96540
and on http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5318183934935
I think that you cannot use the WHERE in your MERGE like that on 9i...
Something else I want to warn you for:
It's a bad idea to store your date and time separated as strings! You'll run into troubles sooner or later, for 100%...
Use a single DATE column instead, in which you store both the date and time components..

Similar Messages

  • Query in the where clause is not allowed

    Hi all,
    I have a table m_vehicle that stores 1 or more than 1 rows of data for each person. But the partner's schema requires that 0 or 1 vehicle license plate data be sent with the xml file. I have the following nested select statement inside a bigger one and it does not work,
    select xmlelement("VehicleLicensePlate",
         (case when mv.lic_plate_state is not null then
              xmlelement("PlateState", mv.lic_plate_state)
         end), -- end of plate state
         (case when mv.lic_plate_no is not null then
              xmlelement("PlateNumber", xmlelement("ID", mv.lic_plate_no))
         end),
         (case when mv.lic_plate_year is not null then
              xmlelement("PlateExpiryYear", mv.lic_plate_year)                                                  
         end)
         ).extract('/*')
    from m_vehicle mv where mv.mni_id = 1083650
    and mv.seq_no = (select max(mv2.seq_no) from m_vehicle mv2
    where mv2.mni_id = mv.mni_id) and mv.lic_plate_no is not null
    But it works when I run it alone and gets the latest row for the person. It does not work either if I join this table with other tables. My root element select is from dual because I have to supply lots of SOAP and other artifacts in the xml. Is it because I have this root select from dual that the query in the where clause does not work? How do I make it work so that I get 0 or one row only from the table? My solution was to write a function that returns each part of the license plate data using dymanic sql and call it in the xmlelement function. It works but I would like to use plain sql instead.
    Thanks.
    Ben

    By the way, the error I get is this,
    ERROR:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00216: invalid character 3 (0x3)
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 111
    Ben

  • DATAMOVER: Error: Syntax error in where clause for PSOPRDEFN

    SET LOG C:\PSUSER_HRM.log;
    SET input F:\psoprdefn.dat;
    IMPORT psoprdefn where OPRId = 'PS';
    when i execute this command after importing .dat file from my database i get error:
    Error: Syntax error in where clause for PSOPRDEFN
    any suggestions pls help....
    Thanks
    aravind
    Edited by: 967641 on Nov 20, 2012 11:39 AM
    Edited by: 967641 on Nov 20, 2012 11:40 AM

    That is correct.
    Datamover tries to insert data in PSOPRDEFN and rows exist with these keys.
    To avoid this you can add the following statement in your script:
    SET UPDATE_DUPS;
    This will update the values other than the keys if a row already exists in the database with the keys in the dat file.
    I can advice you to buy the new book of Jim Marion, PeopleSoft PeopleTools Data Management and Upgrade Handbook
    http://www.amazon.com/PeopleSoft-PeopleTools-Management-Upgrade-Handbook/dp/0071787925/ref=sr_1_1?ie=UTF8&qid=1353575734&sr=8-1&keywords=jim+j+marion
    It has an entire chapter on how to use datamover.
    Hakan

  • Problem: Error in WHERE clause. Unrecognized clause or element.

    Hi All,
    i have a replicat and tried to filter some rows:
    This was my MAP-Statement in the param-file:
    MAP GOMS3KT, TARGET goldengate.txlog,
    COLMAP (
    tsid = #IDTIMESTAMP(),
    syskey = SYSKEY,
    type = "KT",
    trxtimestamp = #TRAILJULIANTS(),
    acquirer = #ACQFILTER(acq-id-schema_1,acquirer-id_1,log-item-length_2),
    origin = #ASSERTDEFAULT2(bezugssystem_1 ," " ,log-item-length_2),
    issuer = #MANIPULATEISSUER(bezugssystem_1, ISS-ID-SCHEMA_1, ISSUER-ID_1, -1, log-item-length_2)
    ) where (bezugssystem_1 = "PSVL");
    At runtime, i got this error:
    2013-02-25 09:09:42 WARNING OGG-00869 No unique key is defined for table 'TXLOG'. All viable columns will be used to represent the
    key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
    ...(bezugssystem_1 = "PSVL")...
    ^
    Error in WHERE clause. Unrecognized clause or element.
    The column 'bezugssystem_1' does exist, i mapped it before to a the oracle column 'origin'
    What is wrong here ??
    I i delete the where clause all works fine!
    Edited by: Felix_GG on 26.02.2013 15:44
    Edited by: Felix_GG on 26.02.2013 18:25

    Of course, in the where clause should stand a '=' or what i wrote (but is not able to show) the signs for NOT EQUAL, a 'less than' followed by a 'greater then'

  • The to_date() error in where clause of proc code

    In a proc code, firstly I use "SELECT to_char(f_date_1, 'DDMONYY') into :char_date FROM TBL_1;" to get the value of f_date_1.
    Then I use "SELECT ID FROM TBL_2 WHERE f_date_2 = :char_date;" to get the value of ID according char_date.
    In table, the type of f_date_1 and f_date_2 is DATE.
    char_date is "char char_date[10]".
    My question is:
    1. If I use WHERE f_date_2 = to_date(:char_date, 'DDMONYY'), it will prompt: "-1861, ORA-01861: literal does not match format string".
    2. If I use WHERE f_date_2 = :char_date, it will work well.
    Since the type of f_date_2 is DATE and the type of char_date is CHAR, why does to_date(:char_date, 'DDMONYY') have problems?
    Thanks.

    I was not able to duplicate the error you got, but I did spot something that may be affecting your results:
    *Set up test table using HR.EMPLOYEES*
    create table TEST_DATE as
    select employee_id, last_name, hire_date
    from employees
    var char_date char(10)
    begin
    select to_char(hire_date,'DDMONYY') into :char_date
    from test_date
    where rownum = 1;
    end;
    *case 1*
    select *
    from test_date
    where hire_date = to_date(:char_date,'DDMONYY')
    *case 2*
    select *
    from test_date
    where hire_date = :char_date --> this assumes a implicit char to date conversionWhile I got case 2 to work, it assumes that the database is configured to recognize the character mask as a valid string format. If you tried running that query on a different database, this query may fail as well.
    To verify why case 1 may not have worked, do a quick check:
    select :char_date from dualIt is possible that you may have applied a different character mask between your first query:
    >
    SELECT to_char(f_date_1, 'DDMONYY') into :char_date FROM TBL_1;
    >
    and the WHERE clause of your second query:
    >
    WHERE f_date_2 = to_date(:char_date, 'DDMONYY')
    >
    RP

  • SELECT LIST throws error for WHERE CLAUSE

    Hi All
    I am struck with, what looking like a trivial error, but I don't know how to settle it down. I am new to Apex (3.1). I am experimenting with. I have Oracle 10g running on Windows.
    I have a dropdown item in one of my pages (SELECT list). I am trying to display few items there dynamically (depends on the user who logged in). I set it as SELECT LIST and entered the following query in "List of Values".
    select enrolled_course display_value, course_id return_value
    from COMP_LIST
    where stu_id = :APP_USER
    order by 1I got the following error.
    1 error has occurred
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.Then, I tried the step by step instruction from "Oracle® Application Express - Advanced Tutorials -Release 3.1.2 -E10497-02". Using creating list of values creation as seperately. That too, I got the same error.
    I am doing it wrong I suppose. Please correct me. Thanks in advance
    With Regards
    Guru
    Edited by: guru paran on Oct 16, 2008 5:12 PM

    Thanks Andy
    When I hardcoded, it worked.
    select enrolled_course display_value, course_id return_value
    from COMP_LIST
    --where-- --emp_id-- = --100--
    where stu_id = 100
    order by 1
    {code}
    :APP_USER is not working then, Now, I should be using v('APP_USER')? When I tried v('APP_USER'), I got the same error back! The COMP_LIST is a view. Is there some problem with the view then?
    But again, I am able to select from it without WHERE (now with hardcoded value also)....
    Edited by: guru paran on Oct 16, 2008 6:26 PM
    Added [code] tags
    Edited by: guru paran on Oct 16, 2008 6:42 PM
    It is STU_ID and not EMP_ID
    Edited by: guru paran on Oct 16, 2008 6:43 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Beginner: Getting syntax error on WHERE clause in SELECT

    I'm very new to php and mySQL.  Am using DW master/detail to generate to basic code I need.  One thing I need to do is modify a select statement in the master to include a WHERE clause to limit the selection to a particular value in one field.
    I'm getting a syntax error with the WHERE clause I'm adding to the map select statement.
    This is the portion of the error message showing the error location:
    'WHERE Group='Community' LIMIT 0, 10'
    The php that generated the select is:
    $query_maps = "SELECT * FROM tblmaps ORDER BY tblmaps.DispSeq";
    $query_limit_maps = sprintf("%s WHERE Group='%s' LIMIT %d, %d", $query_maps, $selectGroup, $startRow_maps, $maxRows_maps);
    This approach to creating the select statement is from the code generated for the master page.  It adds the LIMIT clause.  All I did was add the "WHERE Group='%s' and the $selectGroup variable which comes from earlier code.  You can see that the $selectGroup variable is equal to the "Community: group.
    I've scanned the web to see what syntax error I might be making but haven't found anything that explains it.
    The full resolved select statement is:
    SELECT * FROM tblmaps ORDER BY tblmaps.DispSeq WHERE Group='Community' LIMIT 0,10
    What am I not seeing?
    Tom

    Thanks.  Make sense but changing that didn't help.
    Here's the error message I'm getting:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Group='Community' ORDER BY tblmaps.DispSeq LIMIT 0, 10' at line 1
    The full select (from a debugging ECHO I inserted) is:
    SELECT * FROM tblmaps WHERE Group='Community' ORDER BY tblmaps.DispSeq LIMIT 0, 10
    Note that when I take the WHERE clause out, there is no syntax error.

  • Very slow query when specifying where clause

    Hi folks:
    I am using SAS with SQL Passthrough for Oracle, however that may be irrelevant to the problem.
    I have a query that I am subsetting based on a series of where clauses, and when I put the clauses into the query, it slows it down tremendously.
    I can pull the entire table and subset it later on in SAS and it is much faster.
    Can someone explain why the SQL subsetting logic runs slower than pulling 18M rows and subsetting later?
    Here is my query - hope this is enough information
    select
    a.loan_number
    , a.CFLRC_CD
    , a.cservno
    , b.cprj_typ
    , a.occ_stat
    , c.state2
    , c.city2
    , e.hstatus
    , e.hcattype
    , e.dqind
    , e.mthsdel
    from
    VEW_LL_ln_1 a
    , vew_ll_ln_2 b
    , VEW_LL_PROP_GEO_CD c
    , vew_ll_ln_actvy_1 e
    where
    a.loan_number = b.loan_number
    and a.loan_number = c.loan_number
    and a.loan_number = e.loan_number
    and e.act_dte = '01-feb-2011'
    and not (occ_stat in ('2','3'))
    and hcattype <> '800'
    and dqind not in ('E','F','G','H')
    and cprj_typ not in ('1','2','3','4','5','16','17','18','19','20','21','22')
    and cflrc_cd <> '2'
    order by
    a.loan_number
    Thanks

    You're in the wrong forum. This is the forum for the SQL Developer tool. You will get better answers in the SQL and PL/SQL forum which is here PL/SQL

  • Syntax error in WHERE clause

    Hi all,
    see the code.
    data: itab type cdhdr occurs 0,
            wa type cdhdr.
    data: begin of itab1 occurs 0,
             lifnr like lfa1-lifnr,
              ktokk like lfa1-ktokk,
            end of itab1.
    select * from cdhdr into table itab.
    select lifnr ktokk from lfa1 into table itab1
        for all entries in itab
          where lifnr = itab-objectid.
    when i go for Syntax check i am getting Error like  " when using the addition for all entries in itab " the fields  LIFNR and ITAB-OBJECTID  must have the same type and lengh.
    so, i have done the following correction in WHERE clause.
    select lifnr ktokk from lfa1 into table itab1
        for all entries in itab
          where lifnr = itab-objectid(10).
    But this time i am geting warning in German language.
    my correction is correct or not ?
    Pls guide me ..
    Thanks
    Krupali.

    select lifnr ktokk from lfa1 into table itab1
    for all entries in itab
    where lifnr = itab-objectid(10).
    But this time i am geting warning in German language.
    my correction is correct or not ?
    Answer is your correction is not correct.
    we cannot use offset with for all entries.
    you can do this way first take the itab-objectid(10) in some other field like temp than fire for all entries on temp.
    like below.
    select lifnr ktokk from lfa1 into table itab1
    for all entries in itab
    where lifnr = itab-temp."<-- see here
    Amit.
    Edited by: Amit Gujargoud on Aug 26, 2008 8:00 AM

  • Query tuning in WHERE clause

    Hi All,
    I have 2 tables.
    TABLE_A contains 10 miliion records.
    TABLE_B contains 100 Records.
    I am joining these 2 tables
    Here a.ID is in Left side
    SELECT A.*, B.*
    FROM TABLE_A a, TABLE_B b
    WHERE a.ID = b.ID;Here b.ID is in Left side
    SELECT A.*, B.*
    FROM TABLE_A a, TABLE_B b
    WHERE b.ID = a.ID;My question is which query will give better performance? I was thinking, that, if we put table column with less number of rows at Left side, then it will be faster than other.

    In current versions of Oracle, it doesn't matter in what order you sum-up your predicates in the WHERE-clause of a query: they will be optimized/executed in a same way.

  • Data Services Designer Query tranform dynamic where clause or another way

    I have an XML source that has 5 fields.  These fields are used to query 4 different SQL table data sources and do an AND inthe where clause of a query transform.  Works well if all 5 fields in the xml have data.  If one (or more) are blank, then it runs the where checking for blank matches and gives no results.  What I want to do is if a field is blank, do not use it in the where clause.  Could this be an outer join setup?  Issue is that if there is a PhoneNumber input, then to be considered a result, there must be a PhoneNumber match on potential result records...

    I have an XML source that has 5 fields.  These fields are used to query 4 different SQL table data sources and do an AND inthe where clause of a query transform.  Works well if all 5 fields in the xml have data.  If one (or more) are blank, then it runs the where checking for blank matches and gives no results.  What I want to do is if a field is blank, do not use it in the where clause.  Could this be an outer join setup?  Issue is that if there is a PhoneNumber input, then to be considered a result, there must be a PhoneNumber match on potential result records...

  • Query...where clause problem in XSQL

    I am getting error with following simple example: (however it works fine when the < sign changed to greater than > sign). Anybody any idea?
    select * from emp
    where empno < 7876
    XSQL-005: XSQL page is not well-formed.
    XML parse error at line , char
    Expected name instead of .
    null

    The "less-than" sign (also known as the "left-angle-bracket") is a special character in an XML file, since it is the start of an element like <foo>.
    So, you either have to write your query like this:
    <xsql:query>
    select * from emp where empno &;lt; 7839
    </xsql:query>or like this, escaping the entire query with a CDATA section:
    <xsql:query>
    <![CDATA[
    select * from emp where empno < 7839
    ]]>
    </xsql:query>A third option is that instead of writing:
    empno < 7839
    you exploit the fact that this is equivalent to:
    7839 > empno
    and write it that way. Since "greater-than" sign does not need to be escaped specially in an XML file, it gets the job done, too.

  • DocumentClient query with Int64 where clause is incorrect when converted and sent to Azure

    The code below constructs a query with a lambda expression involving an Int64. When the query is converted and sent to Azure, it is incorrect. I captured the request to Azure using Fiddler for the example below, and the body contained:
    {"query":"SELECT * FROM root WHERE (root.car.id = 1.01036229983142E+16) "}
    Notice the constant does not match that of the code. Is this a bug in Azure DocumentDB library? If so, where can I submit a bug?
    long carId = 10103622998314238;
    IQueryable<MyDocument> query = documentClient.CreateDocumentQuery<MyDocument>("<collectionLinkGoesHere>", new FeedOptions { MaxItemCount = 1 });
    query = query.Where((MyDocument d) => d.Car.Id == carId);
    await query.AsDocumentQuery().ExecuteNextAsync<T>();

    @kurifodo1, DocumentDB follows the JSON standard for numbers, which is http://en.wikipedia.org/wiki/IEEE_754 notation. So any long integer gets serialized to a double stored as IEE754, and will lose some precision. While this isn't the most intuitive behavior,
    it's important in order to be compliant with other tools and platforms that speak JSON.
    If you'd like to just perform equality queries, consider storing this as a string. If you'd like to perform range queries, consider breaking up the number into two parts (high and low), similar to the BigInteger structure in C#.
    Hope this helps.

  • Set_block_property does not called the query from the where clause

    Hi all,
    I have two blocks in the Oracle form 6i. Master link with the detail. Because of the data is quite huge if I have the auto query when the form is loaded hence I have two enter parameter created of From_date and To_date together with button to execute the query when that two parameter is being filled.
    I have the following quotes in the button of when-button-pressed :-
    BEGIN
    set_block_property('act_vw_sale_comm', default_where, 'invh_dt >='''|| to_date(:act_vw_sale_comm.fdate,'dd/mm/yyyy') ||''' and invh_dt <= ''' || to_date(:act_vw_sale_comm.tdate,'dd/mm/yyyy')||'');
    go_block('act_vw_sale_comm');
    execute_query;
    set_block_property('act_vw_sale_comm', default_where, '');
    END;
    However, nothing being displayed when I click on the button. Anything wrong on the above statement ? Please help me. thanks.
    Rgds
    Lim

    BEGIN
    go_block('act_vw_sale_comm');
    set_block_property('act_vw_sale_comm', default_where, 'invh_dt >= '''|| :FDATE ||''''' AND invh_dt <= '''|| :TDATE ||'''');
    execute_query;
    --set_block_property('act_vw_sale_comm', default_where, '');
    END;
    Now, I have the above statement, but still the same when try to execute the query, this time, the screen execute but does not show anything and close my form straight away. Why!
    Anyone can help me?
    Thanks
    Lim

  • Query Execution on Where Clause

    Hi I have the where cluase as below , I would like to know how does oracle decides which one to execute first,
    WHERE S.PERSPECTIVE='S'
    and s.shipment_gid=sb.shipment_gid
    AND SB.BILL_GID=CBIL.INVOICE_GID
    and inv.invoice_gid=cbil.invoice_gid
    AND S.SOURCE_LOCATION_GID=LC.LOCATION_GID
    and l.location_gid=lc.location_gid
    AND TRUNC(cbil.insert_date)=TRUNC(tc.tesco_cal_date)
    AND(lc.location_gid='N' OR lc.corporation_gid='TESCO.10719')
    AND s.source_location_gid=lc.location_gid
    AND tc.tesco_year='2013'
    AND tc.tesco_period=6
    AND tc.tesco_week_number=23     

    Hi,
    The optimizer usually goes for low-hanging fruit first.  If there is a condition that's easy to perform and narrows down the result set a lot, it will do that condition before another one that is harder to perform, or that doesn't rule out so many rows.  For example, if there are indexes on tc.tesco_period and tc.tesco_week_number, but not on tc.tesco_year, then it will probably perform one of the conditions that can be done with an index before it does the condition involving tc.tesco_year.  If there are 53 different possible values for tc.tesco_week_number, but only 6 possible values for tc_tesco_period, then it will probably to the condition on tc.tesco_week_number (and rule out about 52/53 of the rows) before it does the condition thatt involves tc.tesco_period (which only excludes about  5/6 of the rows.)
    There are always exceptions.  As others have said already, look at the execution plan if you really want to know.

Maybe you are looking for

  • Update delayed error

    Dear Team, Good day......... We are using SQL 2005 sp2 as DB &I am facing Update termination error. When Creating any document then document no is Generated but it will take time 5 to 10 min to Update in Db Table .I am getting Update Delay error. & A

  • Currency Conversion Type missing in BEx

    I have created a new conversion translation type M1 based on Monthly Average exchange. RSCUR definition for  this conversion on the time ref tab to be a "variable time reference"- End of Period for Standard Info Object Fiscal Period "0FISCPER". Is th

  • Connecting Yamaha DGX-500

    I just bought an M-Audio interface and i have it attached with midi cables to my yamaha dgx-500. I have the interface on, the cables plugged in, my yamaha on and in the midi setting. The mac has no problem recognizing my interface and that there's a

  • Error installing sap 2004s SR1 with DB2 and AIX

    Hello Gurus, I am installing MySap 2004s SR1 with DB2 and IBM AIX. I am facing the following error : <b>ERROR 2006-11-09 02:21:22 MDB-01052  Could not connect to database: DB6CliConnectUser(): [IBM][CLI Driver] SQL30082N  Attempt to establish connect

  • Incompatible Security and Connection time out

    Ok, since installing leopard, I have not been able to connect to the stronger of my two wireless connections. The weak on, which is WPA connects fine, when I can get a strong enough signal. The second, WEP (I know, people say it's weak, but thats wha