Query to translate one string column by referring to another 2 table

I have 3 table which is
1)RATIO_HISTORY
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ RATIO_ID + RATIO_CRITERIA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 + (subjek=2 AND gred<=240) OR (subjek=3 AND gred<=240) OR (subjek=4 AND gred<=567) OR (subjek=5 AND gred<=565)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 + (subjek=4 AND gred<=567) OR (subjek=5 AND gred<=565)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2)LKP_SUBJEK
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SUBJEK_ID SUBJEK
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 + English
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 3 + Chemical
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 4 + Biology
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 5 + Physic
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 6 + History
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 7 + Mathematics
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3) LKP_GRED
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GRED_ID    GRED
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 240 + 1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 567 + 2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 565 + 3
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 568 + D
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
what i want to do is, i want to create a query than can translate the column of Criteria in table ratio_history to look like this;
example: ratio_id=1
(subjek=English AND gred<=1) OR (subjek=Chemical AND gred<=1) OR (subjek=Biology AND gred<=2) OR (subjek=Physics AND gred<=3)
Can anyone help me?
thank you in advance.
Edited by: user5441678 on Mar 17, 2011 7:12 PM

Hi,
Welcome to the forum!
Whenever you have a question, please post your sample data in a form that people can use to re-create the problem and to test their solutions.
For example:
CREATE TABLE     ratio_history
AS
SELECT      1      AS ratio_id
,     '(subjek=2 AND gred<=240) OR (subjek=3 AND gred<=240) OR (subjek=4 AND gred<=567) OR (subjek=5 AND gred<=565)'
          AS ratio_criteria
FROM     dual     UNION ALL
SELECT     2, '(subjek=4 AND gred<=567) OR (subjek=5 AND gred<=565)'     from dual;
CREATE TABLE     lkp_subjek
AS
SELECT     2 AS subjek_id,     'English' AS subjek     FROM dual     UNION ALL
SELECT      3,          'Chemical'          FROM dual     UNION ALL
SELECT     4,          'Biology'          FROM dual     UNION ALL
SELECT     5,          'Physic'          FROM dual     UNION ALL
SELECT     6,          'History'          FROM dual     UNION ALL
SELECT     7,          'Mathematics'          FROM dual;
CREATE TABLE     lkp_gred
AS
SELECT     240 AS gred_id,     '1' AS gred     FROM dual     UNION ALL
SELECT     567,          '2'          FROM dual     UNION ALL
SELECT     565,          '3'          FROM dual     UNION ALL
SELECT     568,          'D'          FROM dual;Be sure to mention which version of Oracle you're using. The solution below works in Oracle 10 and up. (I tested it in Oracle 10.2.0.1.0, but it should work in Oracle 10.1 as well.
Regular expressions make it easy to split ratio_criteria up into parts. I assume that every row will have from 1 to 6 pairs of numbers (subjek_id and a gred_id), so we can have up to 7 "items" on each row, counting the text that comes after the last number. That's what the "magic number" 7 is in sub-query cntr. Of course, you can increase that if your real data has more numbers.
WITH     cntr     AS
     SELECT     LEVEL     AS n
     FROM     dual
     CONNECT BY     LEVEL <= 7     -- Or whatever you need
,     ratio_items     AS
     SELECT     r.ratio_id
     ,     c.n                                        AS item_num
     ,     REGEXP_SUBSTR ( ratio_criteria, '[^0-9]+', 1, (2 * c.n) - 1)     AS subjek_txt
     ,     REGEXP_SUBSTR ( ratio_criteria, '[0-9]+',  1, (2 * c.n) - 1)     AS subjek_id
     ,     REGEXP_SUBSTR ( ratio_criteria, '[^0-9]+', 1, (2 * c.n)        )     AS gred_txt
     ,     REGEXP_SUBSTR ( ratio_criteria, '[0-9]+',  1, (2 * c.n)        )     AS gred_id
     FROM          ratio_history     r
     CROSS JOIN     cntr          c
,     translated_items     AS
     SELECT     i.ratio_id
     ,     i.item_num
     ,     i.subjek_txt
          || s.subjek
          || i.gred_txt
          || g.gred          AS txt
     FROM          ratio_items     i
     LEFT OUTER JOIN     lkp_subjek     s  ON  s.subjek_id = TO_NUMBER (i.subjek_id)
     LEFT OUTER JOIN     lkp_gred     g  ON  g.gred_id   = TO_NUMBER (i.gred_id)
SELECT       ratio_id
,       REPLACE ( SYS_CONNECT_BY_PATH (txt, '~?')
            ,                      '~?'
            )     AS translated_history
FROM       translated_items
WHERE       CONNECT_BY_ISLEAF     = 1
START WITH     item_num     = 1
CONNECT BY     item_num     = PRIOR item_num + 1
     AND     ratio_id     = PRIOR ratio_id
ORDER BY  ratio_id
,       item_num
;Sub-query ratio_items splits each row into 7 parts, each potentially containing some text that comes before the subjek_id, the subjek_id, some text that comes before the grep_id, and the grep_id.
Sub-query translated_items looks up the translations of the ids in the appropriate tables. Outer-joins are used, because the last item will not have any ids, but we still need to preserve its text. This means that if ratio_criteria has an incorrect id, the query will still run; just the incorrect part will be missing.
The main query re-unites the translated items, in order, using SYS_CONNECT_BY_PATH, which requires a delimiter between items. The delimiter must never appear in the strings to be combined. I assumed that the string '~?' will never occur in your real data. You can change that to any string, of any length, if you want. (The individual characters in the delimiter may appear in the text, so it's okay to have ~'s and ?'s, you just can't have a ~ followed immediately by a ?.) We don't actually want a delimiter in this problem, so REPLACE gets rid of it.
Output:
  RATIO_ID TRANSLATED_HISTORY
         1 (subjek=English AND gred<=1) OR (subjek=Chemical AND gred<=1
           ) OR (subjek=Biology AND gred<=2) OR (subjek=Physic AND gred
           <=3)
         2 (subjek=Biology AND gred<=2) OR (subjek=Physic AND gred<=3)Interesting problem!

Similar Messages

  • Need to concatonate multiple values for same key columns into one string

    Hi...I'm attempting to use PL/SQL to read through a table containing more than one column value for a set of keys, and concatonate those values together into one string. For example, in the STUDENT table, for a STUDENT_ID there are multiple MAJORS_ACCOMPLISHED such as History, Biology and Mathematics. Each of the majors is stored in a different row with the same STUDENT_ID due to different faculty DEPARTMENT values.
    I want to read through the table and write out a single row for the STUDENT_ID and
    concatonate the values for MAJORS_ACCOMPLISHED. The next row should be another STUDENT_ID and the MAJORS ACCOMPLISHED for that student..etc.
    I've hit a wall trying to use cursors and WHILE loops to get the results I want. I'm hoping someone may have run across this before and have a suggestion. Tks!!

    I think you are looking for string aggregation.
    The following are the replies posted by me in the forum recently on the same case.
    they might help you.
    Re: Concatenating multiple rows in a table - Very urgent - pls help
    Re: Doubt in a query ( Urgent )
    Re: How to remove words which consist of max 2 letters?
    Re: output like Name1,Name2,Name3...

  • Rest query with filter sub-string (contains, not eq)

    Hi,
    how can I do a REST-query with a filter for a string-column which is only a sub-string? I only found EQ, for example $filter=(name EQ 'tom') which compares the whole string.
    But I would like to query records, where a string-column CONTAINS a specific sub-string.
    Thx, Tom

    Hi Tom,
    Do you use it on azure Data Market place? Did you try to add "*" on your query string, like this
    post.
    Also, you could try this tool from this
    thread. Also, for this issue, I suggest you could post it on
    SQL forum for better support.
    If I misunderstood, please let me know.
    Regards,
    Will
    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.

  • Report on BEx query with 2 structures (one in rows and one in columns)

    Hi, experts! I have to make Crystall report on BEx query with 2 structures, one in columns (with KF's), and one in rows. Is it possible to create such report? Because when I create such report, I cant see fields in structures, only characteristics fields.
    Ok, I found samr problem in another thread. Sorry.
    Edited by: Mikhail Sychev on Dec 5, 2009 9:53 PM

    Hey Flora,
    Happy to hear that its working now.
    Answering your question, again its upto the connection and report format you are using. Based on your question i hope you your report output should be like this.
    You cannot map to two labels for the series, again this report format is possible only in cross tab through Webi. I would suggest you to concatenate the material and month in a dimension in webi like below.
    I have done the concatenation in excel level, i would suggest you to do that in webi. Try to reduce the formula as much in excel.
    or
    If you are using Query browser connection, then i would suggest you to create a separate report which will display the actual vs plan material wise, here you need to pass the material as a prompt.
    Hope this helps in clear, please revert me for any clarification.

  • Concatenate multiple columns into one string

    Hello,
    I am using Oracle 11.2, how can I concatenate the value of multiple columns into one string with one SQL:
    create table testTb(classId number(5), classRoom varchar2(32));
    insert into testTb value(101, 'room101');
    insert into testTb value(101, 'room201');
    insert into testTb value(101, 'room301');
    insert into testTb value(202, 'room444');
    insert into testTb value(202, 'room555');
    I would like to generate the result as followings:
    Class 101 is in room101, room201, room301
    Class 202 is in room444, room555
    Thanks,

    Hi,
    Since you're using Oracle 11.2, you can use the aggregate LISTAGG function:
    SELECT       'Class ' || classid
                   || ' is in '
                 || LISTAGG ( classroom
                         ) WITHIN GROUP (ORDER BY classroom)
                   AS txt
    FROM       testtb
    GROUP BY  classid
    ;The generic name for concatenating all the strings in a group is String Aggregation . This page shows several ways to do it, suitable for different versions of Oracle.

  • Sql query for finding a string in a column of a table

    Hi All,
    I have an issue, I have gotten a string ie '1D USD PRIME' and I have access to oracle's dictionary tables and views such as (all_source, all_tab_cols etc), my requirement is to find which table' column holds my above mentioned string, so I mean both the table name and the column name, it could be that this string might exist in more than 1 table so I want all the tables that holds it.
    Regards
    Rahul

    Hi All,
    I think you misunderstood my question, so may be I didnt ask it properly, so here it is I am explaining in detail with an example.
    Suppose I have 10 users with 10 different user name's in a database and I am the 11th user as DBA, every 10 of these users have created some tables lets say 20 tables each by every user making a count of the total tables as 200, now lets say 10 of 200 tables has a column ie fname with value as 'rahul', I want to search the string 'rahul' from all the 200 tables that which of the tables contains this string along with the column name.
    I hope this time my question is clear, the point is I just know of a value and I dont know the table name and column name where it may actually residing, futher I want to search tables of other users as well.
    Regards
    Rahul

  • How to Read the one Source Column data and Display the Results

    Hi All,
         I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
    Ex:
    Pr_ProjectType
    AD,AM
    AD
    AM
    AD,AM,TS,CS.OT,TS
    AD,AM          
    like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
    4.AD,AM,TS,CS.OT,TS in this string we need AD,AM  only.
    this logic we need we have thousand of data in the table.Please help this is urgent issue
    vasu

    Hi Vasu,
    Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
    are two approaches for your reference:
    Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
    for the custom function is as follows:
    CREATE FUNCTION dbo.udf_GetNumeric
    (@strAlphaNumeric VARCHAR(256))
    RETURNS VARCHAR(256)
    AS
    BEGIN
    DECLARE @intAlpha INT
    SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
    BEGIN
    WHILE @intAlpha > 0
    BEGIN
    SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
    SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
    END
    END
    RETURN ISNULL(@strAlphaNumeric,0)
    END
    GO
    The SQL commands used in the OLE DB Source is like:
    SELECT
    ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
    FROM MyTable
    Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
    characters to the corresponding substring. The script is as follows:
    using System.Text.RegularExpressions;
    Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
    References:
    http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/ 
    http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html 
    Regards,
    Mike Yin
    TechNet Community Support

  • Text nodes are colapsed to one string

    Hi,
    I am new to Oracle XML.
    i need to parse a xmltype table coulmn and load data to a diffrent table.
    XSD sample
    <xsd:element name="BrowserPluginList">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="BrowserPlugin" type="xsd:string" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    Query:
    select
    xmltype.extract(xdoc,'/xData//BrowserPluginList/BrowserPlugin').getStringVal()
    from xmltab;
    Results:
    <BrowserPlugin>MS ActiveX PlugIn1</BrowserPlugin><BrowserPlugin>MS ActiveX PlugIn2</BrowserPlugin><BrowserPlugin>MS ActiveX PlugIn3</BrowserPlugin>
    (output is one string with line breaks)
    Query
    select
    xmltype.extract(xdoc,'/xData//BrowserPluginList/BrowserPlugin/text()').getStringVal()
    from xmltab;
    Results :
    MS ActiveX PlugIn1MS ActiveX PlugIn2MS ActiveX PlugIn3
    (output is all the text nodes are collapsed to one string)
    Desired results(Two Columns: 1.sequence#, 2.BrowserPlugin
    Seq#, Browserplugin
    1,      MS ActiveX PlugIn1
    2,     MS ActiveX PlugIn2
    3,      MS ActiveX PlugIn3
    please help ..
    Thanks
    Reddy

    Please ignore the message.. i was able to produce the desired results using the xmlsequence.
    this forum is very helpful..
    keep the good work Geoff Lee.
    thanks

  • Translation for dynamic columns

    Hello,
    I am new to BIP and I am researching if it's possible to support translation for the a column splitting(crosstab) report that the column heading is not known until the runtime? Fortunately, I can seed the translation for these column headings in a TL table but I just would not know which columns will be displayed and the sequence of these display columns until the runtime.
    Thanks,
    Calvin

    Thank you very much for the reply but I am still a little unclear how to implement your suggested approaches.
    1) pass the correct translations to the report as part of the data set
    I intend to design 3 tables. Table 1 is the main one and Table 2 and 3 store the column headings and translation.
    Table 1: REPORT_ROWS(REPORT_NAME, ROWNUM, VALUE1, VALUE2, VALUE3...VALUE10).
    - REPORT_NAME + ROWNUM: PK columns
    - VALUE1-10: Depending on REPORT_NAME, different columns will be populated.
    Table 2: REPORT_FORMAT(REPORT_NAME, LABLE1, LABEL2,....LABEL10)
    Table 3: REPORT_FORMAT_TL(REPORT_NAME, LANGUAGE, LABEL1, LABEL2,....,LABEL10)
    I can get translations from Table3. But how do I get the labels displayed as column headings in the BIP?
    Isn't the column headings in BIP defaulted the table column name of Table 1?
    Should I change the design of these tables?
    2) and 3) how to do I pick the right translation at the runtime in the dataset or in the table?
    My understanding is the xliff file is based on strings on the report template. In this case, these strings are derived at the runtime.
    Therefore, the xliff file approach is not applicable. Is this a right assumption?
    Many thanks!
    Calvin

  • Hello i need a help about script to export translatable text strings from ai files and import them back

    Hello i need a help about script to export translatable text strings from ai files and import them back after editing, thanks in advance

    Lanny -
    Thank you for taking the time to help with this problem. Can I just say however that as someone who has posted a first comment here and quite clearly never used a forum like this before, your comment unfortunately comes across as very excluding. It makes me feel there are a set of unwritten rules that I should know, and that I don't know them shows that the forum is not for me. In short, it's exactly the kind of response that stops people like me using forums like this.
    I'm sure it's not intended to be received like this and I am sure that the way you have responded is quite normal in the rules of a forum like this. However, it is not normal for those of us who aren't familiar with forums and who only encounter them when they have a genuine problem. This is why I hope it is helpful to respond in full.
    The reason I posted here is as follows. I was directed here by the apple support website. The original comment seemed to be the only one I could find which referred to my issue. As there is no obvious guidance on how to post on a forum like this it seemed perfectly reasonable to try and join in a conversation which might solve more than one problem at once.
    Bee's reply however is both helpful and warm. This could in fact be a template for how new members should be welcomed and inducted into the rules of the forum in a friendly and inclusive way. Thank you very much indeed Bee!

  • How to create a variance on data that exists iIn only one database column

    How to create a variance on data that exists iIn only one database column?
    I'm trying to create a calculation to show the difference between the budgets for two different years in a Discoverer crosstab query.
    I'm using the lag function to repeat the value of a column for the current year and the year before.

    Lag and lead seems to be the only choice and they work excellent. Checkout the new 10g Database features. There is new SQL modal clause which might give additional and powerful analytics but in this case lag and lead should be sufficient.
    regards
    http://www.infocaptor.com/workbook-dump.php

  • How to add one date column and charecter column

    hi all,
    i have 3 column start_date(date),end_date( date),duration (varchar2)
    i am trying to add start_time and duration like this
    end_date := to_char(start_time) + duration;
    but its showing value_error
    how to add one date column and charecter column.
    Thanks

    you need something that does:
    end_date (DATE) := start_date (DATE) + <number of
    days> (NUMBER)Not necessarily, because if the duration is just a string representation of a number then it will be implicitly converted to a number and not cause an error
    e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('01/07/2007','DD/MM/YYYY') as start_dt, '3' as duration_days from dual)
      2  -- END OF TEST DATA
      3  select start_dt + duration_days
      4* from t
    SQL> /
    START_DT+
    04-JUL-07

  • How can i delete One Blank Column in my report

    Hi guru's,
    can any one tell me .........
    i'm getting one Blank column in Query output.How can i delete that Blank Column ?
    in the same way Row  Also....
    Thanking  u advancely
    Chandra

    Here is a site with some nice sample code on deleting rows / columns : [http://www.java2s.com/Code/JavaScript/HTML/ModifyingTableColumns.htm|http://www.java2s.com/Code/JavaScript/HTML/ModifyingTableColumns.htm]
    As to where to put the code, edit your web template, then put the code in there. There are script web items that you can use, but be aware that editing javascript in the script item is not too pleasant. I have found the best approach is to rather create the javascript file on my machine, then upload it to the MIME repository, then reference that in the web template.
    Here is how I have referenced the javascript file sitting in our MIME repository:
    < script src="bwmimerep:///sap/bw/mime/Customer/javascript/CustomCalculations.js" />
    I hope this helps you out.
    Cheers,
    Andrew
    Edited by: Andrew Lewis on Jul 18, 2008 9:26 AM

  • Slow delete on a table with one CLOB column

    Hi,
    I have a table which has one CLOB column and even if I delete one row from it, it takes approx. 16 seconds. Since UNDO isn't generated for CLOBs (at least not in the UNDO tablespace), I can't figure out why this is so? The CLOB has defined a RETENTION clause, so it depends upon UNDO_RETENTION which is set to 900. There wasn't any lock from another session present on this table.
    The table currently contains only 6 rows but it used to be bigger in the past, so I thought that maybe a full table scan is going on when deleting. But even if I limit the DELETE statement with an ROWID (to avoid a FTS), it doesn't help:
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SQL> select count(*) from scott.packet;
      COUNT(*)
             6
    SQL> column segment_name format a30
    SQL> select segment_name
      2    from dba_lobs
      3  where owner = 'SCOTT'
      4     and table_name = 'PACKET';
    SEGMENT_NAME
    SYS_LOB0000081487C00002$$
    SQL>  select segment_name, bytes/1024/1024 MB
      2    from dba_segments
      3  where owner = 'SCOTT'
      4      and segment_name in ('PACKET', 'SYS_LOB0000081487C00002$$');
    SEGMENT_NAME                           MB
    PACKET                               ,4375
    SYS_LOB0000081487C00002$$             576
    SQL> -- packet_xml is the CLOB column
    SQL> select sum(dbms_lob.getlength (packet_xml))/1024/1024 MB from scott.packet;
            MB
    19,8279037
    SQL> column rowid new_value rid
    SQL> select rowid from scott.packet where rownum=1;
    ROWID
    AAAT5PAAEAAEEDHAAN
    SQL> set timing on
    SQL> delete from scott.packet where rowid = '&rid';
    old   1: delete from scott.packet where rowid = '&rid'
    new   1: delete from scott.packet where rowid = 'AAAT5PAAEAAEEDHAAN'
    1 row deleted.
    Elapsed: 00:00:15.64From another session I monitored v$session.event for the session performing the DELETE and the reported wait event was 'db file scattered read'.
    Someone asked Jonathan Lewis a similar looking question (under comment #5) here: http://jonathanlewis.wordpress.com/2007/05/11/lob-sizing/ but unfortunately I couldn't find if he wrote any answer/note about that.
    So if anyone has any suggestion, I'll appreciate it very much.
    Regards,
    Jure

    After reviewing the tkprof as suggested by user503699, I noticed that the DELETE itself is instantaneous. The problem is another statement:
    select /*+ all_rows */ count(1)
    from
    "SCOTT"."MESSAGES" where "PACKET_ID" = :1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          2           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      1.40      16.93     125012     125128          0           1
    total        3      1.40      16.93     125012     125128          2           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=125128 pr=125012 pw=125012 time=0 us)
          0   TABLE ACCESS FULL MESSAGES (cr=125128 pr=125012 pw=125012 time=0 us cost=32900 size=23056 card=5764)I checked if there was any "ON DELETE" trigger and since there wasn't, I suspected this might be a problem of unindexed foreign keys. As soon as I created an index on SCOTT.MESSAGES.PACKET_ID the DELETE executed immediately. The "funny" thing is that, the table SCOTT.MESSAGES is empty, but it has allocated 984MB of extents (since it wasn't truncated), so a time consuming full tablescan was occurring on it.
    Thanks for pointing me to the 10046 trace which solved the problem.
    Regards,
    Jure

  • Updating one varray  column in a table

    Hi ,
    We are using 10gR2 on AIX . I have one varray column in a table which has be updated ..To update this column , data is fetched in a query by using 2 tables.Is there any way to reduce the update time?
    Edited by: Minu on 25-Apr-2011 20:24

    HOW TO: Post a SQL statement tuning request - template posting

Maybe you are looking for

  • Netweaver Java Enterprise Portal System Copy issue

    Dear friends, We are trying to export Production portal online without down time and install Target system using import method. Import process is successfull and we tried doing element.resync=true for force bootstrap from the database. We are able to

  • TS3276 Yahoo! sent mail not updated in the server.

    I have an issue with Yahoo! Mail. When I'd sent email from my Mail from my mac book air, it can be sent but a copy is not updated in the server, thus when I view from the web or other device I can't see it as it is not updated. I've checked the "stor

  • Payment Scheme amount adjustment on periodic review

    Hi Experts, Can you please explain me adjustment of extrapolated amount and bill amount, while periodc review. or any document which explain me that, i have debug the program but found nothing. Example : In periodic review invoice generated for 300 a

  • Changing the default logical system names for adaptive RFC models

    Hello, When I create an Adaptive RFC model the dialog that asks me to specify the model name, package, source folder, etc. has default values in the "Default logical system name for model instances" and "... RFC metadata". I know I can type in anothe

  • How to setup and load hierarchies in BW?

    Dear BW gurus, We have vendor hierarchy in ECC table LFMH.In BW when i try to load this hierarchy for 0VENDOR using 0VENDOR_LKLS_HIER datasource, i do not see the hierarchy that i need from the ECC (in the "available hierarchies in OLTP" option in th