Creating tabs in excel using pl sql

below is the procedure that i have written...
i am currently spooling all the data into a single worsheet....
i want to put data in seperate worksheets in the same excel files....
how wud i go abt doing that?
SELECT to_char(sysdate, 'DD-Mon-YYYY') today
FROM dual;
define spoolid= &xtoday
DEFINE ext =.csv
define outfile=d:\utility\DailyReport-&spoolid&ext
spool &outfile
-- Creating the Application input file records
SELECT 'COLUMN_NAME,DATA_TYPE,NULLABLE,DATA_DEFAULT,COLUMN_ID,CONSTRAINTS,COMMENTS'
FROM dual;
DECLARE
n_moduleid number;
CURSOR Cur_TableNames(mId number) IS
SELECT STRTABLENAME
FROM MODULE_DATA
WHERE NMODULEID = n_moduleid;
rt_tbnames MODULE_DATA.STRTABLENAME%type;
CURSOR Cur_TableData(Tbname MODULE_DATA.STRTABLENAME%type) IS
SELECT a.COLUMN_NAME||','||
a.DATA_TYPE || decode(a.DATA_TYPE,
'NUMBER',
'(' || a.DATA_PRECISION ||
DECODE(a.DATA_SCALE, 0, '', ',' || a.DATA_SCALE) || ')',
'DATE',
'(' || a.DATA_LENGTH || ')') ||','||
Decode(a.NULLABLE, 'Y', 'Yes', 'No') data1,
a.DATA_DEFAULT data2,
to_char(a.COLUMN_ID)||','||
''||','||
b.COMMENTS data3
FROM user_tab_columns a, user_col_comments b
WHERE a.TABLE_NAME = Tbname
AND a.TABLE_NAME = b.TABLE_NAME
ANd a.COLUMN_NAME = b.COLUMN_NAME
ORDER BY a.COLUMN_ID;
rt_tbdata Cur_TableData%ROWTYPE;
BEGIN
SELECT NMODULEID
INTO n_moduleid
FROM MODULE
WHERE STRMODULENAME = 'MOVEMENT';
--dbms_output.put_line(n_moduleid);
OPEN Cur_TableNames(n_moduleid);
LOOP
FETCH Cur_TableNames INTO rt_tbnames;
EXIT WHEN Cur_TableNames%NOTFOUND;
my_dbms_output.put_line(rt_tbnames);
my_dbms_output.put_line('');
FOR rt_tbdata in Cur_TableData(rt_tbnames)
LOOP
my_dbms_output.put_line(rt_tbdata.data1||','||rt_tbdata.data2||','||rt_tbdata.data3);
END LOOP;
my_dbms_output.put_line('');
END LOOP;
CLOSE Cur_TableNames;
END;
select text from my_dbms_output_view;
SPOOL OFF;

You may have to use VBA to split data up into separate tabs.
Or put multiple CSV files together into a single workbook -- again with VBA.

Similar Messages

  • Create Output to Excel from PL/SQL

    I've created a procedure that generates an excel output. The output is generated if the number of rows are less than 850. If more than 850, I received a "Page Not Found" error.
    I used Note:132262.1 "How to Create Output to Excel from PL/SQL".
    Does anybody know a fix or workaround for this issue?

    It might be worth your time to check out owa_sylk from asktom.oracle.com. It's a pl/sql package that generates SYLK files, which Excel can then open. By using a standard file format instead of a proprietary one you get away from most of the "which version of Excel" issues.
    Scott

  • Create Categories or Perspectives using PL/SQL?

    Hi
    Can you create Categories or Perspectives using PL/SQL?
    I have had a look at the API's section on here but I cant seem to find anything.
    Is it just a simple as adding it to the table?
    Thanx
    Craig

    Here's what I run:
    I ran the query you provided above and here are the results:
    UNLIMITED TABLESPACE
    CREATE TABLE
    Here are the commands I run:
    CREATE TABLE TEST_TABLE AS SELECT * FROM DUAL;CREATE TABLE succeeded.
    DROP TABLE TEST_TABLE;DROP TABLE TEST_TABLE succeeded.
    CREATE PROCEDURE TEST_PROC IS
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE TEST_TABLE AS SELECT * FROM DUAL';
    END TEST_PROC;PROCEDURE TEST_PROC Compiled.
    EXEC TEST_PROC; Error starting at line 1 in command:
    EXEC TEST_PROC;
    Error report:
    ORA-01031: insufficient privileges
    ORA-06512: at , line 4
    ORA-06512: at line 1
    01031. 00000 - "insufficient privileges"
    *Cause:    An attempt was made to change the current username or password
    without the appropriate privilege. This error also occurs if
    attempting to install a database without the necessary operating
    system privileges.
    When Trusted Oracle is configure in DBMS MAC, this error may occur
    if the user was granted the necessary privilege at a higher label
    than the current login.
    *Action:   Ask the database administrator to perform the operation or grant
    the required privileges.
    For Trusted Oracle users getting this error although granted the
    the appropriate privilege at a higher label, ask the database
    administrator to regrant the privilege at the appropriate label.
    Does this mean I need the CREATE ANY TABLE priv?
    Thanks again everyone!
    -Joe
    Edited by: Joe Bertram on Dec 2, 2009 12:07 PM

  • Creating a text file using pl/sql

    how can one create a text file using pl/sql?
    Say for example abcd.txt in the d: drive
    (d:\abcd.txt)
    on a windows nt server

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by bhrigu nagal ([email protected]):
    thanks for your replies
    I had already set the utl_file_dir parameter
    I tried the utl package and wrote the following code but got some errors
    declare
    filehandler UTL_FILE.FILE_TYPE;
    begin
    filehandler:=UTL_FILE.fopen('d:/intel/','myfile.txt','w');
    utl_file.put_line(filehandler,'look masjdfgsd\n');
    utl_file.fclose(filehandler);
    exception when utl_file.invalid_path then
    raise_application_error(-20023,'bhrigu ,chk the path');
    end;
    the errors
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "SYS.UTL_FILE", line 101
    ORA-06512: at "SYS.UTL_FILE", line 157
    ORA-06512: at line 4
    if u know what this is please tell me
    thanks bhrigu
    <HR></BLOCKQUOTE>
    U need :
    1) To have UTL_FILE_DIR param in the init file of the instance with the same directory (don't forget to stop and restart the base)
    2) Handled the exceptions listed in the utl_file package (Oracle_home\rdbms\admin\utlfile.sql) in your source.
    3) Turn set serveroutput on in SQL*Plus.
    Run your procedure and see the error message to debug.
    Good luck
    null

  • How do i create TABs page dynamically using htmldb

    Hi,
    I want to create tab page using htmldb app. Using wizard it does not allow me to create tab through sql query. Is there any other option to do this?
    Please Help.
    Regards
    Vishal

    You might try to create a bunch of Tabs (static) and set shown condition to a variable controlled dynamically. Sort of semi-dynamical Tab, which I actually use but don't know it fit your need or not.
    DC

  • Export Data to Excel using PL/SQL

    Hello.....
    Can anyone tell me of a straight-forward way to export a result set to an excel file using PL/SQL?
    Thanks,
    Christine

    my oracle DB is on unix box and i created that directory on unix server...
    SQL> select directory_path from all_directories where directory_name = 'SERVER_PATHWAY_FILES_LOCATION1';
    DIRECTORY_PATH
    /d02/oradata/CSV_Files
    SQL> [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to Export data from a Table to Excel using PL/SQL Code

    Hi,
    I need to export data from a table to the excel sheet using PL/SQL script.
    could you pls provide with custom codes or sample procedures.
    Bobby

    http://asktom.oracle.com/pls/ask/f?p=4950:8:7947129213057862756::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:728625409049

  • Can't create an MBO object using an SQL Server connection profile

    Hi all,
    I'm trying to create an MBO from an table using an SQL Server connection profile. The connection is fine but when i grag a table into Mobile Application Diagram in order to create an MBO i got the following exeption:
    I´ve already configured the necessary jar (sqljdbc4.jar) in the following directories:
    C:\Sybase\UnwiredPlatform\Servers\UnwiredServer\lib
    C:\Sybase\UnwiredPlatform\Unwired_WorkSpace\Eclipse\sybase_workspace\mobile\eclipse\plugins\com.sybase.uep.com.sqlserver_2.1.0.201109131337
    but i always get the same error.
    Any help, suggest would be apreciated
    thx,
    Nuno

    Hi Nuno,
    I just wanted you to verify the path where you have pasted JAR file. As you mentioned
    Path 1:
    C:\Sybase\UnwiredPlatform\Servers\UnwiredServer\lib
    but as per doc it should be under:
    C:\Sybase\UnwiredPlatform\Servers\UnwiredServer\lib\3rdparty
    Path 2:
    C:\Sybase\UnwiredPlatform\Unwired_WorkSpace\Eclipse\sybase_workspace\mobile\eclipse\plugins\com.sybase.uep.com.sqlserver_2.1.0.201109131337
    but as per doc it should be under:
    C:\Sybase\UnwiredPlatform\Unwired_WorkSpace\Eclipse\sybase_workspace\mobile\eclipse\plugins\com.sybase.uep.com.sqlserver_2.1.0.201109131337\lib
    Rgrds,
    JK

  • Exporting Cross-Tab to Excel using RAS 9.0 - incorrect and data loss

    Hello,
    Hope somone can help to solve the following issue.
    Develop a cross-tab report using Crystal Report Developer 9.0. service pack 5 or above.
    (1). Viewing in Crystal Report - no problem - all rows and columns displayed correctly.
    (2). Export to Excel using Crystal Report - no problem - all rows and columns exported correctly.
    (3). Viewing in RAS 9.0 - no problem, all rows and columns displayed correctly.
    (4). Export to Excel using RAS 9.0 - problem - only one or two rows with last rows are exported but wrong data. Most columns are not exported.  Seems like exporting errors.
    RAS 9.0 was patched with hotfix 200603 and service pack 5.
    Please help or is there any hotfix or service pack that resolved this problem?  As developer, we can use crystal report for exporting but for users, their only choice is through RAS.
    Thank you very much!

    Please re-post if this is still an issue to the .NET Development - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly

  • Creating reports on Excel using java

    Does anyone have any idea on how to use java in creating reports on excel?
    Tnx in advance.

    1. Create a CSV(comma seperated values) file that can be opened in Excel.
    2. Create an HTML file that can be opened by excel.
    3. Use some COM bridge like: http://danadler.com/jacob/

  • How to create dynamic HTML page using PL/SQL code in APEX.

    hello,
    I am woking on one APEX application in which i want to create one dynamic HTML page on button press using PL/SQL code.
    Thanks

    It is possible to create HTML page with dynamic content. One way would be creating hidden field (e.g. P1_HTML on page 1) with dynamic HTML and on button click you redirect to page 2 and pass P1_HTML item value to item P2_HTML on page 2. On page you must have PL/SQL region. You can then render your dynamic HTML with code:
    htp.p(:P2_HTML);
    Don use APEX URL for passing HTML value. Problem and solution is described here: http://blog.trent-schafer.com/2011/04/03/dont-pass-string-parameters-in-the-url-in-apex-its-a-bad-idea/
    Edited by: MiroMas on 3.2.2012 3:20

  • Want to create Ineractive report by using pl/sql block

    Hi,
    But If have to read different informations for different tables, how can I do ?
    For example:
    for s in (SELECT srv_sys_name,ddb_dbname
    FROM search_master
    WHERE ( ddb_dbname like '%'||:p7_ddb_dbname||'%' AND :p7_ddb_dbname IS NOT NULL ))
    loop
    apex_collection.add_member(p7_col, s.srv_sys_name, s.ddb_dbname );
    end loop;
    If I have an other table to look to get other informations, i don't know what to do ?
    It's my problem for now.
    Thanks in advance. Bye.

    HTML_DB 1.6 + Apex 4.0 + Hyperion user wrote:
    But If have to read different informations for different tables, how can I do ?
    For example:
    for s in (SELECT srv_sys_name,ddb_dbname
    FROM search_master
    WHERE ( ddb_dbname like '%'||:p7_ddb_dbname||'%' AND :p7_ddb_dbname IS NOT NULL ))
    loop
    apex_collection.add_member(p7_col, s.srv_sys_name, s.ddb_dbname );
    end loop;If I have an other table to look to get other informations, i don't know what to do ?Generally, perform a join combining the tables.
    Additionally, creating collections row-by-row is horribly inefficient. Use the <tt>APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B</tt> bulk methods instead.
    However in this case the the PL/SQL and collection-based approach is unnecessary. Base the IR on the query (plus joins to whatever other tables are necessary):
    select srv_sys_name,ddb_dbname
    from search_master
    where ddb_dbname like :p7_ddb_dbname_qryand compute hidden item <tt>p7_ddb_dbname_qry</tt> to include the value of <tt>p7_ddb_dbname</tt> and wildcard characters as required.
    Finally, note that <tt>LIKE</tt> searches using leading-edge wildcards on large data sets can be inefficient as this eliminates the possibility of using indexes on the searched column.
    (Always post code wrapped in tags<tt>\...\</tt> tags to preserve formatting and special characters.)

  • HOW CAN I ADD NEW WORKSHEET(TAB) TO EXCEL USING ABAP pROGRAM?

    i want to add new tabs to my excel file using abap.... can someone help me on this?

    hi,
    PERFORM add_worksheet USING 'Test 1'.
    *& Form ADD_WORKSHEET
    FORM add_worksheet USING i_name.
    Add new worksheet
      IF g_first_ws <> 'N'.
        g_first_ws = 'N'.
        GET PROPERTY OF g_excel 'ACTIVESHEET' = g_worksheet.
      ELSE.
        CALL METHOD OF g_worksheets 'Add' = g_worksheet.
      ENDIF.
      SET PROPERTY OF g_worksheet 'NAME' = i_name.
      g_row = 1.
      g_col = 1.
    ENDFORM. " ADD_WORKSHEET

  • Create OS filesystem Directory Using Apex, SQL commands of SQL worshop

    I am using Apex 3.0, Oracle Database 10g and IE 6.5
    Code Here:
    Create or replace Directory 'Data_Dir' as 'C:\temp\'
    Error Message:
    Insufficient Priveleges
    This code runs fine when I access server remotely. Our projec team has no APex experience. our workspace administrator does not know how to grant appropriate privileges to my user accounts.
    Please provide us step by step help immediately on 'How to create OS Directory from APEX'.
    Thank you very much.

    Please provide us step by step help immediately on 'How to create OS Directory from APEX'.Please bear in mind that most people in this forum are doing it in their own time, without any financial gain from it. If you have an urgent support issue that is critical to your business and you want it answered immediately you should contact Oracle support, otherwise remember that you may need to wait some time for someone to answer your question here (especially considering it's the weekend).
    However, in answer to your question, yes your DBA will need to grant 'create directory' or 'create any directory' to the user you've specified. If you're saying it runs fine when you access the server remotely (I'm assuming you mean via SQLPlus etc), that probably suggests your DBA has granted the right via a role which won't work while connected in the APEX environment (you will need to explicitly grant the permission to the user).
    Hope this helps.

  • Create a Multiple Files using PL-SQL

    Hi Experts,
    I have a table which contains 360 records and want to create multiple files with each file containing 12 records.
    I tried to use the below code, however was unsuccessfull..
    Please help!!!!
    DECLARE
       num      NUMBER             := 1;
       f_file   UTL_FILE.file_type;
       row_sm   NUMBER             := 0.00;
    CURSOR c_cur
       IS
          SELECT   customer_key, all_columns_concat
              FROM demo;
    c_rec    c_cur%ROWTYPE;
    BEGIN
       OPEN c_cur;
       LOOP
          FETCH c_cur
           INTO c_rec;
         EXIT WHEN c_cur%NOTFOUND;
          WHILE num = c_rec.file_num
          LOOP
             f_file := UTL_FILE.fopen ('DM_DIR', 'FILE_' || num, 'w', 3267);
             num := num + 1;
          END LOOP;
          UTL_FILE.put_line (f_file, c_rec.all_columns_concat);
          row_sm := c_rec.sum_row + row_sm;
       END LOOP;
       UTL_FILE.fclose (f_file);
      CLOSE c_cur;
    END;
    Regards,
    RaviR.

    Thanks Ramin,
    Your Code really helped. I am now not getting no errors and files are also being created. However, if I replace the UTL_FILE with DBMS_OUTPUT, I get below output. In your code i replaced 12 with 3. Hence its dividing after 3 rows. (with 1st row duplicated)
    Output
    1
    1
    2
    3
    ========================================
    4
    4
    5
    6
    ========================================
    7
    7
    8
    9
    ========================================
    10
    10
    11
    12
    ========================================
    13
    13
    14
    15
    ========================================
    16
    16
    Now my concern is that i my table I have a flag which determines the seperation...
    Column1
    File_Num
    1
    1
    2
    1
    3
    1
    4
    2
    5
    2
    6
    2
    7
    3
    8
    3
    9
    3
    10
    3
    11
    3
    Hence if the file_Num is 1 it will go to File1, file_num=2 will be written to File2 and so on.
    Please help me to get this logic.
    Thanks in advance.
    Regards,
    RaviR

Maybe you are looking for