Oracle sql to outer join based on reg exp

Hi,
I am expecting output like (3). I want to join two tables with regex. join condition
. For example, in table1.string(abcYYMMDD.txt) I want to match date part (YYMMDD) wit any possible number in Table2.string (abc150420.txt)
Please suggest.
(1) table1:
abcYYMMDD.txt
ddefYYMMDD.txt
ghiYYMMDD.txt
(2) table2:
abc150420.txt
abc150421.txt
abc150422.txt
abc150320.txt
ddef150101.txt
ddef150404.txt
(3) Table1 left join Table2 (join example - abc(replace YYMMDD by regex).txt=abc150420.txt)
abcYYMMDD.txt,abc150420.txt
abcYYMMDD.txt,abc150421.txt
abcYYMMDD.txt,abc150422.txt
abcYYMMDD.txt,abc150320.txt
ddefYYMMDD.txt,ddef150101.txt
ddefYYMMDD.txt,ddef150404.txt
ghiYYMMDD.txt,

The audittime field is a timestamp field.
If I give the below query, rownum is not in the sequential order, see below few records..
SELECT rownum,to_char(audit_time_stamp,'dd-mon-yyyy HH24:MI:SS.FF') from audit_details ORDER BY audit_time_stamp
ROWNUM     to_char(audit_time_stamp,'dd-mon-yyyy HH24:MI:SS.FF')
16     18-apr-2007 14:30:52.551010
17     18-apr-2007 16:33:21.900305
18     18-apr-2007 17:49:44.061420
19     18-apr-2007 17:49:44.134804
20     19-apr-2007 16:40:15.775235
21     22-apr-2007 23:31:01.818784
ROWNUM     To_char(audit_time_stamp,'dd-mon-yyyy HH24:MI:SS.FF')
1     01-may-2007 19:17:46.880342
2     01-may-2007 19:24:04.952571
3     01-may-2007 19:24:32.182110
4     01-may-2007 19:25:49.464260
5     01-may-2007 19:25:52.127018
6     01-may-2007 19:27:34.099095
7     01-may-2007 19:30:34.763481
8     01-may-2007 19:31:06.226955
9     01-may-2007 19:32:36.727196
10     01-may-2007 19:40:44.061941

Similar Messages

  • Crystal Report with 2 oracle datasources (left outer join) very slow

    I've made a crystal report with 2 oracle datasources (2 commands). I'm using crystal 10.
    These 2 data sources are linked with a left outer join.
    The report takes a while to run (more then one hour).
    i can run Both query's in a couple of seconds/minutes, but it looks like crystal is runniing the second query for each record in the first query.
    When i make the same report in BO. Just 2 queries with merged dimensions in the report, it is taking a couple of minutes to complete the report.
    Question is if somebody knows how crystal is handling these 2 different data sources.
    Is there any way to say to crystal to fetch the data of both queries and do the join after that?
    At the moment it looks like that crystal is going to the other datasource for each record in the first query, which will cost a lot of time.

    Joris,
    I've always had a bad time combining a Command with any other object. Performance seems to drop dramatically, just as you've described.
    I can't tell you specifically why, it falls off so bad...
    The solution I've used is to do a linked  server query (at least that's what it's called in MS SQL Server) I've never used Oracle, but I'd be VERY surprised if it didn't have that same feature. This will keep 100% of the processing on the server(s) and will get your run times back to what you would expect.
    HTH,
    Jason

  • Oracle 8i Full Outer Join Syntax

    Can someone please help me run this on Oracle 8i:
    SELECT
    R.CUSTOMER_NUM,
    R.SURNAME_NM,
    R.FIRST_NM,
    R.STREET_NM,
    R.PROV_CD,
    R.CITY_NM,
    R.POSTL_CD,
    W.ADDR_TWO_DESC,
    C.RTL_CO_NUM,
    C.CARD_NUM
    FROM
    RTL_CUST R
    FULL OUTER JOIN WHLSL_CUST W ON (R.CUST_NUM = W.CUST_NUM)
    FULL OUTER JOIN CUSTOMER_CARD C ON (T.CUST_NUM = C.CUST_NUM)
    I only know the ANSI syntax. Whats the old one?

    Is this correct:
    SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, W.ADDR_TWO_DESC, NULL AS RTL_CO_NUM, NULL AS CARD_NUM
    FROM CCD_RTL_CUST R, CCD_WHLSL_CUST W WHERE R.CUST_NUM (+) = W.CUST_NUM
    UNION
    SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, W.ADDR_TWO_DESC, NULL AS RTL_CO_NUM, NULL AS CARD_NUM
    FROM CCD_RTL_CUST R, CCD_WHLSL_CUST W WHERE R.CUST_NUM = W.CUST_NUM (+)
    UNION
    SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, NULL AS ADDR_TWO_DESC, C.RTL_CO_NUM, C.CARD_NUM
    FROM CCD_RTL_CUST R, CUST_CARD C WHERE R.CUST_NUM (+) = C.CUST_NUM
    UNION
    SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, NULL AS , C.RTL_CO_NUM, C.CARD_NUM
    FROM CCD_RTL_CUST R, CUST_CARD C WHERE R.CUST_NUM = C.CUST_NUM (+);

  • Problematic sql with outer join

    There is one sql statement:
    INSERT INTO XXOM_SSC_TEMP_MMI_GTEMP (HEADER_ID, LAST_UPDATE_DATE) SELECT DISTINCT OOH.HEADER_ID, XSOH.LAST_UPDATE_DATE FROM OE_ORDER_HEADERS_ALL OOH INNER JOIN (SELECT TRANSACTION_TYPE_ID FROM OE_TRANSACTION_TYPES_TL OTT WHERE OTT.NAME NOT IN ('ORDER_RMA_MMI' ) AND OTT.LANGUAGE = 'US') OTT ON (OTT.TRANSACTION_TYPE_ID = OOH.ORDER_TYPE_ID) LEFT OUTER JOIN XXOM_3LP_SYM_ORA_ORDER_HDR XSOH ON (TO_CHAR (XSOH.ORDERTYPE) = SUBSTR ( OOH.ORIG_SYS_DOCUMENT_REF, 1, INSTR (OOH.ORIG_SYS_DOCUMENT_REF, '-', 1) - 1) AND TO_CHAR (XSOH.ORDERNBR) = SUBSTR ( OOH.ORIG_SYS_DOCUMENT_REF, INSTR (OOH.ORIG_SYS_DOCUMENT_REF, '-', 1) + 1) AND (XSOH.LAST_UPDATE_DATE >= :B1 )) INNER JOIN OE_ORDER_LINES_ALL OOL ON (OOH.HEADER_ID = OOL.HEADER_ID AND OOL.SHIP_FROM_ORG_ID = :B2 ) WHERE OOH.BOOKED_FLAG = 'Y' AND XSOH.ORG_ID = OOH.ORG_ID
    Porblematic query has insufficient and sub-optimal join conditions which makes it more expensive.One has recommended to remove one unnecessary outer join from the query and also fix the join to pick index.
    But how can we remove outer join and in place of that what should we write.

    Your code is unreadable, man! Surely your boss does not let you produce stuff like that? Format it. Because I'm a helpful person, I just put it through the formatter on http://www.dpriver.com/pp/sqlformat.htm :INSERT INTO xxom_ssc_temp_mmi_gtemp
                (header_id,
                 last_update_date)
    SELECT DISTINCT OOH.header_id,
                    XSOH.last_update_date
    FROM   oe_order_headers_all OOH
           inner join (SELECT transaction_type_id
                       FROM   oe_transaction_types_tl OTT
                       WHERE  OTT.name NOT IN ( 'ORDER_RMA_MMI' )
                              AND OTT.LANGUAGE = 'US') OTT
                   ON ( OTT.transaction_type_id = OOH.order_type_id )
           left outer join xxom_3lp_sym_ora_order_hdr XSOH
                        ON ( To_char (XSOH.ordertype) =
                             Substr (OOH.orig_sys_document_ref,
                             1,
                             Instr (OOH.orig_sys_document_ref,
                             '-', 1)
                             - 1)
                             AND To_char (XSOH.ordernbr) =
                                 Substr (OOH.orig_sys_document_ref,
                                 Instr (OOH.orig_sys_document_ref, '-', 1) + 1
                             AND ( XSOH.last_update_date >= :B1 ) )
           inner join oe_order_lines_all OOL
                   ON ( OOH.header_id = OOL.header_id
                        AND OOL.ship_from_org_id = :B2 )
    WHERE  OOH.booked_flag = 'Y'
           AND XSOH.org_id = OOH.org_id

  • SQL 92 Outer Join Syntax and Funtion.

    When i am trying to use {fn substring(..)} or {oj table} in sql query to make it database independent, oralce driver does not support this.
    Could any one explain the above issue?
    If so, How do i use it? Explain the syntax a bit.
    Thanks in Advance,
    Ramani.

    I should add that I have tried to change SQLServerPlatform to have shouldPrintOuterJoinInWhereClause() return "true". This embeds a "=*" in the join conditions in the WHERE clause.
    SQL Server 2000 still supports this syntax, but the "=*" isn't ALWAYS the correct operator. It is IMPORTANT to put the "*" on the correct side of the expression.
    TopLink always prints "=*", and it always puts it in the correct space, but the OPERATORS are not always in the correct order so you are creating a "left join" on the wrong table.
    So my other question, is it possible to FORCE TopLink to remember to put the outer join table in the RIGHT SIDE?
    Nate

  • Oracle - SQL - update sequential number based on order by clause

    I have a procedure that inserts records in to a temporary table. After procedure execution, I want to update a field in the temp table (recno) with sequential number ordered by a field audit date which is a time stamp field
    For example, after updating the recno field, if I give a query like below,
    Select recno,audit_timestamp,<other fields> from audit_details
    order by audit_timestamp
    the output should display recno in the sequential order. Can any one guide me on how to achieve this using a SQL query?

    The audittime field is a timestamp field.
    If I give the below query, rownum is not in the sequential order, see below few records..
    SELECT rownum,to_char(audit_time_stamp,'dd-mon-yyyy HH24:MI:SS.FF') from audit_details ORDER BY audit_time_stamp
    ROWNUM     to_char(audit_time_stamp,'dd-mon-yyyy HH24:MI:SS.FF')
    16     18-apr-2007 14:30:52.551010
    17     18-apr-2007 16:33:21.900305
    18     18-apr-2007 17:49:44.061420
    19     18-apr-2007 17:49:44.134804
    20     19-apr-2007 16:40:15.775235
    21     22-apr-2007 23:31:01.818784
    ROWNUM     To_char(audit_time_stamp,'dd-mon-yyyy HH24:MI:SS.FF')
    1     01-may-2007 19:17:46.880342
    2     01-may-2007 19:24:04.952571
    3     01-may-2007 19:24:32.182110
    4     01-may-2007 19:25:49.464260
    5     01-may-2007 19:25:52.127018
    6     01-may-2007 19:27:34.099095
    7     01-may-2007 19:30:34.763481
    8     01-may-2007 19:31:06.226955
    9     01-may-2007 19:32:36.727196
    10     01-may-2007 19:40:44.061941

  • Outer Joins Generated in SQL but not specified in Data Foundation

    Hi:
      I created a very simple universe on a MS Access database. there are four tables, joined by equi joins. Yet, when I select the objects (one from each table), the generated SQL has outer joins! This was not the case in XI 3.1 using Designer. Has anyone else run into this?
    I tried to create a similar scenario with SQL server and I got the same issue.
    Here is the generated SQL from the MS Access based query:
    SELECT
      Country.country,
      Region.region,
      City.city,
      Customer.first_name,
      Customer.last_name
    FROM
      Country,
      Region,
      City,
      Customer,
      { oj Country LEFT OUTER JOIN Region ON Country.country_id=Region.country_id },
      { oj Region LEFT OUTER JOIN City ON Region.region_id=City.region_id },
      { oj City LEFT OUTER JOIN Customer ON City.city_id=Customer.city_id }
    Notice all the outer joins -- they are not specified as outer joins in Data Foundation yet Webi Rich Client continues to generate the outer joins.
    Thanks!
    -Mike

    Hi,
    This sounds familiar.
    I think this may have been a bug recently solved in Patch2.10 for BI 4.0 SP02
    Whenever a user creates a join in the data foundation using drag & drop (and not editing the join using the UI), the flag for defining the outer join status is improperly set.
    This causes the SQL generation to create a left outer join when the UI displays that no outer join has been set.
    The workaround is to edit the join (double-click to show the join editor) and then do OK. In this case a inner join will be used in the SQL generation.
    This was confirmed fixed (in an internal discussion) in Patch2.10 . Does it sound familar ?
    Regards,
    H

  • Newbie: Trying to write PL/SQL that is dynamic based on data

    Hi everyone,
    I was wondering how I would go about writing a report that outer joins based on data from the main table? Here is what I wanna do in pseudo-sql:
    SELECT
         b.po_number,
    a.ht_code,
         b.figure_no,
         b.order_number,
         a.supplier_no,
    b.cert_date,
    b.plant
    FROM header b, part_spec a
    where ...
    begin:
    project = '' /* initialize project */
    /* The table to get the project value for the report is named ORDER01 or ORDER02 or ... */
    /* It is the word ORDER concatenated with the plant value above. */
    select project from 'ORDER' || :PLANT;
    END;
    How would I do this with APEX 2.0?
    I've successfully used APEX to generate SQL Query reports (REGION) but never PL/SQL.
    Your help is appreciated,
    FerrisWheel
    Edited by: FerrisWheel on Dec 15, 2009 10:13 AM
    Edited by: FerrisWheel on Dec 15, 2009 10:14 AM
    Edited by: FerrisWheel on Dec 15, 2009 10:14 AM

    OK, Thanks for the quick feedback. Here is a quick generic SQL I wrote up to show my goal using your suggestion. Notice the ERP_ORDERHDR and plant values in each of the SQLs below.
    SELECT b.cust_po_no,
    a.ht_code,
         b.item_no,
         b.ERP_ORDER_NO,
         a.supplier_code,
    b.cert_date,
    c.prj
    FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR011 c
    WHERE plant = 1
    AND a.cert_no = b.cert_no
    AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
    AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
    AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
    AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
    AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
    AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
    AND c.orno (+) = b.ERP_ORDER_NO
    AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
    UNION ALL
    SELECT      b.cust_po_no,
    a.ht_code,
         b.item_no,
         b.ERP_ORDER_NO,
         a.supplier_code,
    b.cert_date,
    c.prj
    FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR012 c
    WHERE plant = 2
    AND a.cert_no = b.cert_no
    AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
    AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
    AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
    AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
    AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
    AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
    AND c.orno (+) = b.ERP_ORDER_NO
    AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
    UNION ALL
    SELECT      b.cust_po_no,
    a.ht_code,
         b.item_no,
         b.ERP_ORDER_NO,
         a.supplier_code,
    b.cert_date,
    c.prj
    FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR014 c
    WHERE (plant = 4 or plant = 5 or plant = 8)
    AND a.cert_no = b.cert_no
    AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
    AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
    AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
    AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
    AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
    AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
    AND c.orno (+) = b.ERP_ORDER_NO
    AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
    and this would go on for up to 4 more unions. Is there a way to use PL/SQL to make it more clean? Another issue I have with the above is that the c.orno field that I try to outer join is not numeric whereas the b.ERP_ORDER_NO is numeric. I can to_char(c.orno) but how do I do that and still have an outer join? If I can use PL/SQL, I hope to be able to better control the output and eliminate the unions.
    I hope this is enough information.
    Thanks,
    FerrisWheel

  • Internal Assertion Error while using outer join

    Hi-
    Has anyone experienced this error before: State: HY000. Code: 397397248. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46036] Internal Assertion: Condition !pConjunct->IsAndCond(), file server/Query/Optimizer/Request/Src/SQORToCNF.cpp, line 46. (HY000)
    It happened after I changed the join in logical layer from inner join into left outer join from Fact Tab1 to Fact Tab2, This needs to be changed for cases:
    Fact Tab1 contains:
    Period|Currency|FX Rate
    Mar-09|USD|1
    Apr-09|USD|1.1
    Fact Tab2 contains:
    Period|Currency|Product|Profit
    Mar-09|USD|Metal Abs|1000
    Mar-09|USD|Grey Wood|2000
    Expected Result:
    Period|Currency|Product|Profit|FX Rate
    Mar-09|USD|Metal Abs|1000|1
    Mar-09|USD|Grey Wood|2000|1
    Apr-09|USD|(NULL)|(NULL)|1.1
    But, it shows the error as above (have changed the SERVER_THREAD_STACK_SIZE to 512 KB too but no luck, any idea?
    Thanks,
    Will

    Hey Will,
    Recently I've seen OBIEE generate some bad queries on an Oracle Database. I had setup a few time series measures and when I added more than three into a report, I got a table not found error. It turned out that it was a combination of the query getting very complex and the way it was using ANSI SQL Left Outer Join operator. I'm wondering if your situation is similar.
    Can you try the following?
    1. Log into the RPD and for your user, set the logging level to 7 (Manage->Security then find your user).
    2. Clear all the caches (BI Server=Manage->Cache delete them all, Presentation Server=Settings->Manage Sessions then close all cursors)
    3. Run the report for a date range that works fine
    4. Run the report for a date range that causes the error.
    5. Look at the physical SQL generated in the log files (Settings->Manage Sessions)
    Compare the two queries and see if anything stands out. In fact try to execute both in SQL Developer or Toad and see if you get any errors. If you can, post the physical SQL and I might be able to notice something.
    Just to confirm, you're using OCI to connect to an Oracle source right?
    In my situation, I fixed it by disabling the LEFT OUTER JOIN syntax on the database. We might be able to get you to do something similar to fix your problem.
    Thanks!
    -Joe

  • Datawindow graphical syntax outer join BUG

    Ok, so this is a bug report.  I don't know where i'm supposed to post it for SAP (i do have support).
    The outer join syntax is ansi.
    Using the graphical SQL designer, outer joins are incorrectly written by powerbuilder.  This has been going on ever since ANSI style outer join sytax was added (PB 9?).
    I think it has to do with the datawindow's use of both right and outer joins and its lack of use of inner joins.  The end result is that we have to rewrite a lot of stuff in sql since powerbuilder is generating bad sql.
    The typical example is the use of 2 or more outer joins where the joins are being done using 2 or more columns.
    PB will create both a LEFT and a RIGHT outer join by duplicating the table name.  The table (receive) is only selected ONCE in the sql graphical designer.
    And this is the result:
    Microsoft SQL Native Client
    The objects "receive" and "receive" in the FROM clause have the same exposed names. Use correlation names to distinguish them.
    Do you want to correct errors?
    I would love to see the datawindow sql corrected and written in a more standard way.
    1 change the OUTER JOIN syntax in the db profile setup to indicate the syntax.  not outer join, but syntax.  If you select ANSI have it write ALL joins using JOIN ( from ta join tb on ta.col = tb.col) intead of from tablea, tableb where tablea.col = tableb.col
    2 - eliminate the use of right outer joins.
    At that point i believe that the datawindow could more easily be fixed by SAP to not duplicate tables when in generates the syntax.

    If you have an Oracle Support agreement you can log a Service Request with Oracle, but they may respond that it is not really a bug. The problem is that the "outer" keyword in your 3rd example is being treated as an alias for TABLE_A because it is not considered a reserved keyword.
    with table_a as (
    select 1 as id, 'abc' as value_a from dual union all
    select 2 as id, 'def' as value_a from dual union all
    select 3 as id, 'ghi' as value_a from dual
    , table_b as (
    select 2 as id, 'jkl' as value_b from dual union all
    select 3 as id, 'mno' as value_b from dual union all
    select 4 as id, 'pqr' as value_b from dual
    select ID, outer.VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID);
    ID                     VALUE_A VALUE_B
    2                      def     jkl
    3                      ghi     mnoIf you query the V$RESERVED_WORDS view it will tell you which keywords are reserved.
    select * from V$RESERVED_WORDS where keyword in ('OUTER', 'SELECT','USING');
    KEYWORD                        LENGTH                 RESERVED RES_TYPE RES_ATTR RES_SEMI DUPLICATE
    USING                          5                      N        N        N        N        N
    OUTER                          5                      N        N        N        N        N
    SELECT                         6                      Y        N        N        N        NYou would get a similar result if you tried
    select ID, VALUE_A, VALUE_B from TABLE_A using join TABLE_B using (ID);Regards,
    Bob

  • Oracle.sql.BLOB.setBytes() Error

    Hi,
    I'm trying to use Java to put a large array of bytes into a BLOB table column. I'm first inserting the new row with an empty_blob() and then calling select <blob_column> ... for update and getting the oracle.sql.BLOB out of the resultset. I then try to call setBytes() on this BLOB and I get the following exception:
    java.sql.SQLException: Invalid argument(s) in call: putBytes()
    at oracle.jdbc.driver.T4CConnection.putBytes(T4CConnection.java:2440)
    at oracle.sql.BLOB.setBytes(BLOB.java:916)
    I'm using Oracle XE (oracle-xe-11.2.0-1.0.x86_64.rpm), the latest ojdbc6.jar, and jboss 4.2.2 on CentOS.
    A code snippet of what I'm doing:
    ... stmt = con.prepareStatement("select blob_column from blob_table where id=? for update"); stmt.setLong(1, Id); ResultSet rs = stmt.executeQuery(); try {     if (rs.next()) {         WrappedResultSet wrappedRs = (WrappedResultSet)rs;         BLOB oracleBlob = ((OracleResultSet)wrappedRs.getUnderlyingResultSet()).getBLOB(1);         if(oracleBlob != null) {             byte[] bytes = getData();             int pos = 0;             long bytesLeft = bytes.length;             log.debug("Attempting to write " + bytes.length + " bytes to BLOB");             while(bytesLeft > 0) {                 int bytesWritten = oracleBlob.setBytes(pos, bytes, pos, MAXBUFSIZE);                 log.debug("Wrote " + bytesWritten + " bytes to BLOB");                 bytesLeft -= bytesWritten;                 pos += bytesWritten;             }         }     } } finally {     rs.close(); } ...
    Any help would be greatly appreciated!

    Welcome to the forum!
    Thanks for posting the code and the DB, JDBC and app server versions. Those are what is needed to help.
    >
    java.sql.SQLException: Invalid argument(s) in call: putBytes()
                while(bytesLeft > 0) {
                    int bytesWritten = oracleBlob.setBytes(pos, bytes, pos, MAXBUFSIZE);
                    log.debug("Wrote " + bytesWritten + " bytes to BLOB");
                    bytesLeft -= bytesWritten;
                    pos += bytesWritten;That 'Invalid argument . . .' was your clue to look at the ARGUMENT values you are passing to the method call. You could have easily done that by displaying the values to the console each time in the loop BEFORE the method call.
    This is the signature of that method in the Javadocs (edited to highlight the relevant parts):
    http://docs.oracle.com/javase/6/docs/api/java/sql/Blob.html#setBytes(long, byte[])
    >
    int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
    Writing starts at position pos in the BLOB value; len bytes from the given byte array are written.
    Parameters:
    pos - the position in the BLOB object at which to start writing; the first position is 1
    bytes - the array of bytes to be written to this BLOB object
    offset - the offset into the array bytes at which to start reading the bytes to be set
    len - the number of bytes to be written to the BLOB value from the array of bytes bytes
    >
    This is what you are passing for 'len': MAXBUFSIZE
    Most likely that value is LARGER than the 'byte array' that you are using; perhaps it is even the MAX int size.
    That value is invalid.
    In addition each time thru the loop you increment 'pos' and use 'pos' as the 'offset' into your array. Then you once again use MAXBUFSIZE as the number of bytes to write from your array. Even if MAXBUFSIZE is less than the length of your array at some point it will likely be greater than what is left of the array.
    For example, if MAXBUFSIZE is 2 and your array length is 3 the first 'put' will put the first two bytes. Then the second put will use a 'pos' of 2 and try to put 2 more bytes; except there is only one byte left.
    Your code updates the entire BLOB value. Best practices are to use the stream methods for reading and writing BLOB/CLOB rather than the 'setBytes' method you are using. The main reason for this is performance: the stream methods write DIRECTLY to the database.
    >
    Notes:
    The stream write methods described in this section write directly to the database when you write to the output stream. You do not need to run an UPDATE to write the data. However, you need to call close or flush to ensure all changes are written. CLOBs and BLOBs are transaction controlled. After writing to either, you must commit the transaction for the changes to be permanent.
    >
    See 'Reading and Writing BLOB and CLOB Data' in the JDBC Dev Guide
    http://docs.oracle.com/cd/B19306_01/java.102/b14355/oralob.htm#i1058044
    >
    Example: Writing BLOB Data
    Use the setBinaryOutputStream method of an oracle.sql.BLOB object to write BLOB data.
    The following example reads a vector of data into a byte array, then uses the setBinaryOutputStream method to write an array of character data to a BLOB.
    java.io.OutputStream outstream;
    // read data into a byte array
    byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    // write the array of binary data to a BLOB
    outstream = ((BLOB)my_blob).setBinaryOutputStream(1L);
    outstream.write(data);

  • Sort-Merge outer join, why? when?

    Hi All,
    How Oracle runs/optimizes outer joins has always been my subject of curiocity.
    In Oracle documentation V 10.1 -> Performance tuning guide -> Chap. 14 ( The Query Optimizer) -> Go almost at the bottom
    There is a small section of "Sort Merge outer joins".
    It has a sentence
    "When an outer join cannot drive from the outer (preserved) table to the inner (optional) table, it cannot use a hash join or nested loop joins. Then it uses the sort merge outer join for performing the join operation"
    Can you help me understanding this ??
    Thanks in advance

    You actually need a sort-merge join sometimes: a join on inequality can't be run as a hash join, and may be very inefficient as a nested loop.
    e.g.
    select ...
    where  del.delivery_date between ord.order_date + 5 and ord.order_date + 8Unfortunately there are other cases where a sort merge join could be a very efficient join mechansim - because of suitable indexes - but the optimizer won't take it because there is a bug (from my perspective, at any rate) in the cost for sorting.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • Outer join query for SQL server from Oracle

    Hi All,
    My question is regarding making queries from Oracle to SQL Server database thorugh DBLink.
    In my oracle database I have a DBLink emp.world for SQL Server database.
    I need to query SQL Server data from oracle (so that this query can be combined with other oracle tables).
    Query is given below:
    SELECT
            a."EmpID" as "Employee ID",
            a."EmpStatus" "Employee Status"
            b."EmpSub" as "Employee Subjects"
    FROM
            [email protected] a
            left outer join [email protected] b on a."EmpID" = b."suEmpID"
    ORDER BY  a."EmpID";My problem is when I run the same query from oracle, it does not show the EmpID that does not exist in Subjects table, but when run from actual SQL Server database, it shows all the records.
    Samples are given below:
    Run from Oracle
    Employee ID      Employee Status     Employee Subjects
    101                     Active                     Maths
    102                     Active                     Maths
    102                     Active                     Physics
    104                   Inactive                  Chemistry
    Run form SQL Server
    Employee ID      Employee Status     Employee Subjects
    101                     Active                     Maths
    102                     Active                     Maths
    102                     Active                     Physics
    103                 Active                       NULL
    104             Inactive            ChemistryI am not sure why in oracle outer join for SQL server tables is not working. What is the right way for outer join in this case.
    I am using oracle database 10gR2 and SQL Server 2005.
    Please Help.
    Thanks.

    SELECT
    a."EmpID" as "Employee ID",
    a."EmpStatus" "Employee Status"
    b."EmpSub" as "Employee Subjects"
    FROM
    [email protected] a
    left outer join [email protected] b on a."EmpID" = b."suEmpID"
    ORDER BY a."EmpID";
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm#sthref3175
    From your description, it appears you may need a right outer join. You want to get back all the rows from 'B', not from 'A'. Try a right join and let us know.

  • Translating SQL from MYSQL to ORACLE with more than one outer join.

    I will translate the following sqlquery from MYSQL to ORACLE:
    SELECT ticket.ticket_no,ticket.ticket_dato,ticket.ticket_subject,ticket.customer_id,customer_name,ticket.ticket_own_read, ticket.department_id, department.department_name, priority_name, tickstat_name, tickettype_name
    FROM customer, ticket left join department
    on ticket.department_id = department.department_id left join priority on ticket.priority_id = priority.priority_id
    left join ticketstatus on ticket.tickstat_id = ticketstatus.tickstat_id
    left join tickettype on ticket.tickettype_id = tickettype.tickettype_id
    where ticket.customer_id = customer.customer_id and customer.owner_id =
    #session.owner_id#
    I have tried in ORACLE with:
    SELECT ticket.ticket_no,ticket.ticket_dato,ticket.ticket_subject,ticket.customer_id,customer_name,ticket.ticket_own_read, ticket.department_id, department.department_name, priority_name, tickstat_name, tickettype_name
    FROM customer, ticket ,department, priority, ticketstatus, tickettype
    where
    ticket.department_id(+) = department.department_id and
    ticket.priority_id(+) = priority.priority_id and
    ticket.tickstat_id(+) = ticketstatus.tickstat_id and
    ticket.tickettype_id(+) = tickettype.tickettype_id and
    ticket.customer_id = customer.customer_id and customer.owner_id = #session.owner_id#
    I get an error:
    MERANT][ODBC Oracle driver][Oracle]ORA-01417: a table may be outer joined to at most one other table
    How do I translate the code to ORACLE?

    I think that your syntax is wrong. The (+) operator should be on the right hand table column, not the left hand table column if you want all rows on the left hand table column. If this syntax is really what you want, you can create underlying views for each join condiction.

  • Oracle OUTER JOIN on more than one table

    Hi!
    Friends, please help with this urgent problem: How can an outer join be written on more than one table?
    An SQL Server query:
    SELECT * from a INNER JOIN b on a.id = b.id LEFT OUTER JOIN c ON c.id = a.id AND c.id = b.id
    works fine with SQL SERVER
    But Oracle query:
    SELECT * from a,b,c WHERE a.id = b.id AND a.id = c.id (+) AND b.id = c.id (+)
    gives an error: OUTER JOIN cannot be used on more than one table? Why?
    I use OracleDriver from classes12.zip to connect to Oracle8i database.
    Please, help!

    The Oracle 8i and later SQL reference reads that the following "join_types" are supported and under this syntax it does not limit the LEFT OUTER JOIN (syntax the same as SQLServer example in original note) to two tables as implied in these notes:
    The join_type indicates the kind of join being performed:
    Specify INNER to indicate explicitly that an inner join is being performed. This is the default.
    Specify RIGHT to indicate a right outer join.
    Specify LEFT to indicate a left outer join.
    Specify FULL to indicate a full or two-sided outer join. In addition to the inner join, rows from both tables that have not been returned in the result of the inner join will be preserved and extended with nulls.
    You can specify the optional OUTER keyword following RIGHT, LEFT, or FULL to explicitly clarify that an outer join is being performed.

Maybe you are looking for

  • Get bind variables of a dynamic view object

    I seem unable to retrieve the bind variables for a dynamically created view object, even though I can do the same thing for a regular view object. Here is the code: newVO = repServ.createViewObjectFromQueryStmt("newQry",strSql); VariableValueManager

  • Adobe Acrobat XI Pro: Limitation of Records in the Tracking Responses.pdf File

    Hello, When we create and distribute a PDF form, with the email or internal server option, is there a limitation about the file size and the number of records in the Tracking > Forms > Distributed > Title_responses.pdf file? Thanks.

  • Problem in displaying PDF report

    Environment : WEB AS : Oracle 9i As Dev : Oracle 9i Developer Suite Db : Oracle 9i DB when we call a report(pdf format) from form, It opens up the acrobat reader then,it gives the following error " There was an Error Processing a Page. There was a pr

  • How to change the loglevel of error log in DS

    Hi, I have a simple question regarding setting the log level of Sun directory server. I have created following ldif file to change the log level to 256 while the default was 0: dn: cn=config changetype: modify replace: nsslapd-errorlog-level nsslapd-

  • Parsing in Java

    Hey Guys, I have a requirement where i need to read and validate a fixed length text file having 90,000 records(lines). I need to parse each record and do some validations. Currently i am reading line by line using regular java.io.FILE/java.io.FileIn