Oracle query to generate date and calculate fees

Hi, please help me to create a query to get the end result of both tables as below

 CREATE TABLE detention_charge_slot
   (slot_no NUMBER(5),
  from_days NUMBER(10),
  to_days NUMBER(10),
  charge_amount NUMBER(10,2));

 INSERT INTO detention_charge_slot  VALUES (1,1,4,0);
 INSERT INTO detention_charge_slot  VALUES (2,5,9,10);
 INSERT INTO detention_charge_slot  VALUES (3,10,14,20);
 INSERT INTO detention_charge_slot  VALUES (4,15,999,25);

   CREATE TABLE detention_invoice
   (invoice_no NUMBER(10),
  invoice_dt DATE,
  delivery_dt DATE);

   INSERT INTO detention_invoice VALUES(1,'10-JAN-2015','25-JAN-2015');

Where expected result 1 = Invoice_no:

Start_date End_date Days Charge_Amount
JANUARY 10, 2015JANUARY 13, 201540
JANUARY 14, 201518 JANUARY 2015510
19 JANUARY 2015JANUARY 23, 2015520
JANUARY 24, 201525 JANUARY 2015225

If you expect more than one line in DETENTION_INVOICE, use the following query

WITH DATES

AS

(SELECT DI. INVOICE_DT + FROM_DAYS - 1 START_DATE,

LEAST (DI. INVOICE_DT + TO_DAYS - 1, DELIVERY_DT) END_DATE.

CHARGE_AMOUNT

OF DCS, DETENTION_INVOICE DI DETENTION_CHARGE_SLOT

where di.invoice_no = 1)

SELECT start_date, end_date - + 1 days START_DATE, end_date, charge_amount

OF DATES

Tags: Database

Similar Questions

  • Migration - MySQL to Oracle - do not generate data files

    Hello

    I have been using the SQL Developer migration Assistant to move data from a MySQL 5 database to an Oracle 11 g server.
    I used it successfully a couple of times and its has all worked.

    However, I am currently having a problem whereby there is no offline data file generated. Control files and all other scripts generated don't... just no data file.
    It worked before, so I'm a bit puzzled as to why no logner work.

    I looked at newspapers of migration information and there is no errors shown - datamove is marked as success.
    I tried deleting and recreating rhe repository migration and checked all grants and privs.

    Is there an error message then it would be something to continue but have tried several times and checked everything I can think.

    I also tried the approach of migration command-line... same thing. Everything works fine... no errors... but only the table creation and control script files are generated.
    The schema of the source is very simple and there is only the tables to migrate... no procedure or anything else.

    Can anyone suggest anything?

    Thank you very much
    Mike

    Hi Mike,.

    I'm so clear.
    You use SQL Developer 3.0?
    You walked through the migration wizard and choose Move Offline mode data.
    The generation of DDL files are created as are the scripts to move data.
    But no data (DAT) file is created and no data has been entered in the Oracle target tables.

    With offline data move, Developer SQL generates (saved in your project, under the DataMove dir directory) 2 sets of scripts.
    (a) a set of scripts to unload data from MySQL to DAT files.
    (b) a set of scripts to load data from the DAT files in the Oracle target tables.
    These scripts must be run by hand, specifying the details for the source databases MySQL and Oracle target.

    "no offline data file generated. Control files and all other scripts generated don't... just no data file. »
    «.. . but only the creation and control file table scripts are generated. »

    What you mean
    (1) the DAT files are not generated automatically. This should, if we need to run the scripts yourself
    (2) after manually running the scripts that the DAT are not present, or that the DAT files are present, but the data does not load in Oracle tables.
    (3) the scripts to move data in offline mode does not get generated

    Kind regards
    Dermot
    SQL development team.

  • SQL query to generate nested XML data

    Hello
    I use Oracle 11 g R2 SOE...

    I have two main tables

    COMMERCIALS_PROPERTIES (PK, com_id, com_size, project number, com_type number number number)
    COM_PHOTOS (PK ID number, number com_id FK, content mimetype varchar2, blob)

    Please, note that the following has nothing to do with my problem:
    CONTENT and mimetype columns. In addition, the tables of research: PROJECTS, COM_TYPE

    Apex (Application Express) we can expose a report as a RESTful web service in XML format:

    I use this query to generate the XML 1 feed, but I need to change the query to generate flow XML 2 .

    How is this possible?
     Select
          
    "COM"."COM_ID" as "COM_ID",
    "COM"."COM_SIZE" as "SIZE",
    "PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
    "COM_TYPES"."COM_TYPE" as "COM_TYPE",
    
    'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
    
     FROM 
    COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
    on   IMG.COM_ID = COM.COM_ID
    inner join "PROJECTS" "PROJECTS" 
    on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
    inner join "COM_TYPE_LOOKUP" "COM_TYPES" 
    on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
         
     WHERE
      COM.COM_ID < 80 order by 1
    H1. XML 1
    H2. Please look only < COM_ID > and < ImgURL >
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
    </ROW>
    
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </ROW>
    
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
    </ROW>
    
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </ROW>
    
    </ROWSET>
    ---------------------------
    H1. XML 2
    H2. Please look only < COM_ID > and < Images > and < ImgURL >
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </Images>
    </ROW>
    
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </Images>
    </ROW>
    </ROWSET>
    
     

    Hi, Fateh

    One possible way is to use the XML features to create your XML file.
    Using XML, you can make the IMAGES as a subquery XMLAGG rather than join at the table of the image.

    Here is an example of the use of schema SCOTT:

    SQL> select xmlelement(
      2            "ROWSET"
      3          , xmlagg(
      4               xmlelement(
      5                  "ROW"
      6                , xmlforest(
      7                     d.deptno as "ID"
      8                   , d.dname as "NAME"
      9                   , (
     10                        select xmlagg(
     11                                  xmlelement(
     12                                     "ImgUrl"
     13                                   , 'http://the.server.com/'||e.empno
     14                                  )
     15                                  order by e.empno
     16                               )
     17                          from scott.emp e
     18                         where e.deptno = d.deptno
     19                     ) as "Images"
     20                  )
     21               )
     22               order by d.deptno
     23            )
     24         ) the_xml
     25    from scott.dept d
     26    /* joins to the other tables EXCEPT image table */
     27  /
    
    THE_XML
    --------------------------------------------------------------------------------
    10ACCOUNTINGhttp://the.server
    

    The output is an XMLTYPE column (think of it as a CLOB with addition of feature ;-))
    My SQL * PLUS the output of cuts, but believe me, it's all there.
    Just to show, here is the same example, wrapped in a function XMLSERIALIZE to print the XML file:

    SQL> select xmlserialize(
      2            content
      3            xmlelement(
      4               "ROWSET"
      5             , xmlagg(
      6                  xmlelement(
      7                     "ROW"
      8                   , xmlforest(
      9                        d.deptno as "ID"
     10                      , d.dname as "NAME"
     11                      , (
     12                           select xmlagg(
     13                                     xmlelement(
     14                                        "ImgUrl"
     15                                      , 'http://the.server.com/'||e.empno
     16                                     )
     17                                     order by e.empno
     18                                  )
     19                             from scott.emp e
     20                            where e.deptno = d.deptno
     21                        ) as "Images"
     22                     )
     23                  )
     24                  order by d.deptno
     25               )
     26            )
     27            as varchar2(4000)
     28            indent size=2
     29         ) the_xml
     30    from scott.dept d
     31    /* joins to the other tables EXCEPT image table */
     32  /
    
    THE_XML
    --------------------------------------------------------------------------------
    
      
        10
        ACCOUNTING
        
          http://the.server.com/7782
          http://the.server.com/7839
          http://the.server.com/7934
        
      
      
        20
        RESEARCH
        
          http://the.server.com/7369
          http://the.server.com/7566
          http://the.server.com/7788
          http://the.server.com/7876
          http://the.server.com/7902
        
      
      
        30
        SALES
        
          http://the.server.com/7499
          http://the.server.com/7521
          http://the.server.com/7654
          http://the.server.com/7698
          http://the.server.com/7844
          http://the.server.com/7900
        
      
      
        40
        OPERATIONS
      
    
    

    For a Web service you don't need to print the XML that is returned by the Web service.

    I do not know APEX, so I don't know if APEX supports exposing an already built piece of XML, rather than expose a query result.
    But my guess is that it should do very well if you ask an XMLTYPE data type (i.e. - to use the first of my examples, and not automatically printed.)

    If you do not have APEX to do it this way, then I suggest that you try asking in the APEX forum rather than the SQL forum ;-)

  • procedure that will dynamically build the query data and table Medallion

    Hi people,

    I write a procedure that dynamically build the query data and insert in the table "dq_summary".
    enforcement procedure with success and data not inserted into the table 'dq_summary '.

    I have thin problem in code attached below
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOR rep IN cur_di_attr
          LOOP
            dbms_output.put_line ('d: ');   
            
            BEGIN
              EXECUTE IMMEDIATE 'SELECT table_name FROM ' || sum_tab || ' WHERE id = ' || rep.attribute_id INTO rep_tab;
              dbms_output.put_line ('rep_tab: '||rep_tab);
              run_query := run_query || ' ' || rep_tab || ' WHERE ' || nvl(wh_cond, '1 = 1');
              EXECUTE IMMEDIATE run_query INTO end_rslt;
            
              EXECUTE IMMEDIATE 'UPDATE dq_summary SET ' || prop || '_' || p_code || ' = ' || end_rslt || ' WHERE attribute_id = ' || rep.attribute_id;
              dbms_output.put_line ('e: ');      
              dbms_output.put_line ('rep_tab: '||rep_tab);
              dbms_output.put_line ('end_rslt: '||end_rslt);
              dbms_output.put_line ('f: '); 
            EXCEPTION
              WHEN no_data_found THEN
                rep_tab := '';
                sum_tab := '';
            END;  
          
          END LOOP;    
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    but in the procedure below must be run several times
    create or replace
    PROCEDURE DQ_REPORT_PROC
    AS
      prop                              di_proposition.pro_name%type;
      col_var                           VARCHAR2(100);
      p_code                            dq_parameter.para_code%type;
      sum_tab                           di_proposition.summary_table%type;
      run_query                         dq_parameter.run_query%type;
      wh_cond                           dq_parameter.where_cond%type;
      end_rslt                          VARCHAR2(20);
      rep_tab                           VARCHAR2(50);
      v_error_msg                       VARCHAR2(200);   
      v_error_code                      VARCHAR2(200);  
      v_object_name                     VARCHAR2(50)                          DEFAULT 'DQ_REPORT_PROC';
      v_iss_no                          VARCHAR2(20)                          DEFAULT NULL;
      CURSOR cur_di_prop IS 
        SELECT upper(replace(replace(pro_name, ' '),'-')) pro_name
          FROM di_proposition;
      
      CURSOR cur_di_para IS
        SELECT upper(para_code) para_code, run_query, where_cond
          FROM dq_parameter;
      
      CURSOR cur_di_attr IS 
        SELECT attribute_id
          FROM dq_summary;
    BEGIN
      
      DELETE FROM dq_summary;
    
      INSERT INTO dq_summary (attribute_id, entity_name, attribute_name, data_champ) 
        SELECT a.attribute_id, b.entity_name, a.attribute_name, a.data_champ
          FROM di_attribute_master a, di_entity_master b
         WHERE a.entity_id = b.entity_id;
    
      FOR c_prop IN cur_di_prop
      LOOP
        prop := c_prop.pro_name;
        
        BEGIN
          SELECT distinct SUBSTR(column_name, 1, INSTR(column_name, '_')-1), summary_table
            INTO col_var, sum_tab
            FROM user_tab_cols a, di_proposition b
           WHERE a.table_name = 'DQ_SUMMARY'
             AND upper(replace(replace(b.pro_name, ' '),'-')) = prop
             AND SUBSTR(a.column_name, 1, INSTR(a.column_name, '_')-1) = upper(replace(replace(b.pro_name, ' '),'-'))
             AND upper(b.status) = 'Y';
             
             dbms_output.put_line ('col_var: '||col_var);
             dbms_output.put_line ('sum_tab: '||sum_tab);
             
        EXCEPTION
          WHEN no_data_found THEN
            col_var := '';
            sum_tab := '';
        END;
    
        dbms_output.put_line ('a: ');
    
        FOR para IN cur_di_para
        LOOP
         dbms_output.put_line ('b: ');
          p_code := para.para_code;
          run_query := para.run_query;
          wh_cond := para.where_cond;
          dbms_output.put_line ('c: ');
          FOR rep IN cur_di_attr
          LOOP
            dbms_output.put_line ('d: ');   
            
            BEGIN
              EXECUTE IMMEDIATE 'SELECT table_name FROM ' || sum_tab || ' WHERE id = ' || rep.attribute_id INTO rep_tab;
              dbms_output.put_line ('rep_tab: '||rep_tab);
              run_query := run_query || ' ' || rep_tab || ' WHERE ' || nvl(wh_cond, '1 = 1');
              EXECUTE IMMEDIATE run_query INTO end_rslt;
            
              EXECUTE IMMEDIATE 'UPDATE dq_summary SET ' || prop || '_' || p_code || ' = ' || end_rslt || ' WHERE attribute_id = ' || rep.attribute_id;
              dbms_output.put_line ('e: ');      
              dbms_output.put_line ('rep_tab: '||rep_tab);
              dbms_output.put_line ('end_rslt: '||end_rslt);
              dbms_output.put_line ('f: '); 
            EXCEPTION
              WHEN no_data_found THEN
                rep_tab := '';
                sum_tab := '';
            END;  
          
          END LOOP;    
        END LOOP;
      END LOOP; 
      COMMIT;   
    EXCEPTION
          WHEN OTHERS THEN
             v_error_msg   := SQLERRM;
             v_error_code  := SQLCODE;  
             TRACKER_LOG_EXECEPTION(v_iss_no, v_object_name, CURRENT_TIMESTAMP, v_error_msg, v_error_code);
          COMMIT;        
      
    END DQ_REPORT_PROC;
    Published by: BluShadow on February 7, 2012 12:04
    addition of {noformat}
    {noformat} tags.  Please read {message:id=9360002} and learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    903830 wrote:

    I write a procedure that dynamically build the query data and insert in the table "dq_summary".
    enforcement procedure with success and data not inserted into the table 'dq_summary '.

    I'm sorry. But there is no kind of say that way. The code is undesirable. The approach is wrong. This will not happen. This will cause the fragmentation of memory in the shared Pool. This will lead to another session being impossible to analyze the sliders because of the fragmented memory.

    Not only that. The underlying data model is questionable.

    All this seems a candidate perfect as an example of how NOT to design and code and use Oracle.

  • Output query based on date - Oracle 8i

    I'm writing a very simple query for output data based on date ranges, but I continue to encounter an error.

    When I make this statement:

    Select * from my.table
    where startdate > ' 2008-01-01'

    I get this error:

    [ODBC] [Ora] ORA-01861: literal does not match the format string


    When I format the select statement in this way:

    Select * from my.table
    where startdate > #2008-01-01 #.

    I get this error:

    [ODBC] [Ora] ORA-00932: inconsistent data types: expected DATE got the NUMBER

    Currently using CF8, and what I believe is Oracle 8i. I tried these data in many other ways of formatting, but can not make it work. I know that when I query the database using access, he has no problem returns results with the date SQL formatted as # #01 / 01 / 2008

    You can use the Oracle to_date() function to convert your string to a date/time object:

    Select * from my.table
    where startdate > to_date ('2008-01-01', ' YYYY-MM-DD "")

    Otherwise, because you are using an ODBC for Oracle connection, you can try using the function CreateODBCDate() in ColdFusion:

    Select * from my.table
    where startdate > #CreateODBCDate("2008-01-01") #.

    Or, as has already been suggested, use cfqueryparam with the proper CFSQLType, such as CF_SQL_TIMESTAMP instead of CF_SQL_INTEGER as you try to do.

    You can not use a date value 'string' against a date/time column in a query Oracle, as he proceed to an implicit type conversion.

    Phil

  • Different output for the same query in SQL Server and Oracle

    I have two tables table1 and table2

    -table1 has two columns c1 int and varchar c2. There are no constraints added in it. It contains data as shown below

    C1 c2
    -------------------
    d 6
    5 d
    102 g
    6%
    f 103
    5.
    501 j
    1 g
    601 n
    2 m

    -table2 has only a single column c1 int. There is no added in constraints. It contains data as shown below

    C1
    ----
    6
    1
    4
    3
    2

    now when I run below, given the query in sql server and oracle it gives me different results

    Select *.
    FROM table1
    table2 on table2.c1 = table1.c1 inner join (SELECT ROW_NUMBER() (any ORDER by ASC c1) AS c1 from table2)

    output of SQL server
    ------------------------
    C1 c2 c1
    --------------------------------
    1 g 1
    2 m 2
    3 h 3
    4 g 4
    5 d 5


    release of Oracle
    ----------------------
    C1 C2 C1
    ---------------------------------
    5 d 5
    4 g 4
    3 h 3
    1 g 1
    2 m 2


    If you notice the first column in the two outputs. It is sorted in sql server and no oracle.

    Why he behaves differently in oracle? Is there a way I can fix this problem in oracle?

    Thank you
    Jigs

    It is NOT a behavior "differently" in Oracle; you did not specify just an order that you expect of your results, so you'll get output in what order the fantasies of the database showing (ie. no guaranteed order). It is an artifact of the way the database chooses to collect the data and databases (or same sets of data within the same database) can and will most likely behave differently.

    Same SQL Server will not be guaranteed to always get your data in an orderly manner if you exclude the order by clause, even if you think that there always display the data in an orderly manner.

    Your solution is to add an order by clause, in the TWO databases, to force the order of the data output.

  • [OSB] Specification of date and hour format custom in the generator of MFL/Format

    It is possible to specify a date and time format customized by MFL (e.g. use of the Format, or directly from the MFL XML document generator). I work with a file format that contains dates of the form:
    Bq yyyymmmdd HHMM .
    that is a chain of fourteen characters, with a year to four numbers, three letters, two-digit day, a space as separator, followed by a two-digit hour and a two-digit minute. Each part is included in at least one of the available conversion specifiers, but date part, the part of time, or whole, are available in the form of a standard conversion specifier. I was not able to find a reference to formats date and hour customized using the Format generator or Non - XML data Mapping sample.

    Of course, the field can be treated as a string and converted downstream, but it had a native XML dateTime type as part of the conversion would be ideal.

    Note that the Native Format Manager supports date formats specified by the user, as shown in [http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm#CCGJDGGJ].

    Thank you

    Geoff.

    Edited by: geofft 1 Sep 2008 11:09

    The asnwer is in your question:

    Note that the Native Format Manager supports date formats specified by the user, as shown in the http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm#CCGJDGGJ.

    It is not possible.

    Marc

  • DB2 code: today's date and the day to ORACLE function?

    Please help me to convert this code oracle...

    DB2 code:

    [code] ((Current date) - day (date (current date))) [/ code]

    I tried to use the functions of default in PL date timestamps, but it won't work. Help, please.

    As told by BluShadow and rp0428, you can execute the following statement:

    Select current_date, trunc(current_date,'MM')-1 day of double;

    The output will be today's date and the month last, last day.

  • Create the query by combining data from DBSS_Data_Model and HostModel

    Hello

    I am trying to create a dashboard with the host server list and instances of SQL Server running on the host.

    And I am interested in creating a query by combining data model of data in SQL Server (DBSS_Data_Model) and the host (Hosts) data model, say: which connects DBSS_SQL_Server_Host and host.

    I wonder if there is way to do it?

    Thank you

    Mark

    Something like this function should work:

    def physicalHost = nullqueryStatement = server.QueryService.createStatement("(Host where name = '$hostName')")result = server.QueryService.executeStatement(queryStatement)objs=result.getTopologyObjects()
    
    if (objs != null && objs.size() > 0) {     physicalHost = objs.get(0)}return physicalHost
    

    When the input parameter "hostName" is DBSS_SQL_Server_Host.physical_host_name

    Kind regards

    Brian Wheeldon

  • PowerCLI Script required to identify all clusters in a data center and all hosts within each cluster and calculate it using cpu and ram, avg, min, and max.

    Hi all

    I'm new to powercli and try to create a script to list all clusters in a data center and all hosts in a cluster and calculate min, max and avg cpu usage and ram by the host and cluster. So far, I have tried the below but I can't publish the results of my script.

    $Function = @)
    ForEach ($DataCenter Get-Data Center)
    {
    ForEach ($cluster in ($DataCenter |)) Get - Cluster)) - need help to post the information here and confirm if this is correct or not.
    {
    ForEach ($hosts in ($cluster |)) Get - VMHost))
    {
    ForEach ($vms to ($hosts |)) Get - VM)) - do not know if I called you here functions properly
    {
    $allvms = @)
    $allhosts = @)
    $hosts = get-VMHost
    $vms = get - Vm

    {foreach ($vms in $hosts)
    $hoststat = "" | Select the host name, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin
    $hoststat. Host name = $vmHost.name

    $statcpu = get-Stat-entity ($vmHost) - start (get-date). AddDays(-30)-Finish (Get-Date) - MaxSamples 10000 - stat cpu.usage.average
    $statmem = get-Stat-entity ($vmHost) - start (get-date). AddDays(-30)-Finish (Get-Date) - MaxSamples 10000 - stat mem.usage.average

    $cpu = $statcpu | Measure-object-property value - average - Maximum - Minimum
    $mem = $statmem | Measure-object-property value - average - Maximum - Minimum

    $hoststat. CPUMax = $cpu. Maximum
    $hoststat. CPUAvg = $cpu. Average
    $hoststat. CPUMin = $cpu. Minimum
    $hoststat. MemMax = $mem. Maximum
    $hoststat. MemAvg = $mem. Average
    $hoststat. MemMin = $mem. Minimum
    $allhosts += $hoststat
    }
    }
    }
    }
    }

    $Function | Select the host name, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv "c:\Function.csv" - noTypeInformation

    Any help on this is much appreciated.

    [Ordered] casting was introduced in v3 PowerShell.

    For PowerShell v2, you can use

    $vms = get - VM

    $stat = 'cpu.usage.average ','mem.usage.average '.

    $start = (get-Date). AddDays(-31)

    $report = get-Stat-entity $vms - start $start - Stat $stat - ErrorAction SilentlyContinue |

    Group-object - property {$_.} @entity.name} | %{

    $cpu = $_. Group | where {$_.} MetricId - eq "cpu.usage.average"} | Measure-object-property value - average - Maximum - Minimum

    $mem = $_. Group | where {$_.} MetricId - eq "mem.usage.average"} | Measure-object-property value - average - Maximum - Minimum

    New-object PSObject-property @ {}

    Datacenter = Get-Datacenter - VM $_. Group [0]. Entity | Select the name of ExpandProperty-

    Cluster Cluster Get - VM = $_. Group [0]. Entity | Select the name of ExpandProperty-

    VMHost = $_. Group [0]. Entity.Host.Name

    Name = $_. Group [0]. @entity.name

    CpuMin = $cpu. Minimum

    CpuAvg = $cpu. Average

    CpuMax = $cpu. Maximum

    MemMin = $mem. Minimum

    MemAvg = $mem. Average

    MemMax = $mem. Maximum

    }

    }

    $report | Sort-Object-property Datacenter, Cluster, VMHost name |

    Export Csv report.csv - NoTypeInformation - UseCulture

  • In general, is it better to use java.sql.Date and java.sql.Timestamp instead of oracle.jbo.domain.Date?

    Hello world

    During playback of Oracle ADF Real World Developer's Guide, I noticed the dates match occurring in JDeveloper is different from what is the list in the book. JDeveloper is failing to oracle.jbo.domain.Date, but according to the book:

    DATEjava.sql.DateDATE type is mapped to java.sql.Date if the column in the table is a no time didn't need information zone.
    DATEjava.sql.TimestampDATE type is mapped to java.sql.Timestamp if the column in the table has a component "time" and that the client needs to zone information.
    TIMESTAMPjava.sql.TimestampThe TIMESTAMP type is mapped to java.sql.Timestamp if nanosecond precision is used in the database.

    In general, is it better to use java.sql.Date and java.sql.Timestamp instead of oracle.jbo.domain.Date? Using java.sql.Date and java.sql.Timestamp could save me some headaches conversion date. And, is there a place in JDeveloper to display these maps? I looked around and didn't see anything.

    Thank you.

    James

    User, what version of jdev we are talking about?

    In GR 11, 1 material versions db types date and timestamp are mapped to types of domain data that represents a wrapper for the native data types. The reason was that the framework can work with the domain types regardless of the underlying data type.

    Since Oracle 11 GR 2 maps the types DB to java types (default selection, you can change it when you create a model project, you can set the Data Type Mapping). Once the pilot has business components define you cannot change this setting it would break existing components such as eo or vo.

    So if you are working wit 11 GR 1 subject, you must use the domain types, if you work with GR 11, 2 or 12 c, you can use the domain types, but it is recommended to use the java type mapping.

    Timo

  • Flash Template that follow and calculate data?

    I am interested in creation of this emerging and calculate data and give detailed results based on the answers.  Is it possible to create, follow and make this comment in Flash?  Something like the personality test followed.

    I don't know what you mean... Flash is an aspect of Quiz, but you can also create quizzes using Flash.  You will need to learn a bit of everything that involves Flash.  Your main goal to achieve this feature will learn Actionscript and how to interact with a resource of data such as a database of Flash.  He must also learn to use a scripting language on the server, such as PHP, to handle exchanges between the Flash and the database side.

    If you are a beginner with Flash, you have much to learn before you can expect something like what you say you want to create.  If you are a beginner in programming, even more.

  • How to load the date and time from text file to oracle using sqlloader table

    Hi friends

    I need you to show me what I miss loading date and time text file in a table oracle using sqlloader

    It's my data in this way (c:\external\my_data.txt)
    7369,SMITH,17-NOV-81,09:14:04,CLERK,20
    7499,ALLEN,01-MAY-81,17:06:08,SALESMAN,30
    7521,WARD,09-JUN-81,17:06:30,SALESMAN,30
    7566,JONES,02-APR-81,09:24:10,MANAGER,20
    7654,MARTIN,28-SEP-81,17:24:10,SALESMAN,30
    my table in the database emp2
    create table emp2 (empno number,
                      ename varchar2(20),
                      hiredate date,
                      etime date,
                      ejob varchar2(20),
                      deptno number);
    the code for the control in this path (c:\external\ctrl.ctl) file
    load data
     infile 'C:\external\my_data.txt'
     into table emp2
     fields terminated by ','
     (empno, ename, hiredate, etime, ejob, deptno)
    This is the error:
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Commit point reached - logical record count 5
    
    C:\>
    any help that I enjoyed

    Thank you

    Published by: user10947262 on May 31, 2010 09:47

    load data
    INFILE 'C:\external\my_data.txt '.
    in the table emp2
    fields completed by «,»
    (empno, ename, hiredate, etime, Elysa, deptno)

    Try

    load data
     infile 'C:\external\my_data.txt'
     into table emp2
     fields terminated by ','
     (empno, ename, hiredate, etime "to_date(:etime,'hh24:mi:ss')", ejob, deptno)
    

    This is the error:

    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Commit point reached - logical record count 5
    
    C:\>
    

    This isn't a mistake, you can see errors in the log file and bad.

  • Dynamically calculate the number of days between two dates and amounts of split

    Hello

    I have searched for a solution for this, but had no success.
    I need to show the amounts broken down by days.

    I have a table that has an amount column and start and end dates.

    I need to write a query so that the amounts will be broken evenly based on the number of days between the start date and end date.

    For example, for this line.
    insert into my_test values (' 1, '' 3-mar-2010, ' 7 - mar - 2010 ", 1000);

    the query returns this (split $1,000 over 5 days)


    ID Date amount
    1 ' 3-mar-2010' 200,00
    1 ' 4-mar-2010' 200,00
    1 ' 5-mar-2010' 200,00
    1 ' 6-mar-2010' 200,00
    1 ' 7-mar-2010' 200,00



    create table my_test)
    ID number (10),
    start_date date,
    End_date date,
    amount number (10.2)
    );


    Select * from my_test

    insert into my_test values (' 1, '' 3-mar-2010, ' 7 - mar - 2010 ", 1000);
    insert into my_test values (2, 10-mar-2010 ", 19-mar-2010", 2000);
    insert into my_test values (3, 20-mar-2010 ',' 21-mar-2010, 5000);



    Thanks in advance.

    Hello

    One way is to join a Meter of Table , a table, or (more often) a set of results includes a line for eery number 1, 2, 3,... until the maximum number of times you need to divide a line.
    For example:

    WITH     cntr     AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (  SELECT  MAX (end_date - start_date)     AS max_day_cnt
                 FROM        my_test
              )
         CONNECT BY     LEVEL <= 1 + max_day_cnt
    )
    SELECT       t.id
    ,       t.start_date + c.n                    AS dt
    ,       t.amount / (t.end_date + 1 - t.start_date)     AS amt
    FROM       my_test      t
    JOIN       cntr            c     ON     c.n <= t.end_date - t.start_date
    ORDER BY  id
    ,            dt
    ;
    

    This assumes that all dates have the same number of hours, minutes, and seconds, as is the case in your sample data.
    If this isn't the case, then use TRUNC (start_date) and TRUNC (end_date) instead of start_date and end_date or post some sample data and results if some lines do not represent a whole number of days.

  • How to find the Date and the time of Installation of Oracle on Windows?

    Hello

    Is it possible to find the installation Date and time of Oracle on Windows?


    Concerning
    Rajesh

    If you have never recreated/restored/reincarnated the database, then COLUMN of v database $ should tell you when you created the database.

    If you are looking for the time of installing Oracle home, check the logs under OraInventory.

    Reply by Satish sir at the following link:
    installation of a database date/time!

    HTH
    Girish Sharma

Maybe you are looking for