Generating dates from end of month

Hello

I have a table with a column as a partition_key, I want to insert all the end dates of month of Jan2009 to Dec2013 in the format below.

PARTITION_KEY

20090131

20090228

20090331

.

20120229.

.

20131231

Please tell us a plsql sql statement (GOLD) for this block.

SELECT last_day (add_months (DATE ' 2009-01-01',(level-1)))

OF the double

connect by level<= months_between(date="" '2013-12-01',date="">

/

is good to create lines, how you convert a date in number is easy to find...

HTH

Tags: Database

Similar Questions

  • get all the date of end of months between two dates

    Hi all, I'll try to find together the date of end of months between two dates.
    I have the following data in a table

    WITH AS's Data1
    (
    SELECT To_Date('4/30/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual UNION ALL
    SELECT To_Date('5/01/2009','mm/dd/yyyy') dt, "TEST2" lname FROM dual UNION all
    SELECT To_Date('5/02/2009','mm/dd/yyyy') dt, "TEST3" lname FROM dual UNION all
    SELECT To_Date('5/03/2009','mm/dd/yyyy') dt, "TEST4" lname FROM dual UNION all
    SELECT To_Date('5/04/2009','mm/dd/yyyy') dt, "TEST5" lname FROM dual UNION all
    SELECT To_Date('5/05/2009','mm/dd/yyyy') dt, "TEST6" lname FROM dual UNION ALL
    SELECT To_Date('5/31/2009','mm/dd/yyyy') dt, 'TEST7' lname FROM dual UNION all
    SELECT To_Date('6/01/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual

    )

    I would like to write an application that gives you all the end date for months between two dates
    for example, if you give the date 9/1/4 and 5/6/9, the output should be
    DT          LNAME
    -------------------
    4/30/2009   TEST
    IF I give you the dates 01/04/09 AND 01/06/09, THEN output should be
    DT          LNAME
    -------------------
    4/30/2009   TEST
    5/31/2009   TEST7
    as you can see, I want all the end dates of months between two dates by giving the output.

    If I give you 06/05/09 and 05/06/09, and then does so no output because there is no end of month between these two dates.
    Similarly, if I give you 30/04/09 and 30/04/09 then output should be 30/04/09 because it is an end of month date

    anyone can help to write a query. Thank you very much

    Jin
    Not sure if you need subquery, analytical functions for this.
    According to me, which should solve your purpose.

    WITH data1 AS
    (
    SELECT To_Date('4/30/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual UNION ALL
    SELECT To_Date('5/01/2009','mm/dd/yyyy') dt, 'TEST2' lname FROM dual UNION all
    SELECT To_Date('5/02/2009','mm/dd/yyyy') dt, 'TEST3' lname FROM dual UNION all
    SELECT To_Date('5/03/2009','mm/dd/yyyy') dt, 'TEST4' lname FROM dual UNION all
    SELECT To_Date('5/04/2009','mm/dd/yyyy') dt, 'TEST5' lname FROM dual UNION all
    SELECT To_Date('5/05/2009','mm/dd/yyyy') dt, 'TEST6' lname FROM dual UNION ALL
    SELECT To_Date('5/31/2009','mm/dd/yyyy') dt, 'TEST7' lname FROM dual UNION all
    SELECT To_Date('6/01/2009','mm/dd/yyyy') dt, 'TEST' lname FROM dual 
    
    )
    select distinct last_day(dt) dt,lname
      from data1
     where dt between &start_date and &end_date
       and last_day(dt) <= &end_date
    
    also, i have another request. how would i do this without using the data i provided. lets say,
     i tell you, give me alll the months end between two dates using dual in the from clause of a query.
    how would you do this in a query or pl/sql? thanks again
    

    Can be like that

    with data1 as(
    select &start_date+level-1 dt from dual
    connect by level <= &end_date-&start_date+1)
    select distinct last_day(dt)
      from data1
     where dt between &start_date and &end_date
       and last_day(dt) <= &end_date
     order by last_day(dt)
    

    See you soon!
    Bobin

    Published by: Buga added query for updated the need

  • date of end of month in SPR

    We must show the date of end of month for a given date in a table.
    The date is March 25, 2008 ", then output should give me 31 March 2008".
    I want to create a new column derived like this in the RPD.
    I think that variables can not help me out here, because we need to have the date of end of month for each value that the date column will hold.
    Please let me know how can achieve us.

    I haven't played a lot with the expression of OBIEE constructor functions but the technique below should work, you can use standard date functions:

    (1) take the month and year of your date column (for example for today, it will be 10/2008) convert it to a string.
    (2) date data type concatenate 01 to the string of the previous step and convert the entire expression. Now you have the first date of the month of your column in a date format.
    ((3) on the date to 2) add 1 month and 1 day to remove and you get the last day of the month for your selected date.

    Should work in OBIEE too.

  • Date of end of month

    Hi all
    I have a table "xyz" that captures start_date and end_date in one line.
    i.e. start_date = * 15 October 2007 *, end_date = * 25 - dec - 2008 *.

    I want to write a query that diplay end of month of each month between start_date and end_date as dates me. .

    October 31, 2007
    November 30, 2007
    31-dec-2007
    January 31, 2008
    February 29, 2008
    31-mar-2008
    ..
    ..
    ..
    ..
    ..
    ..
    ..
    ..
    31-dec-2008

    Thanks in advance

    Try this

    select
         last_day(add_months(to_date('15-oct-2007','dd-mon-yyyy'),level-1))
    from
         dual
    connect by level <= ((to_date('01-dec-2008','dd-mon-yyyy') - to_date('01-oct-2007','dd-mon-yyyy'))/30) +1
    /
     
    
  • XML schema to generate data from the table of data from a repeating subform

    Hi all, I would like to have a check box that when checked, allows you to hide a quote form and make a purchase order form visible, carrying a part of the field of the form of citation data in a new table on the order form. I have attached to this form to https://workspaces.acrobat.com/?d=pqpsXx5VPi * LkMeVKrX57w if you want to take a look. If the check box is cleared, he hid the PO form and to make quite visible.

    The idea behind this is that my client will create his quote and send t to his client. Once the customer accepts the quote, he simply click a button to generate its purchase order send it to its supplier.

    It seems that I have buttons to add lines on the submission form that the problem is more complex. I would be able to do it myself if the table has a fixed number of lines and I was able to use global fields, and naming each cell something different, but because it's a single repeating subform, I can't operate at all.

    I understand that, because it's a repeating subform that I need to create an XML schema to do this, but also can not know for the life of me how to create the schema. I read tons of tutorials, but no idea how to apply it to my specific needs. I've been able to find only info on how to bind the data source once it's been created.

    I would be eternally grateful if someone could help out me.

    Thank you!

    I edited your form and put it here.

    Here's what I did:

    • Script inserted into your box renamed someone who mask/displays the purchase order / sales quotation
    • I have included a script object with a function I wrote to transfer data from as named fields/subforms from one section to another
    • Inserted a few fields in your table of purchase order

    What you need to do is to complete the development of your purchase order table. Make sure that the common fields between the quote and purchase tables have the same name in order to transfer data.

    No necessary schema.

    Kyle

  • Report of the Group of dates for end of month

    Hi guys

    I need to get 6 months of data grouped by months end dates...

    I need to automate this query so that it looks always to date for the last 6 months

    How do I get there?

    The reason for writing the automated query, it's that this sql script is assigned to the business objects reporting.

    I use the pl/sql

    Here's the DOF

    create the table #Something
    (
    base_date datetime, int connections
    )

    Insert #Something
    Select ' 01 jul 2013', 21 Union all the
    Select ' 02 jul 2013', all 22 union
    Select ' 03 jul 2013', 210 Union all the

    ....

    ...

    Select July 31, 2013,"Union 498
    ' Select ' 01 August 2013 ', 44 Union all the
    ' Select ' 05 August 2013 ', 66 Union all the
    ...

    ....

    Select ' 03 dec 2013", 456 union all
    .

    .

    'Select December 31, 2013,"788

    ..............................................................................

    Desired output

    Connection of base Date

    31 jul 500 (not exact, just randomly)

    August 31 600

    30 sep 356

    31 Oct 676

    30 Nov 544

    31 Dec 456

    ..............................................................................

    Hope this helps

    Hello

    In Oracle, you can do this:

    SELECT LAST_DAY (TRUNC (base_date)) AS last_day_of_month

    SUM (connections) AS total_connections

    OF something

    WHERE base_date > = TRUNC (ADD_MONTHS (SYSDATE,-6), 'MONTH')

    AND base_date<  trunc="" (           ="" sysdate,     ="">

    GROUP OF LAST_DAY (TRUNC (base_date))

    ORDER BY last_day_of_month

    ;

    If you would care to post some CREATE TABLE and INSERT statements so you want the results of work from these data of the sample, then I could test this.

    Using Oracle?  #Something (with a sign # at the beginning) is not valid a table name, and datetime is not a valid data type in Oracle.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    The query above works if base_date is a DATE or TIMESTAMP.

    Since it is now January 2014, what are "the last 6 months?  The above query assumes that they are the last 6 months, that is, July to December 2013.

    If you mean the current (incomplete) and 5 months before it (i.e. August 2013 to January 2014), then add 1 month to the two deadlines in the WHERE clause:

    WHERE base_date > = TRUNC (ADD_MONTHS (SYSDATE,-5), 'MONTH')

    AND base_date<  trunc="" (add_months="" (sysdate, ="" 1) ="">

  • Generate data that are not available in the table

    I have a table that has monthly data for agents. Example of table structure is the following:

    create table agt_dum)

    agent_id number,

    number of months,

    Commission number)

    Examples of data include:

    AGENT_ID MONTHS COUNCIL

    1150
    12100
    1625
    2110
    2220

    Month value can be from 1 to 12.

    So as you can see these data is missing for the agents a few months.

    Here, the requirement is I need to generate data for each agent for 12 months. If the data is not already in the table and are should include agent_id, month number and commission is equal to zero.

    The output for the above data would be:

    AGENT_ID MONTHS COUNCIL

    1150
    12100
    130
    140
    150
    1625
    170
    180
    190
    1100
    1110
    1120
    2110
    2220
    230
    240
    250
    260
    270
    280
    290
    2100
    2110
    2120

    I tried SQL query with full outer join. I was able to generate data for columns of MONTHS and the COMMISSION using the NVL function. But I have been unable to generate the AGENT_ID.

    Please share your suggestions.

    I'm using Oracle 11 g 2.

    Thank you

    Sudhanshu

    If you need something like:

    WITH agt_dum (agent_id, MONTH, commission)

    (SELECT 1, 1, 50 IN all double union)

    Select 1, 2, 100 of all the double union

    Select 1, 6, 25 Union double all the

    Select double union all 2, 1, 10

    SELECT 2, 2, 20 DOUBLES)

    all_months as (select rownum as LUN double connect by rownum<=>

    SELECT *.

    To all_months:

    partition outer join agt_dum ad bequeathed (agent_id) on (ad.month = am.mon)

    /

    It is not yet complete, but I'm sure you can handle the rest...

    HTH

  • Transfer data from old iMac (2008) to the new (end of 2015)

    I was not able to find a convenient way to transfer data from my old mac (iMac 21 of 2008) to the new. (iMac 27 5K 4.0 El Cap) One thing... I have no ports firewire on the new iMac... then I have no crush on the old... What I've read says that you must use one or the other and both ends must be the same. If anyone knows where I can find "usable" information please let me know. Thanks in advance

    Use a Thunderbolt adapter, FireWire or back up your system to an external drive and migrate to it.

    (142867)

  • Transfer data from Contacts for data cards in the program generator

    Does anyone know how to transfer data from contacts in data cards in the program generator?

    We have a case will be company requires to do something like that.

    If this is not possible, what are my other options to accomplish the same outside the Builder program?

    Hi Nader

    You can simulate a Send shape using Connector of cloud within a program. The stages of processing the form would be set to update object data card with the data of the form.

    We can discuss it further if you wish.

    -Zainab

  • Generate data XML from Ref_cursor...

    Thanks for the reply

    Published by: 000111 on June 12, 2012 16:41

    Published by: 000111 on June 12, 2012 16:42

    000111 wrote:
    Hello
    I'm now in xml... I'm trying to generate XML from a ref_cursor... can someone tell me how I can achieve this?

    Does this help start?

    create or replace function my_func(ctr number)
    return sys_refcursor
    as
      l_cur sys_refcursor;
    begin
      open l_cur for select * from all_objects where rownum <= ctr ;
      return l_cur;
    end;
    /
    

    One way to use it is:

    select xmltype(my_func(2)) from dual ;
    

    Another way is:

    declare
       hnd dbms_xmlgen.ctxhandle;
    begin
       hnd := dbms_xmlgen.newcontext(my_func(2));
       dbms_xmlgen.setrowsettag(hnd, 'CURSOR');
       dbms_output.put_line(dbms_xmlgen.getxml(hnd));
    end;
    /
    
  • extract data from a string and compare it with sysdate

    Hello

    Since a few days I struggle to find a solution to my problem, maybe I have some luck here.

    Data type:

    11/23 ANA

    Alex 19/11

    1/11 tomorrow

    03/12 FW1

    Makes me tomorrow

    Bo 11/12

    Necessary data should be as MM/DD. I used substr and/or regexp_like, regexp_substr, but having a few problems.

    Months can be like 1, 2.11, 12 or 01,02, 03... 11, 12.

    I don't need the data in the format Month\Day.

    Basically all of the above "/" should be a month.

    And I need to get out all the foregoing, > 13.

    And I need to compare the exp with sysdate.

    Any ideas?

    THX

    something like:

    FUNCTION to CREATE or REPLACE makeDate (in_string in VARCHAR2
    in_format IN VARCHAR2: = ' MM/DD')
    date of return
    IS
    BEGIN
    To_date (in_string, in_format) return;
    exception
    When others then return null;
    end;
    /

    with sample_data as (choose 11/23 ANA' double str)
    Union of all the
    Select 19/11 Alex' double
    Union of all the
    Select 1/11 tomorrow "of the double
    Union of all the
    Select FW1 10/12 ' double
    Union of all the
    Select "Makes Me" tomorrow the double
    Union of all the
    Select ' Bo' 11/12 double
    UNION ALL
    SELECT 11/24 09:00 ' FROM dual
    )
    SELECT str
    OF sample_data
    WHERE REGEXP_LIKE (str, ' ^ [[: digit:]] {2} / [[: digit:]] {2}')
    and makeDate (regexp_substr (str, ' ^ [[: digit:]]{2}/[[:digit:]]{2}'))]]))<>

    /

    HTH

  • Generic procedure to load the data from the source to the table target

    Hi all

    I want to create a generic procedure to load data of X number of the source table to X number of the target table.

    such as:

    Source1-> Target1

    Source2-> Target2

    -> Target3 Source3

    Each target table has the same structure as the source table.

    The indexes are same as well. Constraint are not predefined in the source or target tables.there is no involved in loading the data from the business logic.

    It would simply add.

    This procedure will be scheduled during off hours and probably only once in a month.

    I created a procedure that does this, and not like:

    (1) make a contribution to the procedure as Source and target table.

    (2) find the index in the target table.

    (3) get the metadata of the target table indexes and pick up.

    (4) delete the index above.

    (5) load the data from the source to the target (Append).

    (6) Re-create the indexes on the target table by using the collection of meta data.

    (7) delete the records in the source table.

    sample proc as: (logging of errors is missing)

    CREATE or REPLACE PROCEDURE PP_LOAD_SOURCE_TARGET (p_source_table IN VARCHAR2,

    p_target_table IN VARCHAR2)

    IS

    V_varchar_tbl. ARRAY TYPE IS VARCHAR2 (32);

    l_varchar_tbl v_varchar_tbl;

    TYPE v_clob_tbl_ind IS TABLE OF VARCHAR2 (32767) INDEX OF PLS_INTEGER;

    l_clob_tbl_ind v_clob_tbl_ind;

    g_owner CONSTANT VARCHAR2 (10): = 'STG '.

    CONSTANT VARCHAR2 G_OBJECT (6): = 'INDEX ';

    BEGIN

    SELECT DISTINCT INDEX_NAME BULK COLLECT

    IN l_varchar_tbl

    OF ALL_INDEXES

    WHERE table_name = p_target_table

    AND the OWNER = g_owner;

    FOR k IN l_varchar_tbl. FIRST... l_varchar_tbl. LAST LOOP

    SELECT DBMS_METADATA. GET_DDL (g_object,

    l_varchar_tbl (k),

    g_owner)

    IN l_clob_tbl_ind (k)

    FROM DUAL;

    END LOOP;

    BECAUSE me IN l_varchar_tbl. FIRST... l_varchar_tbl. LAST LOOP

    RUN IMMEDIATELY "DROP INDEX ' |" l_varchar_tbl (i);

    DBMS_OUTPUT. PUT_LINE (' INDEXED DROPED AS :'|| l_varchar_tbl (i));

    END LOOP;

    RUN IMMEDIATELY ' INSERT / * + APPEND * / INTO ' | p_target_table |

    ' SELECT * FROM ' | '. p_source_table;

    COMMIT;

    FOR s IN l_clob_tbl_ind. FIRST... l_clob_tbl_ind LAST LOOP.

    EXECUTE IMMEDIATE l_clob_tbl_ind (s);

    END LOOP;

    RUN IMMEDIATELY 'TRUNCATE TABLE ' | p_source_table;

    END PP_LOAD_SOURCE_TARGET;

    I want to know:

    1 has anyone put up a similar solution if yes what kind of challenges have to face.

    2. it is a good approach.

    3. How can I minimize the failure of the data load.

    Why not just

    create table to check-in as

    Select "SOURCE1" source, targets "TARGET1", 'Y' union flag double all the

    Select "SOURCE2', 'TARGET2', 'Y' in all the double union

    Select "SOURCE3', 'Target3', 'Y' in all the double union

    Select "SOURCE4', 'TARGET4', 'Y' in all the double union

    Select 'Source.5', 'TARGET5', 'Y' in double

    SOURCE TARGET FLAG
    SOURCE1 TARGET1 THERE
    SOURCE2 TARGET2 THERE
    SOURCE3 TARGET3 THERE
    SOURCE4 TARGET4 THERE
    SOURCE.5 TARGET5 THERE

    declare

    the_command varchar2 (1000);

    Start

    for r in (select source, target of the archiving of the pavilion where = 'Y')

    loop

    the_command: = "insert / * + append * / into ' |" r.Target | ' Select * from ' | '. r.source;

    dbms_output.put_line (the_command);

    -execution immediate the_command;

    the_command: = 'truncate table ' | r.source | "drop storage."

    dbms_output.put_line (the_command);

    -execution immediate the_command;

    dbms_output.put_line(r.source ||) 'table transformed');

    end loop;

    end;

    Insert / * + append * / into select destination1 * source1

    truncate table SOURCE1 drop storage

    Treated SOURCE1 table

    Insert / * + append * / to select TARGET2 * in SOURCE2

    truncate table SOURCE2 drop storage

    Treated SOURCE2 table

    Insert / * + append * / into select target3 * of SOURCE3

    truncate table SOURCE3 drop storage

    Treated SOURCE3 table

    Insert / * + append * / into TARGET4 select * from SOURCE4

    truncate table SOURCE4 drop storage

    Table treated SOURCE4

    Insert / * + append * / into TARGET5 select * from source.5

    truncate table source.5 drop storage

    Treated source.5 table

    Concerning

    Etbin

  • Extract data from Oracle into excel file

    Hello

    I have a requirement where in I need to extract data from Oracle into excel file and the worksheet excel name should be 'given '.
    for example. Excel 'AR Data_DDMMYY' file name and the name of the "Data" sheet excel

    I used the UTL_FILE API to extract the data delimited by tabs that you can open in excel, but it's not exactly an excel file as the name of the worksheet is the same as the name of the file.

    I tried to use utl_file.fcopy and frename.

    Is it possible to do it using PLSQL?

    Select * from version of v$.
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    "CORE     10.2.0.5.0     Production"
    TNS for HPUX: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    Example Code:
    declare
    cursor c is
    select * from scott.emp;
    v varchar2(100);
    f utl_file.file_type;
    
    file_name varchar2(100) := 'AR Data.xls';
    dir varchar2(50) := 'CESDIR191710';
    
    --select * from dba_directories
    
    begin
    
    
    f := utl_file.fopen(dir, file_name, 'W');
    
    v := 'EMPNO'||chr(9)||'ENAME'||chr(9)||'JOB'||chr(9)||'SAL'||chr(9)||'HIREDATE'||chr(9)||'DEPTNO';
    utl_file.put_line(f, v);
    
    for i in c
    loop
    
    v := i.empno||chr(9)||i.ename||chr(9)||i.job||chr(9)||i.sal||chr(9)||i.hiredate||chr(9)||i.deptno;
    utl_file.put_line(f, v);
    
    end loop;
    utl_file.fclose(f);
    
    --utl_file.frename(dir, file_name, dir, replace(file_name, '.xls', '_')||to_char(sysdate, 'MMDDYY')||'.xls', false);
    utl_file.fcopy(dir, file_name, dir, replace(file_name, '.xls', '_')||to_char(sysdate, 'MMDDYY')||'.xls');
    
    end;
    Thank you
    Imran

    Hello

    I tried to change the .xlsx to .xls and it gives a note at the opening of the file "the file you are trying to open, abc.xls, is in a different format that it is specified by the file extension. Check that the file is not corrupted and precedes from a trusted source before you open the file. Do you want to open it now? »

    When you rename the file does not solve your problem.
    Anton Scheffer package generates a file in format xlsx Office 2010. When rename you it with the .xls extension, then Office 2010 will give you the warning that the file format does not match the extension.

    but the requirement has to generate excel 2003 file.

    The xml_spreadsheet package writes a format that was introduced with Office 2003, but you must use .xml as extension in other Office 2010 will give you the same caveat.
    To write the real xls version (binary), you can use Apache POI. You will need to import Java classes in your db and write a PL/SQL wrapper. Or you can use one of the options above, writing the output to a windows server and then use Excel to open and save in the required format.

    You must decide whether it is easier to write the binary xls format or to convince the customer to accept other formats that can be opened with Excel.

    Concerning
    Marcus

  • Help me with SQL Query to retrieve data from a view

    Hello Guru,

    I need help in my sql query.
    I use SQL TeraData.
    I want an Oracle result in the following form-

    Open tickets
    Open months failure / Repair Service s/o improvement request Total general
    2009-01-2 4 4 5 15
    2009-02 1 0 2 3 6
    2009-03 4 1 2 2 9
    Grand Total 7 5 8 10 30


    I wrote the query as where - TIME_PERIOD, RQST_TYPE_DM and DEMAND_SUMMARY_FCT are the points of view and I extract the data from the views only.

    Select NVL (CA. TIME_PERIOD. PERIOD_CD, 'Total') THAT year.
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% of Break' THEN 1 END) as BreakFix
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'N/a', 1 END) by n/a
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'Improvement' THEN 1 END) accessories
    COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% Service' THEN 1 END) as ServiceRequests
    COUNT (CA. RQST_TYPE_DM. RQSTTYP_DESC) AS grand_total
    FROM CA. TIME_PERIOD, CA. RQST_TYPE_DM, CA. DEMAND_SUMMARY_FCT
    WHERE (CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = CA. RQST_TYPE_DM. RQSTTYP_ID)
    AND (CASE
    WHEN CA. DEMAND_SUMMARY_FCT. MONTH_ID = CA. TIME_PERIOD. PERIOD_ID, 1
    WHEN {fn concat ({fn concat (SUBSTR (CA. TIME_PERIOD. {(PERIOD_CD, 3, 4),'-')}, SUBSTR (CA. TIME_PERIOD. PERIOD_CD, 7, 2))} BETWEEN ' 2009-01' AND ' 2009-03' THEN 1
    WHEN CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = '1' then 1
    END) = 1
    GROUP BY ROLLUP (CA. TIME_PERIOD. PERIOD_CD)

    After executing the query, I get the following error:
    3076: syntax Error: Data Type 'Time' does not match a defined Type name.
    :( Kindly help me with this and let me know where I'm wrong... Please.

    Messages indicates something wrong with your data... It would seem that the data does not match your format mask.

    Thus, the data or the format mask.

  • Script Insert statement to extract data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that works for more than 15 years. Every now and then, we need to extract data from this table @ ORacle 7i to import to Oracle 10 G.

    My thoughts are to create a script to Insert statements in oracle 7 and that, to be deployed to Oracle 10 G.

    I found cela scripts in Google and don't know exactly how it works. No explanation on these scripts, would be greatly appreciated. I find that this format can help to produce a set of insert statements in this table to the last table to 10G.

    < pre >
    -Step 1: create this procedure:
    create or replace function ExtractData (v_table_name varchar2) return varchar2 as
    Boolean b_found: = false;
    v_tempa varchar2 (8000);
    v_tempb varchar2 (8000);
    v_tempc VARCHAR2 (255);
    Start
    for tab_rec in (select table_name from user_tables where table_name = upper (v_table_name))
    loop
    b_found: = true;
    v_tempa: =' select ' insert into ' | tab_rec.table_name |' (';
    for col_rec in (select * from user_tab_columns)
    where
    table_name = tab_rec.table_name
    order by
    column_id)
    loop
    If col_rec.column_id = 1 then
    v_tempa: = v_tempa | " ' || Chr (10) | " ' ;
    on the other
    v_tempa: = v_tempa |', ". Chr (10) | " ' ;
    v_tempb: = v_tempb |', ". Chr (10) | " ' ;
    end if;
    v_tempa: = v_tempa | col_rec.column_name;
    If instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc: = "' |' | col_rec.column_name |'| " ' ;
    elsif instr (col_rec.data_type, 'DATE') > 0 then
    v_tempc: = "' to_date ("'| to_char('|| col_rec.column_name||',''mm/DD/YYYY HH24 '') | ") (', "' dd/mm/yyyy hh24"') "';
    on the other
    v_tempc: = col_rec.column_name;
    end if;
    v_tempb: = v_tempb | " ' || Decode('|| col_rec.column_name||',''Null'','||v_tempc||') | " ' ;
    end loop;
    v_tempa: = v_tempa |') values ('| v_tempb |'); "from ' |" tab_rec.table_name | « ; » ;
    end loop;
    If not b_found then
    v_tempa: ='-Table ' | v_table_name | 'not found ';
    on the other
    v_tempa: = v_tempa | Chr (10) | "select"-commit; "double;';
    end if;
    Return v_tempa;
    end;
    /
    display errors

    -STEP 2: run the following code to extract the data.
    Go head
    set pages 0
    game of stripes on
    fixed lines 2000
    the feeding off value
    trigger the echo
    var retline varchar2 (4000)
    coil c:\t1.sql
    Select 'set echo off' from dual;
    Select 'spool c:\recreatedata.sql' from dual;
    Select ' select "-these data was extracted on" | TO_CHAR (sysdate, "mm/dd/yyyy hh24" ") double;' double.

    -The following two lines as repeat as many times as the tables that you want to extract
    exec: retline: = ExtractData ('dept');
    print: retline;

    exec: retline: = ExtractData ('emp');
    print: retline;

    Select 'off spool' from dual;
    spool off
    @c:\t1

    -Step 3: run the updated c:\recreatedata.sql waiting for output to recreate the data.

    Source: http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml




    < / pre >

    Hello

    Well what this script do.
    You will pass a table name as input to the function that will return varchar2 (string - insert statement). It will generate 2 t1.sql of sql script that contains the output sequence.

    Will use the first passed the user_tables scipt to check if the input table name exists and if there is the will reterive user_table_columns column names and generate the following sql script.
    Now, this t1.sql will run to generate a final sript formally orders insert that will run you on the target schema (make sure that the table exists).

    * #t1.sql*

    set echo off
    spool recreatedata.sql
    select '-- This data was extracted on '||to_char(sysdate,'mm/dd/yyyy hh24:mi') from dual;
    select 'insert into MY_OBJECT1 ('||chr(10)||'OWNER,'||chr(10)||'TOTAL) values ('||decode(OWNER,Null,'Null',''''||OWNER||'''')||','||chr(10)||''||decode(TOTAL,Null,'Null',TOTAL)||');' from MY_OBJECT1;
    select '-- commit;' from dual;
    spool off
    

    Then @t1.sql runs, and the general insert for the infeed table table.

    -- This data was extracted on 03/09/2009 23:39
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('MDSYS', 92800);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('TSMSYS', 256);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('DMSYS', 15104);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('TESTME', 128);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('PUBLIC', 2571392);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('OUTLN', 768);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('CTXSYS', 21888);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('OLAPSYS', 78336);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('KLONDIKE', 2432);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('SYSTEM', 51328);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('EXFSYS', 21504);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('DBSNMP', 4096);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('ORDSYS', 216192);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('SYSMAN', 111744);
    
    -- commit;
    

    Hope this helps
    Concerning

Maybe you are looking for

  • I got a new computer and installed Firefox, but do not know how to transfer Firefox bookmarks on the old computer.

    This must be one of the most common problems that people encounter. We receive all new computers every so often, and we all need to keep the old bookmarks when we get a new computer and install the new browser. I feel that I must be among the small m

  • Unknown device on Equium A100 - 01 M

    I have now installed 99.9% of the drivers of this laptop but there is a single device, that I can't seem to find the driver in the device under details Manager, it says "root\legacy_ termservice\system". That is what I tried different drivers without

  • FPGA connect for compiling the server

    Hi all I'm just trying to write my code for my Spartan 3 FPGA. I was moved to another computer so I tried to install the right tools... LabView 2010, the module, LabView FPGA 2010 so that the pilot of the Commission of the Spartan Xlinix I use. Windo

  • How to determine if the XP operating system is genuine

    They gave me this computer, Dell Precision 340, which had been built in 2003. He moved with Windows XP Pro version 2002 registered 3 pack. I was on the site of Microsoft trying to download Security Essentials and the site told me that this operating

  • Blue screen of TouchPad

    TouchPad couldn't right star.  Showing the server error 'please visit http://hpwebos.com/support to help solve this problem. " When you choose close, blue display with "HP webOS on the left corner.  I can even tap and showing three options, "device i