Strange behavior with DBMS_METADATA while Retriving Table DDL

Hi again, I works the DBMS_METADATA package to retrieve the table DDL to a given schema. The problem I encounter is that I am only able to get a type of table DDL at a time and I'd like to be able to recover all types of tables. When I say type table I'm talking about traditional, ITO and partitioned, although I don't know that it applies to other types of.

My system is running 11.2.0.3 on Redhat 6 x 64 with all current patches.

Here's my setup. I created two tables for each type.

create table table_normal1(
    column1 varchar2(30 char),
    column2 varchar2(30 char)    
    );
    
create table table_normal2(
    column1 varchar2(30 char),
    column2 varchar2(30 char)    
    );    

create table table_index_organized1(
    column1 varchar2(30 char),
    column2 varchar2(30 char),
    constraint pk_table_index_organized1 primary key (column1)
    )
    organization index;

create table table_index_organized2(
    column1 varchar2(30 char),
    column2 varchar2(30 char),
    constraint pk_table_index_organized2 primary key (column1)
    )
    organization index;    

create table table_partioned1(
    column1 varchar2(30 char),
    column2 varchar2(30 char)
    )
    partition by list(column1)(
        partition p1 values ('P1'),
        partition p2 values ('P2'),
        partition p3 values ('P3')
        );
        
create table table_partioned2(
    column1 varchar2(30 char),
    column2 varchar2(30 char)
    )
    partition by list(column1)(
        partition p1 values ('P1'),
        partition p2 values ('P2'),
        partition p3 values ('P3')
        );

And here is the anonymous block, that I am running.

declare
    v_ddl_list sys.ku$_ddls;
    v_handle number;
    v_transform_handle number;
begin
    v_handle := dbms_metadata.open(
        object_type => 'TABLE'
        );
    dbms_metadata.set_filter(
        handle => v_handle,
        name => 'SCHEMA',
        value => USER
        );
    v_transform_handle := dbms_metadata.add_transform (
        handle => v_handle,
        name => 'DDL'
        );
    dbms_metadata.set_transform_param(
        transform_handle => v_transform_handle,
        name => 'SQLTERMINATOR',
        value => true
        );
    dbms_metadata.set_transform_param(
        transform_handle => v_transform_handle,
        name => 'PRETTY',
        value => true
        );
    dbms_metadata.set_transform_param(
        transform_handle => v_transform_handle,
        name => 'SEGMENT_ATTRIBUTES',
        value => false
        );
    dbms_metadata.set_transform_param(
        transform_handle => v_transform_handle,
        name => 'REF_CONSTRAINTS',
        value => false
        );
    dbms_metadata.set_transform_param(
        transform_handle => v_transform_handle,
        name => 'CONSTRAINTS_AS_ALTER',
        value => true
        );
    dbms_metadata.set_count(
        handle => v_handle,
        value => 1000
        );    
    v_ddl_list := dbms_metadata.fetch_ddl(
        handle => v_handle
        );  
    open :p_output for select * from table(v_ddl_list) order by to_char(substr(ddltext,1,100));                
end;
/

If I add a Filter Expression by name, I am able to find the other tables very well but I can't get the DDL for several types.

dbms_metadata.set_filter(
    handle => v_handle,
    name => 'NAME_EXPR',
    value => 'IN (''TABLE_NORMAL1'',''TABLE_NORMAL2'')'
    );

Is this a bug or just a limitation without papers? I looked at the documentation several times and I can't find anything that mentioned this problem.

Thank you

I just wanted to know for all I knew it was. You have call dbms_metadata.fetch_ddl repeatedly until it returns a null value. On our production systems, this returns the DDL for tables of 200 or more in 10 seconds. I missed this little note when I was reading the documentation in the "http://docs.oracle.com/cd/E11882_01/server.112/e22490/metadata_api.htm#SUTIL1626".

Thank you

Tags: Database

Similar Questions

  • strange behavior with script times

    Hi all

    I have strange behavior with one of my scripts, and I can't understand where is the problem.

    Before you post the code, here's the principle.

    My form has two fields of time: "Time of Injection" and "Post injection time.

    The script runs when the output of "injection time" event and look if the injection time is before time "post injection.

    Here is my code:

    //get the value of the field "Injection time"
    var injection = this.formattedValue;
    
    //create an new Date object
    var injectionTime = new Date();
    
    //split the string to get the HH MM and SS values of the formattedValue (HH:MM:SS)
    var injectionTimeHoursString = injection.substr(0,2);
    var injectionTimeMinutesString = injection.substr(3,2);
    var injectionTimeSecondsString = injection.substr(6,2);
    
    //parse the strings into integer
    var injectionTimeHoursInt = parseInt(injectionTimeHoursString);
    var injectionTimeMinutesInt = parseInt(injectionTimeMinutesString);
    var injectionTimeSecondsInt = parseInt(injectionTimeSecondsString);
    
    //set the integer values into my Date object
    injectionTime.setHours(injectionTimeHoursInt, injectionTimeMinutesInt, injectionTimeSecondsInt,0);
    
    
    //do the same for the other time field "Post injection time"
    var post = post_injection.post_time.formattedValue;
    var postTime = new Date();
    var postTimeHoursString = post.substr(0,2);
    var postTimeMinutesString = post.substr(3,2);
    var postTimeSecondsString = post.substr(6,2);
    var postTimeHoursInt = parseInt(postTimeHoursString);
    var postTimeMinutesInt = parseInt(postTimeMinutesString);
    var postTimeSecondsInt = parseInt(postTimeSecondsString);
    postTime.setHours(postTimeHoursInt, postTimeMinutesInt, postTimeSecondsInt,0);
    
    
    //calculate the difference between both
    var diff = postTime.getTime() - injectionTime.getTime();
    
    //if the difference gives a negative result, display a message, empty the fields and set focus
    if(diff<0) {
         xfa.host.messageBox("The time of injection should be sooner than the time of post-injection activity measure.\n\nPlease re-enter correct times.","Incompatibility of times");
         this.rawValue = "";
         post_injection.post_time.rawValue = "";
         xfa.host.setFocus(post_injection.post_time);
    }
    

    The code seems to run pretty well... except with certain values.

    If postTime is 12:00

    and injetion is 12:04

    I get the error message and everything, so it's OK

    BUT

    When postTime is 12:00

    and injectionTime is 12:08

    No message! as if the difference was not negative! (the difference is zero...)

    When I display the time in a messagebox, 12:04 12:04:00 GMT blah blah... gives but 12:08 gives 12:00:00 GMT etc...

    same problem with 12:09, but not 12:10 for example...

    Any thoughts?

    Thank you.

    Thank you, but since I'm used to javascript, I'll stick to it.

    I understand the problem. It's a javascript with the ParseInt method bug!

    Check here: http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256C85006A6604

    parseInt("08") = 0.

    How to lose 2 hours for a stupid bug...

  • Strange behavior with postGlobalEvent and eventOccurred()...

    Hello world

    I have a browser plugin for my application that will do two things:

    Firstly, when the BlackBerry browser is forwarded to a Web page with a particular MIME type, the browser plugin will say my application to go to the foreground. It works without any problem.

    Secondly, the browser plugin will display a global event at my request. My request, making use of eventOccurred(), will look for this event and the EC type-approval, it will execute an authorize() method that I have. This also works. However, I notice some strange behavior:

    The first time my application launches the BlackBerry browser and goes to the page specified (with a custom MIME type), everything works fine. If I had while my application to launch the browser and do it AGAIN, my authorize() method is running TWICE. If I open the browser of my application for the third time, so my authorize() method is started THREE times. See the model?

    .. .This is all this without leaving my application. If I had to leave and then start my application again, the 'sequence' prior would begin again. Thus, it seems that whenever x times that I repeat this process, the eventOccurred() method will receive x events.

    Here are a few snippets:

    public class Events {
        final public static int EVENT_AUTHORIZE = 1;
        final public static int EVENT_OTHER = 2;
    }
    
    manager.postGlobalEvent(pid, 0xCAFEBABE, 1, 0, null, null);
    
    public void eventOccurred(long guid, int event_type, int arg2, Object arg3,
                Object arg4) {
            if (guid == 0xCAFEBABE) {
                switch (event_type) {
                case Events.EVENT_AUTHORIZE:
                    authorize();
                    System.out.println("EVENT EXECUTION");
                    break;
                case Events.EVENT_OTHER:
                    break;
                }
            }
    
        }
    

    Can we see what is happening here? I've been "racking my brain" on this one for a while now...

    Thank you!

    "Thus, this can work any time the class is instantiated." The class is instantiated just before I open my browser".

    Application.getApplication().addGlobalEventListener(this);
    

    If you call the above (by instantiating your class) every time that you open the browser, applications to register this event listener again and again.

    If you're going to do it this way, make sure removeGlobalListener you when your application is done processing.

    "Can I make addGlobalListener when my application starts even if this class does not implement GlobalEventListener?"

    You can always have your UiApplication implement GlobalEventListener or just instantiate a new object that implements it in the constructor of your UiApplication.

  • Strange behavior with V$ PDB and CDB_SEGMENTS views of Oracle 12 c

    Hello

    I am trying to run a query between the CDB_SEGMENTS and the views V$ PDB on the container ROOT, but I have a strange behavior:

    SQL*Plus: Release 12.1.0.1.0 Production on Fri Sep 6 12:33:25 2013
    
    Copyright (c) 1982, 2013, Oracle. All rights reserved.
    
    
    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
    
    SYS@orcl12c 06.09.2013> show con_id
    
    CON_ID
    ------------------------------
    1
    SYS@orcl12c 06.09.2013> show con_name
    
    CON_NAME
    ------------------------------
    CDB$ROOT
    SYS@orcl12c 06.09.2013> SELECT B.NAME
     2 , A.CON_ID
     3 , A.TABLESPACE_NAME
     4 FROM CDB_SEGMENTS A
     5 INNER JOIN V$PDBS B
     6 ON B.CON_ID=A.CON_ID;
    
    no rows selected
    
    SYS@orcl12c 06.09.2013 12:34:17> SELECT B.NAME
     2 , A.CON_ID
     3 , A.TABLESPACE_NAME
     4 FROM CDB_TABLESPACES A
     5 INNER JOIN V$PDBS B
     6 ON B.CON_ID=A.CON_ID;
    
    NAME CON_ID TABLESPACE_NAME
    ------------------------------ ---------- ------------------------------
    PDB$SEED 2 SYSTEM
    PDB$SEED 2 SYSAUX
    PDB$SEED 2 TEMP
    PDBORCL 3 SYSTEM
    PDBORCL 3 SYSAUX
    PDBORCL 3 TEMP
    PDBORCL 3 USERS
    PDBORCL 3 EXAMPLE
    ...
    
    23 rows selected.
    
    SYS@orcl12c 06.09.2013> SELECT *
     2 FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('asa03y45g99zb'));
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    SQL_ID asa03y45g99zb, child number 0
    -------------------------------------
    SELECT B.NAME , A.CON_ID , A.TABLESPACE_NAME FROM
    CDB_SEGMENTS A INNER JOIN V$PDBS B ON B.CON_ID=A.CON_ID
    
    Plan hash value: 3590150304
    
    -------------------------------------------------------------------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
    -------------------------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | | | 1 (100)| | | | | |
    | 1 | NESTED LOOPS | | 333 | 14985 | 0 (0)| | | | | |
    |* 2 | FIXED TABLE FULL | X$CON | 2 | 30 | 0 (0)| | | | | |
    | 3 | PX COORDINATOR | | | | | | | | | |
    | 4 | PX SEND QC (RANDOM) | :TQ10000 | 167 | 5010 | 0 (0)| | | Q1,00 | P->S | QC (RAND) |
    | 5 | PX PARTITION LIST AND | | 167 | 5010 | 0 (0)|KEY(AP)|KEY(AP)| Q1,00 | PCWC | |
    |* 6 | FIXED TABLE FIXED INDEX| X$CDBVW$e7cdf8a6 (ind:11) | 167 | 5010 | 0 (0)| | | Q1,00 | PCWP | |
    -------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
     2 - filter(("CON_ID">1 AND "INST_ID"=USERENV('INSTANCE')))
     6 - filter("CON_ID"="CON_ID")
    
    
    25 rows selected.
    
    SYS@orcl12c 06.09.2013> select con_id,count(*) from cdb_segments group by con_id;
    
     CON_ID COUNT(*)
    ---------- ----------
     1 5795
     4 4397
     3 3923
     2 3401
    
    4 rows selected.
    

    Basically, I would like to display the container_name of segments within all PDB files, but the join between CDB_SEGMENTS and views of V$ PDB does not work (lines 20-25) pending the join between CDB_TABLESPACES and V$ PDB works very well (lines 29-34). I've posted the execution plan (lines 50-82).

    You have ideas about this behavior?

    Thank you in advance,

    Arnaud.

    Hello

    Not 100% sure that this is a bug or just something about the way containers works now - however this select seems to work OK:

    SELECT B.NAME, A.CON_ID, A.TABLESPACE_NAME

    OF CDB_SEGMENTS, V$ PDB B

    where to_char (B.CON_ID) = to_char (A.CON_ID)

    See if it works for you too?

    See you soon,.

    Harry

  • Strange behavior with the function «Help in command line»

    So I do a little playing with the opening of the files compiled help (.chm) with the command-line help feature, and I saw a strange behavior when trying to index multi-level access keywords. According to the documentation, if you set the 'Key' operation, you can enter a value for ' string to search for "to access this section. The more precise help that:

    If this string contains a keyword index, the string must match the key of the index as it appears in the help index file. To access a topic with a multilevel index keyword, enter the keyword of the top-level index, a colon and the keyword of the second level index. Do not separate the elements with spaces. For example, a chain of error codes: GPIB jumps about a subject with a keyword of top-level index of error codes and a second level keyword index of GPIB.

    All right, seems simple enough. Except that when I tried, I couldn't work, even with the example provided. I tried the following simple test:

    Opens the help file, but it opens to this page, not to the page ' error codes: GPIB "non-descript. I saw this in 8.2 and 8.6. Anyone have any success with access to a multi-level keyword?

    Note - side

    Curiously, the Index for the help lvconcepts.chm file looks like this:

    In other words, the input index text is just "GPIB", but the text that appears in the keyword field is "codes error, GPIB. I'm curious to know how this was accomplished. I decompiled the lvconcepts.chm file and watched the .hhk file, and it is not immediately obvious to me. (By the way, if you try to use "error codes, GPIB" it does not either).

    Hello

    Please contact National Instruments!
    It is a very strange behavior.  I tested out and seen the exact
    same results you are experiencing.  This was reported to R & D (AUTO ID # 130246) for further investigations.
    From what I can tell the a possible workaround solution that we have documented
    in the post of root Canal.  I can't continue to look into this in order
    to see if there is no other workaround solution or a reason why it is
    run in this way.  Thanks much for the feedback!  If
    you have any other questions on this subject please post them here.
    Have a great day!

  • Strange behavior with mkdir ASMCMD

    First there is option no. - p with the mkdir command, as in Linux. To create multiple directories/subdirectories so I tried the following.

    asmcmd > mkdir arch/racdb1 + arch/racdb2 + racdb1/arch/archivelog + arch/racdb2/archivelog

    1. This creates the first three folders. But gives error on the last.

    Inline image 1

    Someone said do not use + sign. So tried this,

    2. tried still nothing does not.

    Inline image 1

    Once again creates first 3 folder but not the fourth. On the other hand, if I just try to create 3 directories/subdirectories in any order it works. Of course I have it in two separate commands, but I wondered why this strange behavior.

    But it worked for me in 11.2.0.3:

    ASMCMD > mkdir + DATA / has DATA + DATA/C / A / B + DATA/C/D

    ASMCMD > cd DATA

    ASMCMD > ls

    A /

    C /.

    ORCL.

    ORCL_P /.

    PEPSI.

    SERVICETEST.

    TEST /.

    vmrac-cluster.

    ASMCMD > cd A

    ASMCMD > ls

    B /

    ASMCMD > cd...

    ASMCMD > cd C

    ASMCMD > ls

    D /.

  • Strange behavior with the PSD in Photoshop

    I am currently working with a two-page ID CS5.5 document. This is a CMYK document with CMYK images and grayscale.

    Strange behavior is the following: I have a gray levels (tiff) image that is repeated on the page 1 and page 2. This image looks completely different from page 1 to page 2. I have triple checked everything (opactiy, effects, etc.) and then I started to remove items from page 2 one by one.

    As I deleted a psd file all of a sudden all the images in grayscale on page 2 changed his appearance to match page 1. The PSD in question is also in CMYK with a transparent background. What the frack happens?

    I'm more concerned to know if it makes a difference when it goes to print, or if it's just weird screen in InDesign.

    Anyone who has heard of this or know why this happens - would like to hear from you.

    Thank you!

    I think it's simply because of full transparency on the page. Should not affect the production of gray images... but check in Acrobat.

    Mike

  • Strange behavior with the paths of the image

    All, morning

    I have a strange behavior going on with my image paths and I was wondering if someone might be able to identify what they think happens?

    On the relative paths of my model (.. / Images/example.jpg) work very well.

    However, on the pages of the child the same relative paths do not display images and so I had to remove the '... /' to get to work (ending up with Images/example.jpg).

    This is obviously not desirable that I'm going to manually tweak the child pages where the content of the combo box was copied directly from the model that works very well.

    Any ideas what might be up?

    Thanks in advance

    You have not yet entered the main directive of models, which is that only changes to the unchangeable in the model regions will be applied to the child pages.  If this were not true, then we could never put unique content on a child page!

    So - the diagram is as follows:

    1 create a template and save it.

    2. the model of a page child spawn.  The child page will be a 'identical' model copy.

    3. Add a unique content to the page of the child.  The child page is now more a copy of 'identical' of the model.

    4 change something in the part NOT MODIFIABLE from the model and save it - all child pages receive the change.

    5 change something in the EDITABLE model part and save it - no child pages do not receive the change.

    6 spawn a NEW page of the model, and it's still a copy of 'identical' AGAIN CHANGED model.

    See how it works?

  • strange behavior with access Internet and e-mail through D6300 AC1600

    NOTE: When creating this post 'Model' box doesn't let me choose my modem model, it was not an option so I picked one at random! My current modem is the AC1600.

    I hope someone can help with this problem.

    Modem works fine, Internet access is very good.

    My my email on new servers migrated hosting service yesterday now I have strange problems with access to electronic mail.

    I can access e-mail very well on my phone via 4G.

    Unable to access from any device on my network, e-mail, webmail or outlook or messaging.

    If my phone is on the network, it cannot access email either.

    I can ping the e-mail servers and my domain OK from any device

    DNS resolves the addresses OK

    As several devices on the network have difficulty then it is network and/or router associated

    I think a factory reset on the modem as a last resort.

    It's only a problem for e-mail server migration.

    Outlook is saying: the connection to the server has been lost

    Outlook cannot configure the IMAP account automatically.

    When I try manually it says that the server does not support the encryption type (the one provided by the service of the host).

    My companion said that it works OK on hisnetwork.

    Ahhhh, would you believe? After a factory reset of the router and troublehshooting hours I managed to contact my hosting service (I usually go through the dealer) and they said that my IP address has been blocked due to many failed attempts to connect to my CPanel! I had encountered a problem with the password CPanel and who had put on the side so I fixed the problem of e-mail! Heck, who would have guessed that they were related?

    Thanks for your help!

  • Strange behavior with Scan function

    Hi, I see some weird behaviors with the scan function.  Here's a code (for Interactive execution) window which illustrates what I'm struggling with:

    #include 
    static double value;//    1234567890123456static char buffer[20] = "-  24.612 g    ?";
    static int scanneditems;
    static unsigned char sign, stable;
    static char unit[6];
    
    scanneditems = Scan(buffer, "%s>%c[u]%f%c[d]%s[w5y]%c[u]", &sign, &value, unit, &stable);
    

    The buffer I'm scanning has five parts.  The first character is a sign, the next 8 characters is a floating point number, then there is a space that just throw, then five characters is a string that describes the unit, and the last character is a question mark if the reading is unstable or a space otherwise.  The problem is with the last character.  When I run the above code, the value of the variable 'stable' is 32 (space), when I expect a 63 (question mark).  The other points seem to parse correctly, including the double value and the 'unit' char array that contains [g] [space] [space] [space] [space], which is exactly what I expect that it contains.

    It seems I'm missing something obvious, probably something to do with the way that the scan function manages the spaces, but I just can't understand what it is.  Thank you.

    I'm not sure about how Scan treats spaces, but if you check NumFmtdBytes () after the scan you see 12, which means that it has scanned only the 'g' (fill the rest of 'unit' with spaces according to the modifier there) and read the character immediately following the stability.

    This line correctly reads the entire string and returns bytes 16 analyses by the function, which is what is expected.

    scanneditems = Scan (buffer, "%s > %c [u] %f %c [d] %s [-w5t] [u] %c", & sign, & value, unit, & stable);

  • Strange behavior with videos...

    I have put 4 different videos in one page.

    Video01, Video02, etc.

    Each video has a personalized poster.

    But when a click Video04 the viewer of the iPad and Desktop Viewer plays Video03 or Video02

    Any advice?

    Fixed a problem.

    The film inside the frame was great as the frame causing this strange behavior.

    After use, "Fill the frame proportionally" everyting works perfectly.

    Thank you

  • Strange behavior with Report Generation Toolkit. Table does not table.

    We use a Word 2003 (.doc) document as a template for a summary of the report.  It works fine on the development PC.  It fills the fields in the document and fills the chart correctly, as shown in the picture below.

    However, he cannot even on another station.  Although the 2D table is identical and so is the software to investigate the matter, the table does not get filled correctly.  I studied using Word 2010 (.docx) as a model, with the same results.

    I was not able to understand what is different between stations 2 and why it does not work on the 2nd station.  I googled similar questions on the Web site of NOR and was only this article in the knowledge base concerning the new lines in the cell, which is not my case.

    That's what I have on the 2nd machine:

    The table that is sent to the table contains the appropriate data :

    I just found out this is a known bug, which obviously has not yet been resolved (finally... at least until LV2012SP1).

    See these threads:

    http://forums.NI.com/T5/LabVIEW/problem-with-append-table-and-Word-2010/TD-p/1268246

    and

    http://forums.NI.com/T5/LabVIEW/report-generation-MS-Word-table-bug/m-p/1605170

    I'll try the workarounds suggested and report back...

  • Strange behavior of the WHILE loop

    Dear experts LabVIEW

    I would ask you to give me an explanation of the behavior of the very simple VI as an attachment. This VI contains a WHILE loop with three parameters, input and STEP. The table of RESULTS shows the calculated values. Considering the input parameters OF = 0 TO = 1 LEVEL = 0.1, then the RESULTS table contains the values 0, 0.1, 0.2,..., 0.9, 1. Considering the input settings ON = 1, TO = 2, STEP = 0.1, then RESULT table contains values 1, 1.1, 1.2,..., 1.8, 1.9. The question is, why the number 2 is missing?  (I also tried to use different types of data, but without success). Thanks for your thoughts.

    Juraj

    Because you compare floating point numbers.

    For example, 0.1 cannot be represented in exactly in binary, cela repetitive additions probably will not end in an exact integer later.

    Since the three entries, you can calculate the number of values exactly and use a loop FOR. Do not use the convoluted code...

    Why not just use ramp model?

  • Strange behavior with CURRENT_TIMESTAMP

    Hello

    I tried to run the query that got the difference between two timestamps using CURRENT_TIMESTAMP and I seem to return inconsistent results.

    Running Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit

    I'm basically taking 1 second (1/24/60/60) of the current timestamp, and I don't think that it turns a value that is always a second. However, it is always more than one second, the difference is always different. Even if 1/24/60/60 is not a second, results should always be consistent from one request to the next right? This behavior is not strange?

    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> with a as (select CURRENT_TIMESTAMP cts from dual)
      2  select TO_CHAR(a.cts-(a.cts-(1/24/60/60)),'YYYY-MM-DD HH24:MI:SS.FF') difference
      3  from a
      4  ;
    
    DIFFERENCE
    ---------------------------
    +000000000 00:00:01.334196
    
    
    SQL> with a as (select CURRENT_TIMESTAMP cts from dual)
      2  select TO_CHAR(a.cts-(a.cts-(1/24/60/60)),'YYYY-MM-DD HH24:MI:SS.FF') difference
      3  from a
      4  ;
    
    DIFFERENCE
    ---------------------------
    +000000000 00:00:01.180302
    
    
    SQL>
    
    
    

    Thank you

    Dave

    Hello

    (a.cts-(1/24/60/60)

    an example of DATE is arithmetic; the result is the DATE is 1 second before a.cts.  As the result of arithmetic DATE is a DATE, there no fraction of a second.

    If you want the time STAMP that is exactly 1 second before to a.cts, then use an INTERVAL, like this:

    a.CTS - '1' SECOND INTERVAL

  • DENSE_RANK - strange behavior with an instruction BOX in ORDER BY

    Select the version of v$ instance;

    10.2.0.5.0

    Here is my example query:

    WITH A AS (
    select 40 as id,'708' as loc,'10-108' as act,14.5 as per from dual
    union select 40,'708','10-308',14.5 from dual
    union select 40,'708','10-708',14.5 from dual
    union select 40,'708','10-108',10.5 from dual
    union select 40,'708','10-308',10.5 from dual
    union select 40,'708','10-708',10.5 from dual
    )
    select id,loc,act,per
    ,SUBSTR(act,4,3) as aloc
    ,CASE WHEN SUBSTR(act,4,3) = loc THEN 0 ELSE 1 END as "Case"
    ,row_number() over (partition by id,loc order by per desc,
        CASE WHEN SUBSTR(act,4,3) = loc THEN 0 ELSE 1 END) AS Row_Num
    ,dense_rank() over (partition by id,loc order by per desc
        ,CASE WHEN SUBSTR(act,4,3) = loc THEN 0 ELSE 1 END
      ) as D_Rank
    from A;
    

    Here are the results, I expect:

    ID ACT BY ALOC case no_lig D_RANK LOC

    ---------- --- ------ ---------- ---- ---------- ---------- ----------

    40 708 14.5 10-708 708 0 1 1

    40 708 14.5 10-108 108 1 2 1

    40 708 14.5 10-308 308 1 3 1

    40 708 10.5 10-708 708 0 4 2

    40 708 10.5 10-108 108 1 5 2

    40 708 10.5 10-308 308 1 6 2

    However, these are the results I get:

    ID ACT BY ALOC case no_lig D_RANK LOC

    ---------- --- ------ ---------- ---- ---------- ---------- ----------

    40 708 14.5 10-708 708 0 1 1

    40 708 14.5 10-108 108 1 2 2

    40 708 14.5 10-308 308 1 3 2

    40 708 10.5 10-708 708 0 4 3

    40 708 10.5 10-108 108 1 5 4

    40 708 10.5 10-308 308 1 6 4       

    Since CASE WHEN SUBSTR(act,4,3) = 0 1 loc OTHER END is not in the score, why DENSE_RANK() increments?  ROW_NUMBER() behaves correctly with this CASE statement in its ORDER BY, but DENSE_RANK() does not appear.


    I think I can solve my problem by removing BOX WHEN SUBSTR (act, 4, 3) = THEN ELSE 0 1 END of my COMMAND DENSE_RANK() loc, however, in academic terms, I still don't understand the above behavior.  Is this a bug in DENSE_RANK or is it normal?

    Hello

    You're right; the expression that you called "Case" is not in clasue SCORE.  If it were, then a change in the value of 'Case' would cause DENSE_RANK generate a new set of numbers, starting with 1.  Tha't, it is clearly not what is happening here.  In this query, a change in the 'deal' is originally results increment, not start with 1.

    Don't forget the ORDER BY operation

    ORDER BY w, x, y, z

    the distinction between the lines to which none of the expressions w, x, y or z is different.  A change in one of these expressions (in general) causes a change in the results.

    In this example, 'Deal' is part of the analytical ORDER byclause DENSE_RANK, so you should expect a change in the "box" to cause a change in the value returned by DENSE_RANK.

    In this query, DENSE_RANK assigns different numbers with lines that have different values of 'box '.  Lower values of 'Case' will be assigned lower values of D_Rank, which is what you see.

    Lines with a = 14.5 and "Breaks" = 0 get a lower D_Rank (they get D-rank = 1) than the lines with per = 14.5 and "Break" = 1 (they get D_Rank = 2).

    Lines with by = 10.5 and "Breaks" = 0 get a lower D_Rank (they get D-rank = 3) of lines with by = 10.5 and "Case" = 1 (they get D_Rank = 4).

    You're right about how to get the first set of results, too.  If ORDER BY DESC is the ORDER byclause analytical together, DENSE_RANK assign the same number for all rows in the partition that have the same value of per, no matter what values are in all the other columns.

    The fact that "The case" is a CASE expression is actually irrelevant.  If you had a column, with 0 and 1 used and stored in this column in the ORDER BY clause, you would see the same behavior.

Maybe you are looking for

  • Need recovery product for Satellite M30-106 cd

    Misplaced my product recovery CD. Where can I get one from?

  • Deactivation of the system 5341473

    Can anyone please help me I need the administrator password of my computer hp laptop Windows 8 disable the code system that appears is 53414173

  • Windows Server 2012 lost connectivity

    Hi all I created 6 virtual servers Windows Server 2012 R2 Standard. However, there are 2 weeks 3 to 6 servers randomly lost connectivity (ping returned request) outdated, unable to control remotely,... several times until I have restart servers, conn

  • replace the comma with point to a string

    Hello I tried to replace the comma in the chain attached to a point, but I can't make it work. What I am doing wrong? Calle cordially

  • Update SP1 of XP to SP3 - language problems?

    I have an old IBM stationairy pc with XP SP1 and I want to upgrade to SP3. I try to install SP1a, SP2, and SP3, but each ONE of them comes up with the same error message: "The installation program nannot yout update Windows XP files because the langu