How to generate a customized report with a table

I have a table with two columns: month, count. The values are like the following:
Jan-2007 50
Feb-2007 46
Mar-2007 55
Apr-2007 76
Jan-2009 67
Feb-2009 86
Mar-2009 55
I want to generate a report like this:
Month 2007 2008 2009
January 50 76 67
Febuary 46 45 86
How to do that?
Thanks.
Jen

Jen,
This is the best way I could come up with. It is a little clunky but it gets the job done. Basically it buckets each group by month and then unions each month together. I used the column names and formats you specified so you should only have to change the table name.
EDIT
You may want to do a nvl on each decode that way the sums will work correctly for nulls. Also, you could generate this sql statement procedurally and save yourself some maintenance time. This was just to show you how it could be approached.
SELECT 'January' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE substr(month,1,3) = 'JAN'
  GROUP BY 'January'
UNION ALL
SELECT 'February' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE UPPER(substr(month,1,3)) = 'FEB'
  GROUP BY 'February'
UNION ALL
SELECT 'March' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE substr(month,1,3) = 'MAR'
  GROUP BY 'March'
UNION ALL
SELECT 'April' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE UPPER(substr(month,1,3)) = 'APR'
  GROUP BY 'April'
UNION ALL
SELECT 'May' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE substr(month,1,3) = 'MAY'
  GROUP BY 'May'
UNION ALL
SELECT 'June' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE UPPER(substr(month,1,3)) = 'JUN'
  GROUP BY 'June'
UNION ALL
SELECT 'July' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE substr(month,1,3) = 'JUL'
  GROUP BY 'July'
UNION ALL
SELECT 'August' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE UPPER(substr(month,1,3)) = 'AUG'
  GROUP BY 'August'
UNION ALL
SELECT 'September' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE substr(month,1,3) = 'SEP'
  GROUP BY 'September'
UNION ALL
SELECT 'October' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE UPPER(substr(month,1,3)) = 'OCT'
  GROUP BY 'October'
UNION ALL
SELECT 'November' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE substr(month,1,3) = 'NOV'
  GROUP BY 'November'
UNION ALL
SELECT 'December' "Month",
       SUM(DECODE(substr(month,5,4),2000,count)) "2000",
       SUM(DECODE(substr(month,5,4),2001,count))"2001",
       SUM(DECODE(substr(month,5,4),2002,count))"2002",
       SUM(DECODE(substr(month,5,4),2003,count))"2003",
       SUM(DECODE(substr(month,5,4),2004,count))"2004",
       SUM(DECODE(substr(month,5,4),2005,count))"2005",
       SUM(DECODE(substr(month,5,4),2006,count))"2006",
       SUM(DECODE(substr(month,5,4),2007,count))"2007",
       SUM(DECODE(substr(month,5,4),2008,count))"2008",
       SUM(DECODE(substr(month,5,4),2009,count))"2009" FROM TYSON_TEST_TABLE
  WHERE UPPER(substr(month,1,3)) = 'DEC'
  GROUP BY 'December'Edited by: Tyson Jouglet on Mar 17, 2009 9:27 AM

Similar Messages

  • How To Generate And Print Reports In PDF Format From EBS With The UTF8 Char

    Hi,
    I want to know How To Generate And Print Reports In PDF Format From EBS With The UTF8 Character Set in R12.0.4.
    Regards

    Refer to Note: 239196.1 - PASTA 3.0 Release Information
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=239196.1
    Or, you can use XML Publisher.
    Note: 551591.1 - Need Latest XML Publisher / BI Publisher Patches For R12
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=551591.1

  • NAV 2013 R2; How to run a customized report (206 sales invoice) in the classic client

    Hello, in preparing a newly installed NAV 2013 R2, I'm questioning the following:
    In the Development Environment I have customized report 206 Sales - Invoice in the Design menu View Layout with the space of the logo (by Microsoft SQL Server Report Builder) and
    finally saved and compiled.
    When I do run it connects to the server of what I call the classic client or the real NAV 2013 R2 and I can select a posted sales invoice to show the new layout and the result is
    fine as customized as I wanted.
    When I later ordinary print one of the posted sales invoices this customized logo layout doesn't appear on the print. I print in PDF and paper. When I make a next new sales invoice
    this new layout is not in use either.
    Another thing is run print started from the Development Environment is called Sales - Invoice in the header and not just Invoice that it the name when printing when invoicing and
    printing of posted documents.
    Additionally this form of Sales - Invoice shows our company details and good information as web, e-mail, bank account and bank name that is well demanded on a perfect invoice.
    How to get these informations out normally?
    Is the classic client having a wrong report as sales invoice?
    How to run a customized report (206 sales invoice) in the classic client NAV 2013 R2?
    It is like the customized report (206 sales invoice) is not in use yet in the classic client.
    All you wise people out there are welcomed to help me now
    Best regards
    Carsten

    Try on Dynamics Community forum: https://community.dynamics.com/nav/f/34.aspx

  • How to export 2 different report with a link at the same time

    Hi,
    Do anybody know how to export 2 different report with a link at the same time. I currently create a report which link to another report. But when I want to export the 1st report I also want the 2nd report also be exported.
    Thank you very much.
    Best Rgds,
    SL Voon

    Export all the three components individually.
    It will generate 3 script files. Now run them from SQL>
    null

  • How To Migrate My Customized reports & Forms  To R12?

    Hi...
    How To Migrate My Customized reports & Forms To R12?
    I want to migrate my customized report&forms to R12 From 11.5.9 Base?
    how to find the customized Reports & Forms Location?
    How To Register the customized Reports & Forms?
    Regards
    **SBJ**

    Hi,
    Please see these documents/links.
    Note: 563258.1 - How To Upgrade 11i Custom Forms To R12
    Note: 451934.1 - Accessing Custom Forms After Upgrading From To R12
    Note: 552010.1 - Can't Open Custom Forms After R12 Upgrade
    Note: 130686.1 - How to Generate Form, Library and Menu for Oracle Applications
    Forms & Reports in R12?
    Forms & Reports in  R12?
    Thanks,
    Hussein

  • How to create a custom report and include multiple extended CRM database?

    I have created a number of CRM databas extensions and applied all there fields to my contacts and cases.
    I might have for example:
    - Additional address details
    - Business information
    - Quote Details
    - Trade Referees
    I know how to run a custom report and that I can select any one of these extra CRM databases as a filter and included them in the report. Is there a way though to add more than one (preferrably all) of the extra CRM databases to the report?
    The onely ways I can see it work is by either include all fields in one extra CRM database (not ideal) or bu running multiple reports and merge them somehow in Excel.
    Is there another way that I am not aware off?
    Thanks for your help,
    Jerun

    Hi Jerun,
    There's no way to do that. You'll need to run separate reports and merge them in Excel.
    -m

  • How to generate a MSDS report from status GP (Generation possible) to RE

    Hi EHS Goeroes,
    I'm struggling with the Generation of the MSDS. I have done the following procedure and settings:
    a) Create MSDS report (CG42)
    b) Edit Generation Variant (CG2B)
    Settings:
    (I have assigned my template to the Generation Variant)
    Generate manual request automatically: marked
    Change Marks: 0
    Initial release status: RE (released)
    Version requirement: unmarked
    Set historical automatically: unmarked
    c) EHS > Specification Workbench > Report from Template (to test the design - display is correct and all phrases can be found)
    d) EHS > Specification Workbench > Create new report
    (report has been created succesfully and appears in Report Management).
    e) EHS > Specification Workbench > Report Management:
    MSDS_29 Material Safety Data Sheet for China World
    Chinese Not Relevant Generation Poss. => generation possible.
    Feedback affter clicking on Accept: You tried to carry out action 'Accept' on a report with status GP. However, this action is not allowed for reports with this status.
    Feedback after clicking on Generate: You tried to carry out action 'Generate' on a report with status GP. However, this action is not allowed for reports with this status.
    d) SE38 I have no jobs scheduled yet, so I run the following two programs to start the worklist manually, RC1AVGE1 and RC1AVGE2.
    RC1AVGE1 - gave allot of feedback information regarding to changes and so on (first time I run it).
    RC1AVGE2 - feedback: EHS: 'Worklist Generation for Reports - Selection for Check. - 0 reports to be checked were found'
    From my understanding program RC1AVGE2 - should generate the MSDS.
    e) WWI - monitor display (CG5Z):
    100 @03\QNo background processes in client@ 5 SBR WWI-00000000000000000002 FREE RMDERKS
    110 @03\QNo background processes in client@ 5 SBR WWI-00000000000000000063 FREE A132645
    xxx SV001 @5B\QWWI server is active@ @02\QNo background processes on WWI server@
    xxx SV003 @5C\QWWI server is inactive@ @02\QNo background processes on WWI server@
    I checked if I had any jobs running in the background or has been finished, but it seems like it goes wrong here, the system does not generate a job for the generation of the MSDS_29. To be able to get the status of MSDS_29 to RE (Released).
    Does anybody has an idea what I do wrong, or which settings might be incorrect? Futhermore, what are the further steps to issue the report in the SD module - report shipping?
    Help is much appreciated!
    Roy Derks

    Hi Roy,
    Check and activate the QWWI server for the second job wwi - 110. Try once to generate the MSDS.
    I will revert back if i get information.
    regards,
    mahesh.

  • How to download the custom Reports to xls from the system?

    Hi
    How to download the custom Reports to xls from the system?
    I know the t code SE38 for reports.
    Vijay

    Hi
    Here the programa name is nothing but a report name???
    Vijay

  • How to generate a PRBS signial with arbitrary generator HAMEG HMF2525

    hi, i need help to make the acquisition and signal generation from HFM2525 HAMEG.
    and how to generate a PRBS signial  with arbitrary generator HAMEG HMF2525?

    fafil82,
    What have you done so far?  What NI products are you using?  If you're using ELVIS how does your setup look like?  What is your overall application?
    Jonathan R.
    Applications Engineer
    National Instruments

  • How to generate a csv report to determine paper size in a pdf or pdf/a file ?

    how to generate a csv report to determine paper size in a pdf or pdf/a file ?

    Use the cfpdf tag as follows:
    <cfpdf
        action = "getinfo"
        name = "pdf_info"
        source = "C:\temp\testFile.pdf">
    My Operating System is Windows. This tag gets information about testFile.pdf, and stores it in a structure. I have given this structure the name pdf_info. This structure has the key you are interested in, namely, pageSizes.
    Pdf_info.pageSizes is an array whose indices correspond to the respective page number in the PDF. You can use this to generate Comma-Separated Values (CSV) for each page.
    <!--- Initialize CSV list --->
    <cfset csv = "">
    <!--- Add headers or first row, followed by carriage-return --->
    <cfset csv = "Page,Height,Width" & chr(13)>
    <cfloop from="1" to="#arrayLen(pdf_info.pageSizes)#" index="i">
    <cfset row_info = i & "," & pdf_info.pageSizes[i]["height"] & "," & pdf_info.pageSizes[i]["width"] & chr(13)>
    <cfset csv = csv & row_info>
    </cfloop>
    <!--- Output CSV --->
    <cfoutput>#csv#</cfoutput>
    <!--- Write CSV to file --->
    <!--- <cffile action="write" file="C:\temp\output.csv" output="#csv#"> --->
    Done!

  • Creating custom reports with Pie Chart

    Hello,
    I've got a little problem while I'm creating custom reports with SQL Chart.
    For example, I want to have a Pie Chart that represent the distribution of the version for a software, i wrote my query with no problem, the result is in good format.
    My Pie Chart is fine except there are no percentage displayed. The legend on the right is fine with correct count of different version, but no percentage on the pie chart.
    Any idea?
    Thanks in advance,
    Fab

    Hello,
    well, I think this is not possible to ask OEM to print the percentage over the chart.
    Anyway, I sugget you to rewrite your query to compute the % in the query itselft thus to have the pct displayed on the rigth.
    Let's say you want to display the database files' size with such a query: select file_name name,bytes val from dba_data_files;
    This is the way to display the % of each file size over the total (remark the above query has been embeded in the new one).
    select name,ratio_to_report(val) over() pct
    from ( select file_name name,bytes val from dba_data_files )
    order by val desc
    It is quite easy to adapt such a tip to your own query.
    Regards,
    Noel Talard

  • Enhancing Customer Reports with Commands and Parameters

    Hi All,
    I am implementing the mentioned tutorial. I have succesfully deployed the AccessStatisticApplication PAR on portal. While scheduling the report from Content Management -> Reports -> Running Reports, it is giving error "<b>Can't find bundle for base name com.sap.netweaver.km.stats.reports.DocumentAccessReport, locale en_US</b>". Has anyone faced the problem, can anyone please help to remove this runtime error.
    Related Link: <a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7d28a67b-0c01-0010-8d9a-d7e6811377c0">Enhancing Customer Reports with Commands and Parameters</a>
    Regards
    Poonam

    <i>True, the application property service is apparently not to be used for a real-life scenario</i>
    You can definitely use the application property service in production scenarios - it's used by other components in a standard KM install, i.e. out-of-the-box.
    <i>in our case it forced the server down with deadlocks. </i>
    This should definitely not happen! Did you get SAP support to take a look at this? Was it the most popular documents report that caused this, or some other custom code? There should be no such problem with this service, since it's been around for quite some time and in production use.
    <i>
    Even if the code sample is not to be used for real-life scenarios it could at least make use of something else than the application property service which isnt't optimal for this use.
    </i>
    The application property service is good for a lot of scenarios, so it is realistic to use in in real-life scenarios. The only time I have seen this approach (storing the number of hits on documents in the database) fail is in very high-load scenarios.
    <i>Could you provide me with a link to the documentation for the logging framework?</i>
    <a href="http://http://help.sap.com/saphelp_nw70/helpdata/en/d2/5c830ca67fd842b2e87b0c341c64cd/frameset.htm">Logging and Tracing</a> on help.sap.com and <a href="https://help.sap.com/javadocs/NW04S/current/en/index.html">Logging and Tracing API (J2EE Engine API)</a> for NW 7.0.

  • Need to create form on a table with report with a table has NO primary key

    Hi, I tried to created some insert/update/delete form+report in an application, it works fine only if the table has primary key. Does anyone know how to create the same functionality with a table with no primary key? I saw an application is built on older version of htmldb that is using tables with no primary keys at all.
    Here are the specific issues that I am facing:
    - I am building some Form on a table with Report, it requires the table with primary key for form to update. Is there a workaround that I can use tables that has no primary keys at all?
    - Say if primary key is necessary in the previous report+form, but the maximum number of columns that I can use to composed a primary is only 2 for that Form-Report, I cannot find anything handling > 2 primary key. Do you know if there are some ways to composite a primary key from many columns together?
    Your help is really appreciated.
    Thanks,
    Angela

    Sorry to ask response so late. I had no time to get back to that issue before.
    Regarding the triggers, I can make it work for the update, but not the insert.
    Here is my trigger:
    create or replace trigger STATUS_T1
    instead of insert on STATUS
    begin
    insert into STATUS ("LABEL", "AREA", "OWNER", "TEST_NAME", "STATUS", "REMARKS", "BUGS", "DEV_MGR", "TEST_BY_DATE")
    values(:new.LABEL, :new.AREA, :new.OWNER, :new.TEST_NAME, :new.STATUS, :new.REMARKS, :new.BUGS, :new.DEV_MGR, :new.TEST_BY_DATE);
    end;
    by any chance, you can notify what is wrong?
    I already skip the ROWID when inserting to the view STATUS, but I cannot figure out what is wrong when inserting a new record to that view.
    It gave me the following errors:
    ORA-06550: line 1, column 38: PL/SQL: ORA-00904: "ID": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored
    Error Unable to process row of table STATUS
    Then, I turned to debug mode, I am thinking that maybe because I use a HIDDEN item to hold the value of ROW_ID as I use the rowid (called ID in the view) to retrieve the record as a column link from previous page. What do you think?
    Thanks again,
    Angela

  • How to generate the insert script of the  tables data present  in an entire

    How to generate the insert script of the tables data present in an entire schema in sqlplus environment
    with out toad can you please help me please!!!!!!!!!!!!!

    HI,
    First create this function to get insert scripts.
    /* Formatted on 2012/01/16 10:41 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE FUNCTION extractdata (v_table_name VARCHAR2)
       RETURN VARCHAR2
    AS
       b_found   BOOLEAN         := FALSE;
       v_tempa   VARCHAR2 (8000);
       v_tempb   VARCHAR2 (8000);
       v_tempc   VARCHAR2 (255);
    BEGIN
       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)||''';
             ELSE
                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:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
             ELSE
                v_tempc := col_rec.column_name;
             END IF;
             v_tempb :=
                   v_tempb
                || '''||decode('
                || col_rec.column_name
                || ',Null,''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';
       ELSE
          v_tempa := v_tempa || CHR (10) || 'select ''-- commit;'' from dual;';
       END IF;
       RETURN v_tempa;
    END;
    SET PAUSE OFF
    SET LINESIZE 1200
    SET PAGESIZE 100
    SET TERMOUT OFF
    SET HEAD OFF
    SET FEED OFF
    SET ECHO OFF
    SET VERIFY OFF
    SPOOL  GET_INSERTS.SP REP
    SELECT EXTRACTDATA('EMP') FROM DUAL;
    SPOOL OFF
    SET PAUSE  ON
    SET LINESIZE 120
    SET PAGESIZE 14
    SET TERMOUT ON
    SET HEAD ON
    SET FEED 5
    SET ECHO ON
    SET VERIFY ON
    SELECT    'insert into EMP ('
           || CHR (10)
           || 'EMPNO,'
           || CHR (10)
           || 'ENAME,'
           || CHR (10)
           || 'JOB,'
           || CHR (10)
           || 'MGR,'
           || CHR (10)
           || 'HIREDATE,'
           || CHR (10)
           || 'SAL,'
           || CHR (10)
           || 'COMM,'
           || CHR (10)
           || 'DEPTNO) values ('
           || DECODE (empno, NULL, 'Null', empno)
           || ','
           || CHR (10)
           || ''
           || DECODE (ename, NULL, 'Null', '''' || ename || '''')
           || ','
           || CHR (10)
           || ''
           || DECODE (job, NULL, 'Null', '''' || job || '''')
           || ','
           || CHR (10)
           || ''
           || DECODE (mgr, NULL, 'Null', mgr)
           || ','
           || CHR (10)
           || ''
           || DECODE (hiredate,
                      NULL, 'Null',
                         'to_date('''
                      || TO_CHAR (hiredate, 'mm/dd/yyyy hh24:mi')
                      || ''',''mm/dd/yyyy hh24:mi'')'
           || ','
           || CHR (10)
           || ''
           || DECODE (sal, NULL, 'Null', sal)
           || ','
           || CHR (10)
           || ''
           || DECODE (comm, NULL, 'Null', comm)
           || ','
           || CHR (10)
           || ''
           || DECODE (deptno, NULL, 'Null', deptno)
           || ');'
      FROM emp;
    SELECT '-- commit;'
      FROM DUAL;now run the baove select statement you will get the following insert statements
    /* Formatted on 2012/01/16 10:57 (Formatter Plus v4.8.8) */
    --'INSERT INTO EMP('||CHR(10)||'EMPNO,'||CHR(10)||'ENAME,'||CHR(10)||'JOB,'||CHR(10)||'MGR,'||CHR(10)||'HIREDATE,'||CHR(10)||'SAL,'||CHR(10)||'COMM,'||CHR(10)||'DEPTNO)VALUES('||DECODE(EMPNO,NULL,'NULL',EMPNO)||','||CHR(10)||''||DECODE(ENAME,NULL,'NULL',''''|
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7369, 'SMITH', 'CLERK', 7902,
                 TO_DATE ('12/17/1980 00:00', 'mm/dd/yyyy hh24:mi'), 800, NULL, 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7499, 'ALLEN', 'SALESMAN', 7698,
                 TO_DATE ('02/20/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1600, 300, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7521, 'WARD', 'SALESMAN', 7698,
                 TO_DATE ('02/22/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 500, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7566, 'JONES', 'MANAGER', 7839,
                 TO_DATE ('04/02/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2975, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7654, 'MARTIN', 'SALESMAN', 7698,
                 TO_DATE ('09/28/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 1400,
                 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7698, 'BLAKE', 'MANAGER', 7839,
                 TO_DATE ('05/01/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2850, NULL,
                 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7782, 'CLARK', 'MANAGER', 7839,
                 TO_DATE ('06/09/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2450, NULL,
                 10
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7788, 'SCOTT', 'ANALYST', 7566,
                 TO_DATE ('04/19/1987 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7839, 'KING', 'PRESIDENT', NULL,
                 TO_DATE ('11/17/1981 00:00', 'mm/dd/yyyy hh24:mi'), 5000, NULL,
                 10
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7844, 'TURNER', 'SALESMAN', 7698,
                 TO_DATE ('09/08/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1500, 0, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7876, 'ADAMS', 'CLERK', 7788,
                 TO_DATE ('05/23/1987 00:00', 'mm/dd/yyyy hh24:mi'), 1100, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7900, 'JAMES', 'CLERK', 7698,
                 TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 950, NULL, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7902, 'FORD', 'ANALYST', 7566,
                 TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7934, 'MILLER', 'CLERK', 7782,
                 TO_DATE ('01/23/1982 00:00', 'mm/dd/yyyy hh24:mi'), 1300, NULL,
                 10
                );i hope this helps .
    Thanks,
    P Prakash
    Edited by: prakash on Jan 15, 2012 9:21 PM
    Edited by: prakash on Jan 15, 2012 9:22 PM

  • How to generate custom report with PDF output?(Payables)

    Hi All,
    we are using some custom reports in payables modual production server the reports are working fine .
    my question is i need creat same reports in test server i have done following activities.
    1. copied rdf file from prod server and pasted into test server
    2.given excutable name in system administrator modual(concurrent-progrem-excutable)
    3.define report in system administrator modual(cocurrent-program-define) output selected PDF and given parameters.
    4. switch to payables moduale run the report ,following error showing in log file plese help how to resolve it we don,t have any custom reports in test server this is first time to creat the report.
    APPLLCSP Environment Variable set to :
    XML_REPORTS_XENVIRONMENT is :
    /APPS/dkvuatora/8.0.6/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
    XENVIRONMENT is set to: /APPS/dkvuatora/8.0.6/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
    Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :
    American_America.UTF8
    Spawned Process 2707514
    X connection to oraclefinof1:0.0 broken (explicit kill or server shutdown).
    Report Builder: Release 6.0.8.25.0 - Production on Wed Nov 18 16:06:17 2009
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    Enter Username:
    Start of log messages from FND_FILE
    End of log messages from FND_FILE
    Program exited with status 1
    Concurrent Manager encountered an error while running Oracle*Report for your concurrent request 339487.
    Review your concurrent request log and/or report output file for more detailed information.
    Executing request completion options...
    Finished executing request completion options.
    Concurrent request completed
    Current system time is 19-NOV-2009 16:24:52
    ---------------------------------------------------------------------------

    Hello.
    Have a look to Metalink Doc ID 252715.1
    You have to login to server and issue the 'xhost +' command.
    Hope this helps.
    Octavio

Maybe you are looking for

  • Can not save dashboard after copying to another location

    Hi All, I am moving a dashboard to another location and trying to make some changes but when I click on save button nothing happens, "Saving" text appears, page busy gif appears, thats all. I've waited long enough but no change. This occurs only on o

  • ADF BC View object with invalid character in column names

    Hello I Have a table with columns containing # character , for example ORDER# , When i create the read only view object j developer automatically renames this to order, but when i try to sort on that column or try search (filter) i get error that col

  • Oracle 11.2 and VPD

    Dear all i have database on oracle 10.2 some table contain VPD , i move this schema to oracle 11.2 and define all context and polices , but when i run select agents these table i have this error ora-3113 and ora-3114 why this happen? any explained fo

  • Reversal is only possible after CO month end closing

    I am getting the error Reversal is only possible after CO month end closing while doing partial or full confirmation. I had already checked the OKP1 the period is open. Also in MMRV it is fine. Please suggest what could be the reason for this error.

  • Please answer!

    Im sorry to ask again but i didnt get the right answer i was looking for so here goes again for the people who have the iphone 5s gold when yall got it did yall get it scratched or anything right out of the box just a question ?