MERGE INTO error

Hi,
I'm trying to use the MERGE INTO statement. I wrote a script with all the statements. Everything runs fine EXCEPT for one statement:
MERGE INTO TEMPLATE_COMPONENT_TMP2 A USING
(SELECT
  1011 as "TEMPLATE_COMPONENT_ID",
  'Service Canada Logo' as "TEMPLATE_COMPONENT_NAME_EN",
  'Logo de Service Canada' as "TEMPLATE_COMPONENT_NAME_FR",
  TO_DATE('06/03/2009 15:25:08', 'MM/DD/YYYY HH24:MI:SS') as "PRODUCTION_START_DATE",
  TO_DATE('06/03/2009 15:25:08', 'MM/DD/YYYY HH24:MI:SS') as "DATE_CREATED",
  1 as "USER_CREATED",
  1 as "CD_TMPLT_COMPONENT_CTGRY_ID",
  'Service Canada Logo' as "TEMPLATE_COMPONENT_DESC_EN",
  'Logo de Service Canada' as "TEMPLATE_COMPONENT_DESC_FR",
  NULL as "PRODUCTION_END_DATE",
  TO_DATE('06/03/2009 15:31:28', 'MM/DD/YYYY HH24:MI:SS') as "DATE_UPDATED",
  NULL as "USER_UPDATED",
  2 as "CD_LANGUAGE_ID",
  1 as "EDITABLE_IND",
  1 as "VERSION_NUMBER",
  3 as "CD_TMPLT_COMPONENT_TP_ID",
  1 as "CD_EXTERNAL_DATA_SOURCE_ID",
  1 as "SHARED_IND",
  NULL as "CD_FIELD_FORMAT_TYPE_ID",
  NULL as "FIELD_FORMAT_ALGORITHM",
  NULL as "DATASOURCE_TAG",
  NULL as "MAPPING_COLUMN_NAME",
  NULL as "MAPPING_TABLE_NAME",
  1 as "MANDATORY_COMPONENT_IND",
  'Change-over: CLS to ACS' as "REASON_TEXT",
  NULL as "CHANGE_DESCRIPTION",
  '<ns0:para component_code="1011" xmlns:ns0="http://acs.prv/templateComponents"><w:p xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"><w:pPr><w:pStyle w:val="Header" /></w:pPr><w:r><w:pict><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"><v:stroke joinstyle="miter" /><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0" /><v:f eqn="sum @0 1 0" /><v:f eqn="sum 0 0 @1" /><v:f eqn="prod @2 1 2" /><v:f eqn="prod @3 21600 pixelWidth" /><v:f eqn="prod @3 21600 pixelHeight" /><v:f eqn="sum @0 0 1" /><v:f eqn="prod @6 1 2" /><v:f eqn="prod @7 21600 pixelWidth" /><v:f eqn="sum @8 21600 0" /><v:f eqn="prod @7 21600 pixelHeight" /><v:f eqn="sum @10 21600 0" /></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /><o:lock v:ext="edit" aspectratio="t" /></v:shapetype><w:binData w:name="wordml://02000001.jpg">/9j/4AAQSkZJRgABAgEBLAEsAAD/4Qo0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA
AAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAdAAAAcgEyAAIAAAAUAAAAj4dp
AAQAAAABAAAApAAAANAAAAEsAAAAAQAAASwAAAABQWRvYmUgUGhvdG9zaG9wIENTIE1hY2ludG9z
aAAyMDA1OjA5OjE1IDE1OjQ4OjUxAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAlqADAAQAAAAB
AAAAHwAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEA
AgAAAgEABAAAAAEAAAEuAgIABAAAAAEAAAj+AAAAAAAAAEgAAAABAAAASAAAAAH/2P/gABBKRklG
AAECAQBIAEgAAP/tAAxBZG9iZV9DTQAB/+4ADkFkb2JlAGSAAAAAAf/bAIQADAgICAkIDAkJDBEL
CgsRFQ8MDA8VGBMTFRMTGBEMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAENCwsN
Dg0QDg4QFA4ODhQUDg4ODhQRDAwMDAwREQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM
DAwM/8AAEQgAHwCWAwEiAAIRAQMRAf/dAAQACv/EAT8AAAEFAQEBAQEBAAAAAAAAAAMAAQIEBQYH
CAkKCwEAAQUBAQEBAQEAAAAAAAAAAQACAwQFBgcICQoLEAABBAEDAgQCBQcGCAUDDDMBAAIRAwQh
EjEFQVFhEyJxgTIGFJGhsUIjJBVSwWIzNHKC0UMHJZJT8OHxY3M1FqKygyZEk1RkRcKjdDYX0lXi
ZfKzhMPTdePzRieUpIW0lcTU5PSltcXV5fVWZnaGlqa2xtbm9jdHV2d3h5ent8fX5/cRAAICAQIE
BAMEBQYHBwYFNQEAAhEDITESBEFRYXEiEwUygZEUobFCI8FS0fAzJGLhcoKSQ1MVY3M08SUGFqKy
gwcmNcLSRJNUoxdkRVU2dGXi8rOEw9N14/NGlKSFtJXE1OT0pbXF1eX1VmZ2hpamtsbW5vYnN0dX
Z3eHl6e3x//aAAwDAQACEQMRAD8ArK30j/lXD/4+v/qgqit9I/5Vw/8Aj6/+qCz47jze0y/zc/7s
vyfU1kdd6/j9MptrmMz0w6hhBhxcSwOn6P6N300H60dZy+ksosxjWfVLmOreJPEtsZDm/RXG9R6t
' as "TEMPLATE_COMPONENT_CONTENT",
  1011 as "TEMPLATE_COMPONENT_CODE",
  0 as "FREQUENCY_IND",
  0 as "REPEAT_IND",
  'ACS' as "REQUESTED_BY",
  'ACS' as "APPROVED_BY",
  NULL as "CD_PROGRAM_GROUP_ID_BAK"
  FROM DUAL) B
ON (A.TEMPLATE_COMPONENT_ID = B.TEMPLATE_COMPONENT_ID)
WHEN NOT MATCHED THEN
INSERT (
  TEMPLATE_COMPONENT_ID, TEMPLATE_COMPONENT_NAME_EN, TEMPLATE_COMPONENT_NAME_FR, PRODUCTION_START_DATE, DATE_CREATED,
  USER_CREATED, CD_TMPLT_COMPONENT_CTGRY_ID, TEMPLATE_COMPONENT_DESC_EN, TEMPLATE_COMPONENT_DESC_FR, PRODUCTION_END_DATE,
  DATE_UPDATED, USER_UPDATED, CD_LANGUAGE_ID, EDITABLE_IND, VERSION_NUMBER,
  CD_TMPLT_COMPONENT_TP_ID, CD_EXTERNAL_DATA_SOURCE_ID, SHARED_IND, CD_FIELD_FORMAT_TYPE_ID, FIELD_FORMAT_ALGORITHM,
  DATASOURCE_TAG, MAPPING_COLUMN_NAME, MAPPING_TABLE_NAME, MANDATORY_COMPONENT_IND, REASON_TEXT,
  CHANGE_DESCRIPTION, TEMPLATE_COMPONENT_CONTENT, TEMPLATE_COMPONENT_CODE, FREQUENCY_IND, REPEAT_IND,
  REQUESTED_BY, APPROVED_BY, CD_PROGRAM_GROUP_ID_BAK)
VALUES (
  B.TEMPLATE_COMPONENT_ID, B.TEMPLATE_COMPONENT_NAME_EN, B.TEMPLATE_COMPONENT_NAME_FR, B.PRODUCTION_START_DATE, B.DATE_CREATED,
  B.USER_CREATED, B.CD_TMPLT_COMPONENT_CTGRY_ID, B.TEMPLATE_COMPONENT_DESC_EN, B.TEMPLATE_COMPONENT_DESC_FR, B.PRODUCTION_END_DATE,
  B.DATE_UPDATED, B.USER_UPDATED, B.CD_LANGUAGE_ID, B.EDITABLE_IND, B.VERSION_NUMBER,
  B.CD_TMPLT_COMPONENT_TP_ID, B.CD_EXTERNAL_DATA_SOURCE_ID, B.SHARED_IND, B.CD_FIELD_FORMAT_TYPE_ID, B.FIELD_FORMAT_ALGORITHM,
  B.DATASOURCE_TAG, B.MAPPING_COLUMN_NAME, B.MAPPING_TABLE_NAME, B.MANDATORY_COMPONENT_IND, B.REASON_TEXT,
  B.CHANGE_DESCRIPTION, B.TEMPLATE_COMPONENT_CONTENT, B.TEMPLATE_COMPONENT_CODE, B.FREQUENCY_IND, B.REPEAT_IND,
  B.REQUESTED_BY, B.APPROVED_BY, B.CD_PROGRAM_GROUP_ID_BAK)
WHEN MATCHED THEN
UPDATE SET
  A.TEMPLATE_COMPONENT_NAME_EN = B.TEMPLATE_COMPONENT_NAME_EN,
  A.TEMPLATE_COMPONENT_NAME_FR = B.TEMPLATE_COMPONENT_NAME_FR,
  A.PRODUCTION_START_DATE = B.PRODUCTION_START_DATE,
  A.DATE_CREATED = B.DATE_CREATED,
  A.USER_CREATED = B.USER_CREATED,
  A.CD_TMPLT_COMPONENT_CTGRY_ID = B.CD_TMPLT_COMPONENT_CTGRY_ID,
  A.TEMPLATE_COMPONENT_DESC_EN = B.TEMPLATE_COMPONENT_DESC_EN,
  A.TEMPLATE_COMPONENT_DESC_FR = B.TEMPLATE_COMPONENT_DESC_FR,
  A.PRODUCTION_END_DATE = B.PRODUCTION_END_DATE,
  A.DATE_UPDATED = B.DATE_UPDATED,
  A.USER_UPDATED = B.USER_UPDATED,
  A.CD_LANGUAGE_ID = B.CD_LANGUAGE_ID,
  A.EDITABLE_IND = B.EDITABLE_IND,
  A.VERSION_NUMBER = B.VERSION_NUMBER,
  A.CD_TMPLT_COMPONENT_TP_ID = B.CD_TMPLT_COMPONENT_TP_ID,
  A.CD_EXTERNAL_DATA_SOURCE_ID = B.CD_EXTERNAL_DATA_SOURCE_ID,
  A.SHARED_IND = B.SHARED_IND,
  A.CD_FIELD_FORMAT_TYPE_ID = B.CD_FIELD_FORMAT_TYPE_ID,
  A.FIELD_FORMAT_ALGORITHM = B.FIELD_FORMAT_ALGORITHM,
  A.DATASOURCE_TAG = B.DATASOURCE_TAG,
  A.MAPPING_COLUMN_NAME = B.MAPPING_COLUMN_NAME,
  A.MAPPING_TABLE_NAME = B.MAPPING_TABLE_NAME,
  A.MANDATORY_COMPONENT_IND = B.MANDATORY_COMPONENT_IND,
  A.REASON_TEXT = B.REASON_TEXT,
  A.CHANGE_DESCRIPTION = B.CHANGE_DESCRIPTION,
  A.TEMPLATE_COMPONENT_CONTENT = B.TEMPLATE_COMPONENT_CONTENT,
  A.TEMPLATE_COMPONENT_CODE = B.TEMPLATE_COMPONENT_CODE,
  A.FREQUENCY_IND = B.FREQUENCY_IND,
  A.REPEAT_IND = B.REPEAT_IND,
  A.REQUESTED_BY = B.REQUESTED_BY,
  A.APPROVED_BY = B.APPROVED_BY,
  A.CD_PROGRAM_GROUP_ID_BAK = B.CD_PROGRAM_GROUP_ID_BAK;
[/code]
It's giving me:
'<ns0 ara component_code="1011" xmlns:ns0="http://acs.prv/templateComponents"><w  xmlns:w="http:
ERROR at line 29:
ORA-01704: string literal too long
I guess it's NORMAL because a string max length is 4000 char. Here I have a CLOB.
What can I do to workaround this problem?
Thanks in advance,
Marc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Let me explain the FULL picture...
We have 3 environments (databases) with the same table structure. I have to take the data from Table A, in DEV database, and copy it to Table A, in TST and PROD database. They don't want to loose any data that is already in TST and PROD. PLUS, I can't use any DATABASE LINKS (against OUR standards). This is why I was thinking of using the MERGE or UPDATE statements.
I have a script that reads Table A, and builds a script with all the UPDATE statement. Then I found that TOAD could build a MERGE INTO script for me, so I did that. When I tried executing the MERGE script, I got the STRING error (max of 4000 char exeeded).
What are my alternatives?
Please advise !
Thanks in advance,
Marc.

Similar Messages

  • Error when attempting to merge into table with RLS - ORA - 28132

    hey,
    i've encountered an "ORA-28132 - Merge into syntax does not support security policies" when attempting to merge into a table with RLS defined on it.
    i looked around and found this [discussion |http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:259415261270] on ask tom.
    according to the thread - this was a bug in 9i. in 10g merge is possible only if the policy returns "null" and in 11g it was finally fixed.
    *i have been able to merge into tables with rls in 10gR2 in some cases.*
    i would like to know if anyone has some more information about this error. when can i merge into tables with RLS ?
    thanks, Haki.

    Never.
    The bug was that it did work sometimes in 10g i.e. it should always raise an error.
    It's something that I've always found a bit odd and frustrating - that MERGE and RLS policy should not be compatible.
    But bottom line is that you shouldn't be using MERGE on table with RLS policy.
    Edited by: Dom Brooks on Feb 14, 2011 10:51 AM

  • PI 7.1 runtime error: 2 messages are merged into one

    Hi,
    We have recently upgraded to 71. We are having a crtical issue with one of the interface. below are the details:
    Background:Interface is using ABAP mapping to convert an Idoc into file.
    File name is fed into u2018dynamic configurationu2019 in mapping program.
    File adapter uses dynamic file name and saves the file using NFS.
    Interface receives idocs in batch, so several Idocs are received by XI almost at the same time.
    Interface has been working without any problem in version 3.00 for last 3 years.
    Problem in 71.:On occasions (random, not always), 2 idocs are merged into one file. It means, only one file is created, which includes the data from 2 idocs.
    In message pipeline, same file name is shown both message (in dynamic config after mapping)
    We have tried u2018use temporary filenameu2019 option on file adapter, but problem is not resolved.
    Any sugegstion pelase!

    Hi,
    In your Graphical mapping create an UDF with code Thread.sleep(1000)  and map this udf to any node (may be root node).
    Note: The delay is in mili sec.
    This udf will delay the mapping for specific time. I am not sure if it is going to solve your problem but you can try.
    Regards,
    Sarvesh

  • VBA Merge PDFs - Error when first and second PDF are the same

    Using http://khkonsulting.com/2009/03/adobe-acrobat-and-vba-an-introduction/ as a guide, I am able to successfully merge multiple pdf's together into one document using VBA (Access mdb), except when the PDF being merged to has the same name as the next PDF.
    Here's my scenario.  An Access table is updated with a list of reports that need to be printed.  All of these reports are PDF's.  I loop thru this table and merge the PDF's according to an identifier, then print the group.  There are times
    when there are multiple copies of the same report for an identifier.  If the PDF being merged to has the same name of the PDF being merged, an error occurs.  How can I handle this situation?
    Sample data:  This identifier (ESO and Pulling) needs to merge these PDF's (Aaa.PDF) together which happen to have the same name.  Aaa.PDF is trying to merge Aaa.PDF and this throws an error.
    Aaa.PDF ESO  Pulling
    Aaa.PDF ESO  Pulling
    This identifier merges fine despite having the same PDF twice.  But the first PDF is not named the same.  Xxx.PDF is the first PDF and merges the next two into it.  The last two
    are named the same.
    Xxx.PDF  916  Pulling
    Bbb.PDF  916  Pulling
    Bbb.PDF  916  Pulling
    Code:
    pdfDoc1.Open (filesToMerge(1))
    numPages = pdfDoc1.GetNumPages()
    Set pdfDoc2 = CreateObject("AcroExch.PDDoc")
    Dim i As Integer
    For i = 2 To intNbr - 1
    pdfDoc2.Open (filesToMerge(i))
    If pdfDoc1.InsertPages(numPages - 1, pdfDoc2, 0, pdfDoc2.GetNumPages(), True) = False Then
    MsgBox "Cannot insert pages"
    End If
    pdfDoc2.Close
    Next i
    If pdfDoc1.Save(PDSaveFull, "C:\....\ReportPacket__" & Trim(CStr(intReportCount)) & "__" & ... & ".pdf") = False Then
    MsgBox "Cannot save the modified document"
    End If
    pdfDoc1.Close
    The pdfDoc1.InsertPages command fails, displays "Cannot insert pages", then displays "Method 'Close' of object 'CAccroPDDoc' failed.
    Thanks for any help or advice.

    Hi
    As far as I know, Access didn't provide such method. But I think you are able to achieve this goal through some 3rd party PDF component
    Hope this will help you.
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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..

  • "Merge into" statement doesn't work

    Hi Reader,
    It seems that in some of our installed machines merge into statement doesn't;t work. We've already experienced this issue on databases installed within virtual machines, but also found on other configurations sporadically.
    Using statement match a single/multiple records (according required logic)
    statement:
    MERGE INTO RNCATEGORIES CV
    USING dual ON
    ( CV.DESIGNCENTERID = in_DESIGNCENTERID
    AND CV.CADPACKAGENAME = in_CADPACKAGENAME
    WHEN MATCHED THEN
    UPDATE SET
    PKGCATEGORYID = in_PKGCATEGORYID,
         UserPackageType = in_UserPackageType
    WHEN NOT MATCHED THEN
    INSERT VALUES ( in_DESIGNCENTERID,
    in_CADPACKAGENAME, in_PKGCATEGORYID,in_UserPackageType );
    Table script:
    CREATE TABLE RNCATEGORIES
    DESIGNCENTERID RAW(16) NOT NULL,
    CADPACKAGENAME NVARCHAR2(64) NOT NULL,
    PKGCATEGORYID RAW(16),
    USERPACKAGETYPE NVARCHAR2(64)
    PK_RNCATEGORIES PRIMARY KEY (DESIGNCENTERID, CADPACKAGENAME)
    Thanks in advance,
    Amir

    After creating the table, your merge statement gives me
    SQL> MERGE INTO RNCATEGORIES CV
      2  USING dual ON
      3  ( CV.DESIGNCENTERID = in_DESIGNCENTERID
      4  AND CV.CADPACKAGENAME = in_CADPACKAGENAME
      5  )
      6  WHEN MATCHED THEN
      7  UPDATE SET
      8  PKGCATEGORYID = in_PKGCATEGORYID,
      9  UserPackageType = in_UserPackageType
    10  WHEN NOT MATCHED THEN
    11  INSERT VALUES ( in_DESIGNCENTERID,
    12  in_CADPACKAGENAME, in_PKGCATEGORYID,in_UserPackageType );
    AND CV.CADPACKAGENAME = in_CADPACKAGENAME
    ERROR at line 4:
    ORA-00904: "IN_CADPACKAGENAME": invalid identifierwhich is about what I expected. The USING clause requires a select statement, not just a table name. It looks to me like this merge statement is in some kind of stored procedure, and that the in_XXX are variables passed to that procedure. If this is correct, then your merge needs to be more like:
    MERGE INTO rncategories cv
    USING (SELECT in_designcenterid dcid, in_cadpackagename cpn,
                  in_pkgcategoryid pcid, in_userpackagetype upt
           FROM dual)
    ON (cv.designcenterid = dcid and
        cv.cadpackagename = cpn)
    WHEN MATCHED THEN
       UPDATE SET
       pkgcategoryid = pcid
       userpackagetype = upt
    WHEN NOT MATCHED THEN
       INSERT VALUES (dcid, cpn, pcid, upt);John

  • Merge Into works in SQL, fails in PL/SQL

    Database is 9i (Oracle9i Enterprise Edition Release 9.2.0.5.0)<br>
    <br>
    The 9i documentation--PL/SQL User's Guide and Reference
    Release 2 (9.2)--makes it seem like this is part of the PL/SQL language, but the compiler disagrees.<br>
    <br>
    Anyone else encounter this?<br>
    <br>
    Test case:<br>
    create table kev(d date, n number);<br><br>
    Table created.<br>
    <br>
    ..it works in SQL...<br>
    MERGE INTO kev k<br>2 USING ( SELECT 1 n, sysdate d from dual ) s<br>
    3 ON ( k.n = s.n )<br>
    4 WHEN MATCHED THEN<br>
    5 UPDATE<br>
    6 SET k.d = s.d<br>
    7 WHEN NOT MATCHED THEN<br>
    8 INSERT (n,d)<br>
    9 VALUES (s.n, s.d);<br>
    <br>
    1 row merged.<br>
    <br>
    ..but not in PL/SQL...<br>
    begin<br>2 MERGE INTO kev k<br>
    3 USING ( SELECT 1 n, sysdate d from dual ) s<br>
    4 ON ( k.n = s.n )<br>
    5 WHEN MATCHED THEN<br>
    6 UPDATE<br>
    7 SET k.d = s.d<br>
    8 WHEN NOT MATCHED THEN<br>
    9 INSERT (n,d)<br>
    10 VALUES (s.n, s.d);<br>
    11 end;<br>
    12 /<br>
    MERGE INTO kev k<br>
    *<br>
    ERROR at line 2:<br>
    ORA-06550: line 2, column 7:<br>
    PLS-00103: Encountered the symbol "INTO" when expecting one of the following:
    := . ( @ % ; <a SQL statement><br>
    <br>
    Thanks.

    Answer
    There are indeed DB parameters conflicting with the MERGE statement. The DB I am working on is for Oracle Applications. Apparently, although the applications are certified to run on current databases, the underlying code base has not really been brought up, and users are forced into some backward compatibility constraints. So I am stuck until we get our application upgraded from 11.5.7 to something better.
    Hope this helps someone else.
    Kevin
    From the database initialization parameters:
    # Events
    # Events should not be set unless directed by Oracle Support,
    # or by instruction as per the Applications documentation.
    # The following events should be set for PL/SQL backward
    # compatibility.
    # These events should only be used if you are using Oracle
    # Applications release 11.5.7. For later releases (i.e. 11.5.8
    # or higher), you should remove these events.
    event="10932 trace name context level 32768"
    event="10933 trace name context level 512"
    event="10943 trace name context level 16384"

  • MERGE INTO

    Hi All,
    i need an expert advice in this matter, and if possible please explain with some code/example.Here is the situation.
    This process will read all records in the STAGING_TABLE and process the data into the MY_DATABASE tables.
    STG_ID will be used to populate the MY_ID with in MY_DATABASE.
    Any records that fail the load process will be flagged as 'error' by populating the ERROR_TABLE with the reson for the failure. After the load has been performed, all error records will be corrcted and reloaded.
    outline as below:
    1. Read all staging table records.
    2. Use the STG_ID value to determine whether the record already exists with in the MY_DATABASE tables.
    3. If not exist, create the one with associated records.
    4. If exists, compare the staging data to the MY_DATABASE data as per the rules. Then update the appropriate data in MY_DATABASE.
    5. If any records are invalid, update the staging table record with the error message.
    6. create a record in MY_LOGS table to indicate successfull completion of the process as well as the number of records processed.
    Now my approach is to use MERGE INTO path. I know that we can do it with the help of PL/SQL. given the above scenerio which approach is the better one. we have millions of records to be processed. Do merge has the capability to take care of all the logics i.e(insert/update/logs/bad-records)
    can we use Merge in procedure and packages ?
    please give me some advise in this matter .
    Thanks!

    read the following , you might get a better idea
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#SQLRF01606
    Have you considered using External Tables ?

  • Playerglobal.swc Linkage Type: External or Merged Into Code?

    Hi,
    I downloaded Flash Pro CS6 with flex sdk version 11.3. It didn't contain Workers functionality, so I had to download the latest playerglobal.swc 11.8 version.
    I then used Actionscript options and pointed to the playerglobal.swc.
    When  I published the fla with playerglobal.swc linkage type set to Merged into Code, the runtime pops up this error:
    VerifyError: Error #1079: Native methods are not allowed in loaded code.
    However, when  I published the fla with playerglobal.swc linkage type set to External, the runtime pops up this error:
    VerifyError: Error #1014: Class flash.system::Worker could not be found.
    The only way to get rid of the VerifyError: Error #1079: Native methods are not allowed in loaded code is to get rid of all the code that reference Workers in  the fla.
    How can I use Workers in my project!???

    Here's a really old article but using it you can still get the general idea of how to properly update Flash Pro with a new version of Flash Player.
    http://chrisgriffith.wordpress.com/2012/07/20/updating-flash-professional-cs6-to-support-1 1-4/
    It's for Mac but if you're on Windows the paths inside the folders are the same and Flash itself can be found in (C:\Program Files (x86)\Adobe\Adobe Flash CS6) Just grab the player you choose, latest or use the archive link for older, update Flash Pro so it's an option you can select as a publish target:
    http://www.adobe.com/support/flashplayer/downloads.html
    As long as you've updated your debugger (C:\Program Files (x86)\Adobe\Adobe Flash CS6\Players\Debug) with the latest debugger, always test with the debugger (CTRL+SHIFT+ENTER, not just CTRL+ENTER). Otherwise you're using an older Flash Player. You can verify the version of the debugger you're testing with checking the Capabilities.version property,
    e.g.:
    import flash.system.Capabilities;
    trace(Capabilities.version); // should say 11,8,xxx,xxx or whatever version you installed

  • Problem with merge into

    Hi All!
    Following statement give me an error ORA-00904: Invalid column name in the string:
    on (Mirror.ARCH_FLAG=qt.ARCH_FLAG and Mirror.CREDIT_HEADER_ID=qt.CREDIT_HEADER_ID)
    merge into CREDIT_HEADER_P Mirror
    using (select
    CREDIT_HEADER_ID,
    PO_DATE,
    HP_RECEIVED_DATE,
    PDA_ID,
    CUSTOMER_BASE_NR,
    CREDIT_TYPE,
    CREDIT_CURRENCY,
    CLAIM_SUBTYPE_ABREV,
    CUST_PO_NO,
    BILLING_NO,
    OMS_START_SECTION_NO,
    OMS_END_SECTION_NO,
    OMS_SHIP_VIA,
    OMS_CHANGE_REASON_CODE,
    CUST_COMMENT,
    SPECIAL_INSTRUCTIONS,
    CASH_DISCOUNT,
    TARGET_SYSTEM,
    DATE_SENT_TO_TARGET_SYSTEM,
    ARCH_FLAG,
    RECORD_EXTRACTION_DATE,
    LAST_MOD_DATE
    from INC_CREDIT_HEADER_P) qt
    on (Mirror.ARCH_FLAG = qt.ARCH_FLAG and Mirror.CREDIT_HEADER_ID = qt.CREDIT_HEADER_ID)
    when matched then
    update
    set      Mirror.CREDIT_HEADER_ID=qt.CREDIT_HEADER_ID,
         Mirror.PO_DATE=qt.PO_DATE,
         Mirror.HP_RECEIVED_DATE=qt.HP_RECEIVED_DATE,
         Mirror.PDA_ID=qt.PDA_ID,
         Mirror.CUSTOMER_BASE_NR=qt.CUSTOMER_BASE_NR,
         Mirror.CREDIT_TYPE=qt.CREDIT_TYPE,
         Mirror.CREDIT_CURRENCY=qt.CREDIT_CURRENCY,
         Mirror.CLAIM_SUBTYPE_ABREV=qt.CLAIM_SUBTYPE_ABREV,
         Mirror.CUST_PO_NO=qt.CUST_PO_NO,
         Mirror.BILLING_NO=qt.BILLING_NO,
         Mirror.OMS_START_SECTION_NO=qt.OMS_START_SECTION_NO,
         Mirror.OMS_END_SECTION_NO=qt.OMS_END_SECTION_NO,
         Mirror.OMS_SHIP_VIA=qt.OMS_SHIP_VIA,
         Mirror.OMS_CHANGE_REASON_CODE=qt.OMS_CHANGE_REASON_CODE,
         Mirror.CUST_COMMENT=qt.CUST_COMMENT,
         Mirror.SPECIAL_INSTRUCTIONS=qt.SPECIAL_INSTRUCTIONS,
         Mirror.CASH_DISCOUNT=qt.CASH_DISCOUNT,
         Mirror.TARGET_SYSTEM=qt.TARGET_SYSTEM,
         Mirror.DATE_SENT_TO_TARGET_SYSTEM=qt.DATE_SENT_TO_TARGET_SYSTEM,
         Mirror.ARCH_FLAG=qt.ARCH_FLAG,
         Mirror.RECORD_EXTRACTION_DATE=qt.RECORD_EXTRACTION_DATE,
         Mirror.LAST_MOD_DATE=qt.LAST_MOD_DATE,
         Mirror.RECORD_STATUS='M'
    when not matched then
    insert (
    Mirror.CREDIT_HEADER_ID,
    Mirror.PO_DATE,
    Mirror.HP_RECEIVED_DATE,
    Mirror.PDA_ID,
    Mirror.CUSTOMER_BASE_NR,
    Mirror.CREDIT_TYPE,
    Mirror.CREDIT_CURRENCY,
    Mirror.CLAIM_SUBTYPE_ABREV,
    Mirror.CUST_PO_NO,
    Mirror.BILLING_NO,
    Mirror.OMS_START_SECTION_NO,
    Mirror.OMS_END_SECTION_NO,
    Mirror.OMS_SHIP_VIA,
    Mirror.OMS_CHANGE_REASON_CODE,
    Mirror.CUST_COMMENT,
    Mirror.SPECIAL_INSTRUCTIONS,
    Mirror.CASH_DISCOUNT,
    Mirror.TARGET_SYSTEM,
    Mirror.DATE_SENT_TO_TARGET_SYSTEM,
    Mirror.ARCH_FLAG,
    Mirror.RECORD_EXTRACTION_DATE,
    Mirror.LAST_MOD_DATE
    values (
    qt.CREDIT_HEADER_ID,
    qt.PO_DATE,
    qt.HP_RECEIVED_DATE,
    qt.PDA_ID,
    qt.CUSTOMER_BASE_NR,
    qt.CREDIT_TYPE,
    qt.CREDIT_CURRENCY,
    qt.CLAIM_SUBTYPE_ABREV,
    qt.CUST_PO_NO,
    qt.BILLING_NO,
    qt.OMS_START_SECTION_NO,
    qt.OMS_END_SECTION_NO,
    qt.OMS_SHIP_VIA,
    qt.OMS_CHANGE_REASON_CODE,
    qt.CUST_COMMENT,
    qt.SPECIAL_INSTRUCTIONS,
    qt.CASH_DISCOUNT,
    qt.TARGET_SYSTEM,
    qt.DATE_SENT_TO_TARGET_SYSTEM,
    qt.ARCH_FLAG,
    qt.RECORD_EXTRACTION_DATE,
    qt.LAST_MOD_DATE
    But! If I do:
    select Mirror.CREDIT_HEADER_ID
    from CREDIT_HEADER_P Mirror
    or
    select Mirror.ARCH_FLAG
    from CREDIT_HEADER_P Mirror
    I don't get any error. I copied (not entered new!) The column and table name from the statement above! If I submit Mirror.ARCH_FLAG and Mirror.CREDIT_HEADER_ID with 1, it works also. Any ideas?
    Regards,
    Andrej

    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#2080942
    You cannot specify DEFAULT when updating a view.
    You cannot update a column that is referenced in the ON condition clause. Problem is you use ARCH_FLAG and CREDIT_HEADER_ID in ON clause -
    on (Mirror.ARCH_FLAG = qt.ARCH_FLAG and Mirror.CREDIT_HEADER_ID = qt.CREDIT_HEADER_ID)
    and try to update them:
    set Mirror.CREDIT_HEADER_ID=qt.CREDIT_HEADER_ID,
    Mirror.ARCH_FLAG=qt.ARCH_FLAG,
    It violates the deterministic.
    Rgds.

  • Subquery inside Merge Into under 11g

    create or replace
    PROCEDURE SP_IN_CURRENCY
    IS
    CURSOR csr IS SELECT currency_code FROM in_currency ORDER BY currency_code;
    v_hkd_rate NUMBER(15,9);
    BEGIN
    SELECT spot_rate INTO v_hkd_rate FROM in_currency WHERE in_currency.currency_code = 'HKD';
    MERGE INTO currency USING
    (SELECT currency_code, spot_rate FROM in_currency WHERE in_currency.currency_code = 'HKD') rec_in_currency
    ON (currency.currency_code = rec_in_currency.currency_code)
    WHEN MATCHED THEN
    UPDATE
    SET currency.CURRENCY_NAME = NVL(
    (SELECT value
    FROM tb_resources
    WHERE PACKAGE = 'currency'
    AND locale = 'en_US'
    AND KEY = rec_in_currency.currency_code
    ), currency.CURRENCY_NAME),
    currency.spot_rate = (v_hkd_rate/rec_in_currency.spot_rate),
    currency.SPOT_RATE_IN_USD = rec_in_currency.spot_rate
    WHEN NOT MATCHED THEN
    INSERT
    currency_code,
    CURRENCY_NAME,
    spot_rate,
    SPOT_RATE_IN_USD
    VALUES
    rec_in_currency.currency_code,
    (SELECT value FROM tb_resources WHERE PACKAGE = 'currency' AND locale = 'en_US' AND KEY = rec_in_currency.currency_code),
    (v_hkd_rate/rec_in_currency.spot_rate),
    rec_in_currency.spot_rate
    COMMIT;
    END SP_IN_CURRENCY;
    The above stored procedure created successfully in 9i but retrun the following error when create on 11g. Anyone has idea? is it the limitation of 11g? The problem was caused by this subquery:
    (SELECT value FROM tb_resources WHERE PACKAGE = 'currency' AND locale = 'en_US' AND KEY = rec_in_currency.currency_code),
    Error(38,99): PL/SQL: ORA-00904: "REC_IN_CURRENCY"."CURRENCY_CODE": invalid identifier

        value assign in variable equals value return by subquery in USING clause
        so   (V_HKD_RATE / REC_IN_CURRENCY.SPOT_RATE) = 1
        and  CURRENCY_CODE = 'HKD'
        key = rec_in_currency.currency_code is always 'HKD'
        let's say
        SPOT_RATE  = 999
        v_hkd_rate = 999
    -- BEFORE:
    select  spot_rate
    into    v_hkd_rate
    from    in_currency
    where   in_currency.currency_code = 'HKD';
    merge into currency using
        select  currency_code, spot_rate
        from    in_currency
        where   in_currency.currency_code = 'HKD'
    ) rec_in_currency
    on
        currency.currency_code = rec_in_currency.currency_code
    when matched then update set
        currency.currency_name = nvl
                                        select  value
                                        from    tb_resources
                                        where   package = 'currency'
                                        and     locale = 'en_US'
                                        and     key = rec_in_currency.currency_code
                                ,   currency.currency_name
    ,currency.spot_rate           = (v_hkd_rate / rec_in_currency.spot_rate)
    ,currency.spot_rate_in_usd    = rec_in_currency.spot_rate
    when not matched then insert
        currency_code
    ,   currency_name
    ,   spot_rate
    ,   spot_rate_in_usd
    values
        rec_in_currency.currency_code
            select  value
            from    tb_resources
            where   package = 'currency'
            and     locale  = 'en_US'
            and     key     = rec_in_currency.currency_code
    ,    (v_hkd_rate/rec_in_currency.spot_rate)
    ,    rec_in_currency.spot_rate
    -- AFTER:
    merge into currency using
        select  currency_code, spot_rate
         -- 'HKD', 999
        from    in_currency
        where   in_currency.currency_code = 'HKD'
    ) rec_in_currency
    on
        currency.currency_code = 'HKD'
    when matched then update set
        /* If value IS NULL update with current value? I think you should change it... */
        currency.currency_name = nvl
                                        select  value
                                        from    tb_resources
                                        where   package = 'currency'
                                        and     locale  = 'en_US'
                                        and     key     ='HKD'
                                ,   currency.currency_name
    ,    currency.spot_rate        = 999/999
    ,    currency.spot_rate_in_usd = 999
    when not matched then insert
        currency_code
    ,   currency_name
    ,   spot_rate
    ,   spot_rate_in_usd
    values
        'HKD'
            select  value
            from    tb_resources
            where   package = 'currency'
            and     locale  = 'en_US'
            and     key     = 'HKD'
    ,   999/999
    ,   999
    Can anybody check it?
    */

  • Oracle 10: merge into problem

    From ext_mitglied I want to insert ort, plz,strasse into tbl_adresse. And I will do it with merge. The values are currently not existing in tbl_adresse. But Oracle says the unique constraint uq_adresse is violated.
    I don't see where the fault is.?
    CREATE TABLE tbl_adresse
    (o_id number(15) NOT NULL,
    ort varchar2(30) DEFAULT 'Berlin' NOT NULL,
    plz number(5) NOT NULL,
    strasse varchar2(30) NOT NULL,
    CONSTRAINT pk_adresse PRIMARY KEY (o_id),
    CONSTRAINT chk_plz CHECK (plz >= 10000),
    CONSTRAINT uq_adresse UNIQUE (ort, plz, strasse)
    CREATE TABLE ext_mitglied
    m_id number(15),
    ort varchar2(30),
    plz number(5),
    strasse varchar2(30),
    m_anrede varchar2(10),
    m_vorname varchar2(30),
    m_nachname varchar2(30),
    kto_nr number(10),
    blz number(10),
    geb_datum date,
    tel_nr varchar2(30),
    beginn date,
    ende date,
    bezahlt number(1)
    MERGE INTO tbl_adresse a
    USING ext_mitglied ex
    ON ((ex.ort=a.ort) AND (ex.plz=a.plz) AND (ex.strasse=a.strasse))
    WHEN NOT MATCHED
    THEN INSERT ( a.o_id, a.ort, a.plz, a.strasse)
    VALUES( seq_ort.NEXTVAL, ex.ort, ex.plz, ex.strasse );

    Oracle 10 is what? Is that 10.1.0.3, 10.2.0.1, 10.2.0.4 or something else?
    Nowhere in what you posted is an error message either so there is no basis upon which to advise you other than to say that I personally stay away from MERGE statements like they are a plague.
    Please provide DDL for the table, unique indexes if they exist, and constraints.
    And run your statement again.
    Then use a SELECT COUNT(*) to prove no record exists that with your merge statement won't create a violation of the named constraint.
    Then take all of it and copy it to the forum without editing so we can read it.
    Also please read the FAQ before you do and learn to use tags to make your listings understandable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • MERGE INTO and CROSS JOIN

    Hello Guys,
    I have a bit of trouble understanding the MERGE I have written here.
    All the code executes without errors. As far as I see,
    the below MERGE SELECT is a Cartesian product/cross join and I remember that is not
    good. The ON (join condition) seems to be only for the merge into table (T_CLAIMS_BB) and
    the table that comes from the select (d).
    merge into T_CLAIMS_BB t
    using
    SELECT sch_vt.SCH#,vert.CNO,vers.SubCNo,regv.ReturnNo,regv.SndReturnNo,sch_vt.MainProd,sch_vt.Prod
    FROM mainschema.TCONTRACT vert, mainschema.TVERSCONTRACT vers, commonschema.VC_REGVEREINB regv, myschema.T_CLAIMS_VT sch_vt
    ) d
    ON (
    t.sch# = d.sch# AND
    SUBSTR(UPPER(t.BOOKINGTEXT),1,2) = d.SndReturnNo AND d.SubCNo IS NULL
    ) -- Join
    when matched then
    update
    set t.CNO = 'a',
    t.ReturnNo = 'a',
    t.MainProd = 'b',
    t.Prod = 'c';
    I wonder now, what is the advantage of using MERGE in my case - if there is one.
    Finally I want to demonstrate how the whole thing would look without a MERGE:
    SELECT vers.* FROM TVERSCONTRACT vers
    LEFT OUTER JOIN myschema.T_CLAIMS_BB sch ON sch.SubCNo = vers.SubCNo
    LEFT OUTER JOIN commonschema.VC_REGVEREINB regv ON sch.SCH# = regv.SCH# AND SUBSTR(UPPER(sch.BUCHTEXT),1,2) = regv.SndReturnNo AND sch.SubCNo IS NULL
    LEFT OUTER JOIN myschema.T_CLAIMS_VT sch_vt ON sch.SCH# = sch_vt.SCH#

    Hi,
    metalray wrote:
    Hello Guys,
    I have a bit of trouble understanding the MERGE I have written here.
    All the code executes without errors. As far as I see,
    the below MERGE SELECT is a Cartesian product/cross join and I remember that is not
    good.Cross joins are good for some purposes. In practice, they're useful in only 1 or 2 queries out of every 1000.
    Using the old join notation, it was very easy to get a cross join by mistake. Given how rarely cross joins are needed, the vast majority of cross joins (using old notation) were not good, but that was the fault of the programmers and the notation, not an indication that cross join itself was bad.
    The ON (join condition) seems to be only for the merge into table (T_CLAIMS_BB) and
    the table that comes from the select (d).Exactly!
    You can have separate ON conditions inside the USING sub-query, if you need them.
    >
    merge into T_CLAIMS_BB t
    using
    SELECT sch_vt.SCH#,vert.CNO,vers.SubCNo,regv.ReturnNo,regv.SndReturnNo,sch_vt.MainProd,sch_vt.Prod
    FROM mainschema.TCONTRACT vert, mainschema.TVERSCONTRACT vers, commonschema.VC_REGVEREINB regv, myschema.T_CLAIMS_VT sch_vt
    ) d
    ON (
    t.sch# = d.sch# AND
    SUBSTR(UPPER(t.BOOKINGTEXT),1,2) = d.SndReturnNo AND d.SubCNo IS NULL
    ) -- Join
    when matched then
    update
    set t.CNO = 'a',
    t.ReturnNo = 'a',
    t.MainProd = 'b',
    t.Prod = 'c';
    I wonder now, what is the advantage of using MERGE in my case - if there is one.I don't see any advantage, but I suspect the statement, as written, is not doing what it's supposed to. If someone made the mistake of using MERGE when UPDATE would be better, that might be the least of the mistakes in this statement.
    Finally I want to demonstrate how the whole thing would look without a MERGE:It looks like the MERGE statement above is equivalent to:
    UPDATE     t_claims_bb
    SET     cno          = 'a'
    ,     returnno     = 'a'
    ,     mainprod     = 'b'
    ,     prod          = 'c'
    WHERE     UPPER (SUBSTR (bookingtext, 1, 2)) IN
              SELECT  returnno
              FROM     commonschema.vc_regvereinb
    AND     EXISTS
              SELECT  1
              FROM     mainschema.tverscontract
              WHERE     subcno     IS NULL
    AND     EXISTS
              SELECT     1
              FROM     mainschema.tcontract
    AND     EXISTS
              SELECT     1
              FROM     myschema.t_claims_vt
    ;Again, I suspect that the MERGE state,ment above is not doing what it was meant to do, or may coinncidentally be getting the right results on a small sample set. Many of the tables named in the USING clause of the MERGE statement do'nt seem to have much of a role in this problem.
    SELECT vers.* FROM TVERSCONTRACT vers
    LEFT OUTER JOIN myschema.T_CLAIMS_BB sch ON sch.SubCNo = vers.SubCNo
    LEFT OUTER JOIN commonschema.VC_REGVEREINB regv ON sch.SCH# = regv.SCH# AND SUBSTR(UPPER(sch.BUCHTEXT),1,2) = regv.SndReturnNo AND sch.SubCNo IS NULL
    LEFT OUTER JOIN myschema.T_CLAIMS_VT sch_vt ON sch.SCH# = sch_vt.SCH#What is this query? Perhaps you meant to have something like this in the USING clause of the MERGE.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    The sample data should show what the tables are like before the MERGE (or UPDATE), and the results will be the contents of the changed table after the MERGE.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.

  • Any idea why this MERGE INTO statment fails?

    I am using Oracle XE and trying to use a MERGE statment from an external table to a heap table.
    MERGE INTO
        ORDER_ITEM_INTELLI_LABS O
    USING
        ORDER_ITEM_INTELLI_LABS_STAGE S
        ON (O.ACC_NO = S."Acc No",
             O.DRAW_DATE = to_date(S."Draw Date",'MM/DD/RRRR'),       
            O.MED_REC_NO = S."Med Rec#",
            O.CODE_CPT = S."CPT",
            O.PROVIDER_ID = S."Provider ID",
            O.CLIENT_ID = S."Client ID")
      WHEN NOT MATCHED THEN
        INSERT
            (ORDER_ITEM_INTELLI_LABS_UID,
            DEPARTMENT_UID,
            DRAW_DATE,
            ACC_NO,
            MED_REC_NO,
            PATIENT_NAME,
            LAB_TEST_NAME,
            CODE_CPT,
            INS_CARRIER,
            PROVIDER_ID,
            CLIENT_ID,
            UPLOAD_DATE)
        VALUES
            (null,
            in_DEPARTMENT_UID,
            to_date(S."Draw Date",'MM/DD/RRRR'),
            S."Acc No",
            S."Med Rec#",
            S."Patient Name",
            S."Lab Test Name",
            S."CPT",
            S."Ins Carrier",
            S."Provider ID",
            S."Client ID",
            sysdate)
        where
            S."Draw Date" is NOT NULL;This is what I get:
      1  MERGE INTO
      2      ORDER_ITEM_INTELLI_LABS O
      3  USING
      4      ORDER_ITEM_INTELLI_LABS_STAGE S
      5      ON (O.ACC_NO = S."Acc No",
      6          O.DRAW_DATE = to_date(S."Draw Date",'MM/DD/RRRR'),
      7          O.MED_REC_NO = S."Med Rec#",
      8          O.CODE_CPT = S."CPT",
      9          O.PROVIDER_ID = S."Provider ID",
    10          O.CLIENT_ID = S."Client ID")
    11    WHEN NOT MATCHED THEN
    12      INSERT
    13          (ORDER_ITEM_INTELLI_LABS_UID,
    14          DEPARTMENT_UID,
    15          DRAW_DATE,
    16          ACC_NO,
    17          MED_REC_NO,
    18          PATIENT_NAME,
    19          LAB_TEST_NAME,
    20          CODE_CPT,
    21          INS_CARRIER,
    22          PROVIDER_ID,
    23          CLIENT_ID,
    24          UPLOAD_DATE)
    25      VALUES
    26          (null,
    27          in_DEPARTMENT_UID,
    28          to_date(S."Draw Date",'MM/DD/RRRR'),
    29          S."Acc No",
    30          S."Med Rec#",
    31          S."Patient Name",
    32          S."Lab Test Name",
    33          S."CPT",
    34          S."Ins Carrier",
    35          S."Provider ID",
    36          S."Client ID",
    37          sysdate)
    38      where
    39*         S."Draw Date" is NOT NULL
    SQL> /
        ON (O.ACC_NO = S."Acc No",
    ERROR at line 5:
    ORA-00907: missing right parenthesis
    SQL>

    This?
    MERGE INTO ORDER_ITEM_INTELLI_LABS O
      USING ORDER_ITEM_INTELLI_LABS_STAGE S
      ON (O.ACC_NO = S."Acc No"
          AND O.DRAW_DATE = TO_DATE (S."Draw Date", 'MM/DD/RRRR')
          AND O.MED_REC_NO = S."Med Rec#"
          AND O.CODE_CPT = S."CPT"
          AND O.PROVIDER_ID = S."Provider ID"
          AND O.CLIENT_ID = S."Client ID")
      WHEN NOT MATCHED THEN
        INSERT (ORDER_ITEM_INTELLI_LABS_UID, DEPARTMENT_UID, DRAW_DATE, ACC_NO, MED_REC_NO, PATIENT_NAME, LAB_TEST_NAME,
                CODE_CPT, INS_CARRIER, PROVIDER_ID, CLIENT_ID, UPLOAD_DATE)
        VALUES (NULL, in_DEPARTMENT_UID, TO_DATE (S."Draw Date", 'MM/DD/RRRR'), S."Acc No", S."Med Rec#", S."Patient Name",
                S."Lab Test Name", S."CPT", S."Ins Carrier", S."Provider ID", S."Client ID", SYSDATE)
          WHERE S."Draw Date" IS NOT NULL;

  • I have 2 icloud accounts. can they be merged into one?

    I have two iCloud accounts and want to delete one of them.  Can the two be merged into one?

    Welcome to the Apple Community.
    You can't merge accounts but there may be some things you can do, what exactly are you trying to achieve by merging accounts.

Maybe you are looking for