SQL TABLE FORMATING - HELP!!!!

I've retrieving a set of data and need to add a blank line under the results then sum the total of one calculated column. Can anyone tell me how to add a blank line at the end of a query???

Hi
For 8i or +...
Example: select owner, count(*) from all_objects group by rollup (owner)

Similar Messages

  • SQL String formatting - help

    I have a simple sql statement that works (in my case, returns 28 rows).
    select columna,
    columnb
    from table
    where columnb in ('Value1','Value2')
    Next, I can do something like:
    select ''''||replace('Value1,Value2',',',''',''')||'''' from dual and it returns a string:
    (''''||REPLACE('VALUE1,VALUE2',',',''',''')||'''')
    'Value1','Value2'
    What I would like to do, is combine the two statements because the "in" statement will depend on a comma separated value list that the user will supply (which is why I'm trying to format it as an "in" statement would be formatted)
    I've tried:
    select columna,
    columnb
    from table
    where columnb in (select ''''||replace('Value1,Value2',',',''',''')||'''' from dual);
    This SQL statement returns 0 rows instead of my 28 that I think I should get. What am I doing wrong?

    You may want to use Dynamic SQL, since the "in" list needs to be built each time:
    SQL> var cr refcursor
    SQL>
    SQL> declare
    2 v_first_char varchar2(100);
    3 v_qry varchar2(1000);
    4 begin
    5 v_first_char := ''''||replace('&first_char',',',''',''')||'''';
    6 v_qry := 'select empno,ename from emp where substr(ename,1,1) in ('||v_first_char||')';
    7 open :cr for v_qry;
    8 end;
    9 /
    Enter value for first_char: A
    PL/SQL procedure successfully completed.
    SQL> print cr
    EMPNO ENAME
    7499 ALLEN
    7876 ADAMS
    SQL>
    SQL> /
    Enter value for first_char: A,J
    PL/SQL procedure successfully completed.
    SQL> print cr
    EMPNO ENAME
    7499 ALLEN
    7566 JONES
    7876 ADAMS
    7900 JAMES
    SQL>
    SQL>

  • Numbers - Printing Table Formatting Help?

    For the past few months, I've been transitioning my MS Office Access databases over to Numbers on my new MBPro - one database is 'Wine Recommendations' which I keep tract of possible purchases from several publications that I receive - the attached screen capture shows the top first page converted into Numbers.
    In Access, I was able to eliminate 'duplicate' printing of the same entries in the columns desired, e.g. under 'Origin', the first Au-NZ printed but not the same following ones; in 'Type' the grapes first appearance would print but not the identical names below (same for the 'Year'). I've figured out out to do repetitive sorts on those 3 columns, but cannot find a way to eliminate 'duplicate' printing of the same entries.
    So, is this possible in Numbers? Thanks for comments & suggestions. Dave

    Hi Dave,
    A fellow Access user (refugee?) in these parts!  Filemaker is good for this, of course. But here is quite an easy spreadsheet hack to achieve the effect. No fiddling with database report writing or grappling with advanced functions in reference manuals. I've used this in Excel and it ports quite well to Numbers.
    The basic idea: Insert "display" columns to the left of your original data, each filled with a simple formula that shows "a blank" if it sees a "duplicate" or the value if it's a "new" value. When you want to view or print your data just "hide" the original columns with repeating values that you want to suppress. When you need your "full table" back (to sort, filter, whatever) unhide those original columns.
    Here you need three new columns and a short formula in each. That's about it.
    First, insert three columns to the left of your original data.
    Then add the three formulas. I'll start with the formula in column B, because it's the basic "duplicate" killer.
    In B4 enter this formula, filled down:
    =IF(E4=E3,"",E4)
    All this does is show a "blank" if it sees that the value in this row of column E (Type) is the same as the value on the previous row (i.e. it's a "duplicate"). Otherwise it shows the value it finds in column E.
    In column A4 enter this formula, filled down:
    =IF(B4<>"",D4,"")
    This shows what's in column D if there is something in column B; otherwise it shows a "blank"...This seems to be what you wanted in your example. If you want Origin to show only once then you would have =IF(D4=D3,"",D4), exactly the same pattern as in B.
    And in C3 insert a slightly more complicated formula, filled down:
    =IF(AND(F4=F3,B4=""),"",F4)
    This shows a "blank" if the value in column F (Year) is the same as in the previous row AND there is nothing in column B. Otherwise it shows the value it finds in column F on that row.
    Now, when you want to print or view your data, just hide columns D, E, and F.
    If you've got lots rows to view on screen, you may want to freeze the header rows.
    Unhide the columns when you need the "full table" to sort/resort, etc.
    You can sort, etc. in the Reorganize Panel:
    Final notes:
    -- Numbers (unlike Excel) sometimes "scrambles" the formula row references after sorting/resorting. If that happens, just copy/paste A4:C4 from a backup table into row 4 and fill down and all will be well again.
    -- And probably best not to used merged cells, even in the header. Merged cells look nice, but cause unexpected problems.
    Not fancy. Probably more elegant ways. But it gets the job done in a spreadsheet without much fuss.
    SG

  • PL/SQL TABLE AS OUT ON PROCEDURE CALL AND JDBCTHIN(NEED HELP

    How can I pass pl/sql record in and out
    and pl/sql tables in out thru a pl/sql procedure using jdbc with
    the zip file of 816classes12.zip...
    I have tried everything I know...
    I know the procedure is working, others are using it with in
    Oracle...
    I need to use the information it generates.
    here is what I have so far...
    try
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
    oracle.jdbc.driver.OracleConnection conn =
    (oracle.jdbc.driver.OracleConnection)
    DriverManager.getConnection ("jdbc:oracle:thin:@--","NA","NA");
    // SQL92 SyntaxCallableStatement
    oracle.jdbc.driver.OracleCallableStatement cstmt =
    (oracle.jdbc.driver.OracleCallableStatement)conn.prepareCall
    ("{call cbmd_proposal_PKG.DefaultTerms (?,?,?,?)}" ) ;
    cstmt.setString(1,"5118");
    cstmt.setString(2,"3");
    cstmt.registerOutParameter
    (2,oracle.jdbc.driver.OracleTypes.NUMBER);
    cstmt.registerOutParameter
    (1,oracle.jdbc.driver.OracleTypes.ARRAY,"");
    cstmt.execute();
    catch(Exception e)
    System.err.println(e.toString());
    e.printStackTrace();
    null

    The "X" in the second registerOutParameter is the type name which
    you have created in oracle DB.
    eg. if you have created a nested table
    create Type integer_table is table of number(10);
    then "X" = "INTEGER_TABLE" and it has to be in caps
    and other thing to keep in mind is that it only works with nested
    table or varray and not with pl/sql table.
    Al Pivonka (guest) wrote:
    : How can I pass pl/sql record in and out
    : and pl/sql tables in out thru a pl/sql procedure using jdbc
    with
    : the zip file of 816classes12.zip...
    : I have tried everything I know...
    : I know the procedure is working, others are using it with in
    : Oracle...
    : I need to use the information it generates.
    : here is what I have so far...
    : try
    : Class.forName ("oracle.jdbc.driver.OracleDriver");
    : DriverManager.registerDriver (new
    : oracle.jdbc.driver.OracleDriver());
    : oracle.jdbc.driver.OracleConnection conn =
    : (oracle.jdbc.driver.OracleConnection
    : DriverManager.getConnection
    ("jdbc:oracle:thin:@--","NA","NA");
    : // SQL92 SyntaxCallableStatement
    : oracle.jdbc.driver.OracleCallableStatement cstmt =
    : (oracle.jdbc.driver.OracleCallableStatement)conn.prepareCall
    : ("{call cbmd_proposal_PKG.DefaultTerms (?,?,?,?)}" ) ;
    : cstmt.setString(1,"5118");
    : cstmt.setString(2,"3");
    : cstmt.registerOutParameter
    : (2,oracle.jdbc.driver.OracleTypes.NUMBER);
    : cstmt.registerOutParameter
    (1,oracle.jdbc.driver.OracleTypes.ARRAY,"X");
    : cstmt.execute();
    : catch(Exception e)
    : System.err.println(e.toString());
    : e.printStackTrace();
    : The "X" in the second registerOutParameter is still unknown to
    : me.
    : The JavaDoc for the
    OracleCallableStatement.registerOutParameter
    : is not clear.
    : Can any One help simplify this...
    : Thanks
    null

  • HELP! Displaying results from a database in table format

    I'm developing a web application that will use a considerable number of database queries that need to be displayed back to the web-browser in HTML table format.
    I have been told that that result sets can allow tables to be built automatically without having to write the same loop and display code over and over.
    So far I have a HtmlResultSet class as follows:
    import java.sql.*;
    public class HtmlResultSet {
    private ResultSet rs;
    public HtmlResultSet(ResultSet rs) {
    this.rs = rs;
    public String toString() {  // can be called at most once
    StringBuffer out = new StringBuffer();
    // Start a table to display the result set
    out.append("<TABLE>\n");
    try {
    ResultSetMetaData rsmd = rs.getMetaData();
    int numcols = rsmd.getColumnCount();
    // Title the table with the result set's column labels
    out.append("<TR>");
    for (int i = 1; i <= numcols; i++) {
    out.append("<TH>" + rsmd.getColumnLabel(i));
    out.append("</TR>\n");
    while(rs.next()) {
    out.append("<TR>"); // start a new row
    for (int i = 1; i <= numcols; i++) {
    out.append("<TD>"); // start a new data element
    Object obj = rs.getObject(i);
    if (obj != null)
    out.append(obj.toString());
    else
    out.append(" ");
    out.append("</TR>\n");
    // End the table
    out.append("</TABLE>\n");
    catch (SQLException e) {
    out.append("</TABLE><H1>ERROR:</H1> " + e.getMessage() + "\n");
    return out.toString();
    I also have created a class that includes an instance of the class above to display the results, as follows:
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class customerLookup2 {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try{
    Class.forName("org.gjt.mm.mysql.Driver");
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sandywalker");
    out.println("<html>");
    out.println("<head><title> Users</title></head>");
    out.println("<body> Customers");
    HtmlResultSet result = new HtmlResultSet ("SELECT * FROM USERS");
    out.println("</body></html>");
    catch(ClassNotFoundException e ) {
    out.println("Couldn't load database driver: " + e.getMessage());
    catch(SQLException e) {
    out.println("SQLExeption caught: " +e.getMessage());
    finally {
    try {
    if (con !=null) con.close();
    catch (SQLException ignored) { }
    I keep getting a compile error "customerLookup2.java": Error #: 300 : constructor HtmlResultSet(java.lang.String, java.sql.Connection) not found in class HtmlResultSet at line 42, column 34".
    Can anyone shed any light on this.

    Looks like you are passing a string (SELECT * FROM USERS) instead of passing a ResultSet. Try passing a Resultset.

  • Need to format a vpn log text file into a format that can be written directly to a SQL table

    I am trying to do two thing inside of powershell
    1. Take a vpnlog text file  "C:\temp\ps3\vpnlogs\testlog.txt" formatted as such and be able to directly add the columns to a sql table
    "Number" "Date" "Time" "Interface" "Origin" "Type" "Action" "Service" "Source Port" "Source" "Destination" "Protocol" "Rule"
    "Rule Name" "Current Rule Number" "User" "Information" "Product" "Source Machine Name" "Source User Name"
    "291" "29Nov2013" "23:59:00" "" "A*****" "Log" "Log In" "" "" "111.*.*.* " "A*****" "" "" "" "" "pet*******"
    "VPN internal source IP: 192.*.*.*; reason: disconnected from gateway" "Security Gateway/Management" "" ""
    2. Remove the empty colums in this text file so that I can then find a way to upload only colums that have a column name directly up to the sql table via a powershell script .
    SO basically import txt file format it into colums that have data that can then be directly written to a sql table without me having to manually create the columns in the table. if this worked correctly the sql table would be uploaded with the colums and
    data from sql.
    I can do the upload portion with the below listed powershell command however when I import the following file into powershell I have to manually import the testlog.txt into excel then save as a csv to upload... not to mention I had to
    manually create the columns in the sql table so that it imports correctly.
    get-content "C:\temp\ps3\vpnlogs\testlog.txt" I can not get the data to format correctly without manually importing it into the logfiledata.csv.
    $dt=Import-Csv-Path"C:\temp\ps3\vpnlogs\logfiledata.csv"|Out-DataTable
    Write-DataTable -ServerInstance"myserver"-Database"mydata"-TableName"dbo.VPNLOGS"-Data$dt
    I also have tried this to format the text file but it's not working the way I thought it should, but I don't want to have to create the .CSV file if I can avoid it I would rather take the data in powershell formatted and use the colums to
    get-content"C:\temp\ps3\vpnlogs\testlog.txt"|Foreach-Object{
    ($_ 
    -replace'"',',')
    } |Set-Content"C:\temp\ps3\vpnlogs\testlog2.csv"
    | Import-Csv
    "C:\temp\ps3\vpnlogs\testlog2.csv"|selectNumber,date,time,interface,origin,type,action,service,"source
    port",source,destination,protocol,rule,"rule
    name","current
    rule number",user,information,product,"source
    machine name","source
    user name"
    "Number" "Date" "Time" "Interface" "Origin" "Type" "Action"
    "Service" "Source Port" "Source" "Destination" "Protocol" "Rule" "Rule Na
    me" "Current Rule Number" "User" "Information" "Product" "Source Machine Name" "Source User Name"
    "473" "4Dec2013" "23:59:01" "" "AAMESXF604" "Log" "Log In" "" "" "ip72-198-30-53.ok.ok.cox.net" "AAMESXF604" "" "" ""
    "" "usthompst"

    Thank you Mjolinor this seems to have given me a good output, now do you know of a method using the out-datable  and write-datatable that I can use to directly upload the objects and data. Really I do not want to have to create another file at this
    point I would like to take all of this info and now write it directly to my SQL-Table...
       TypeName: Selected.System.Management.Automation.PSCustomObject
    Name                MemberType   Definition                                                                                       
    Equals              Method       bool Equals(System.Object obj)                                                                   
    GetHashCode         Method       int GetHashCode()                                                                                
    GetType             Method       type GetType()                                                                                   
    ToString            Method       string ToString()                                                                                
    Action              NoteProperty System.String Action=Log In                                                                      
    Current Rule Number NoteProperty System.String Current Rule Number=                                                               
    Date                NoteProperty System.String Date=4Dec2013                                                                      
    Destination         NoteProperty System.String Destination=******                                                          
    Information         NoteProperty System.String Information=VPN internal source IP: *.*.*.*; reason: disconnected from gateway
    Interface           NoteProperty System.String Interface=                                                                         
    Number              NoteProperty System.String Number=473                                                                         
    Origin              NoteProperty System.String Origin=********                                                                  
    Product             NoteProperty System.String Product=Security Gateway/Management                                                
    Protocol            NoteProperty System.String Protocol=                                                                          
    Rule                NoteProperty System.String Rule=                                                                              
    Rule Name           NoteProperty System.String Rule Name=                                                                         
    Service             NoteProperty System.String Service=                                                                           
    Source              NoteProperty System.String Source=ip*-*-*-*.ok.ok.cox.net                                                
    Source Machine Name NoteProperty System.String Source Machine Name=                                                               
    Source Port         NoteProperty System.String Source Port=                                                                       
    Source User Name    NoteProperty System.String Source User Name=                                                                  
    Time                NoteProperty System.String Time=23:59:01                                                                      
    Type                NoteProperty System.String Type=Log                                                                           
    User                NoteProperty System.String User=*******  

  • Dynamically fetaching data into PL/SQL tables help

    Hi,
    I am develioping a PL/SQL procedure in which I am creatig 24 PL/SQL tables of the same type.
    But while inserting data in them I need to use the table names dynamically i.e., the Execute immediate used to put the data into the tables would remain same just I need that for each and every run of for loop for that Execute immediate statement, it should use different table name.
    Please see sample code below:
    col_name varchar2(20);
    Type RA_TABLE is table of CALL_DETAIL_EXCEPTION.IC_CIRCT_GR_CD%TYPE
    index by binary_integer;
    MY_RA1 RA_TABLE;
    MY_RA2 RA_TABLE;
    MY_RA3 RA_TABLE;
    MY_RA4 RA_TABLE;
    BEGIN
    for idx in 1..cnt_interval Loop
    Col_name := 'MY_RA'||idx;
    query1:='select Trunk_info bulk collect INTO MY_RA'|| idx ||' from dbl.vw_cgi v where not exists (select 1 from dbl.varun f
    where f.ic_circt_gr_cd= v.TRUNK_INFO and f.call_gmt_dnect_dt_time between
    to_date('''||stime||''',''yyyymmddhh24miss'') and to_date('''||etime||''',''yyyymmddhh24miss''))';
    Now when I execute this code, it gives me an error for query1 saying that it is unimplemented feature in Oracle.
    It is not able to pick up that dynamic table name.
    Please help!

    user9315951 wrote:
    I am develioping a PL/SQL procedure in which I am creatig 24 PL/SQL tables of the same type.All wrong. This is NOT how one treats data in PL/SQL.
    There is NO such concept as PL/SQL "+tables+". You are in fact defining associative arrays and not using these as associative arrays, but as normal arrays. Your code can consume vast amounts of server memory as private process memory. Your code CAN crash the Oracle database server (yes, I have seen this multiple times - even in production).
    Your code is flawed. Your approach is flawed.
    I suggest that you take several steps back, gain some understanding of fundamental Oracle concepts, about what does scale and perform in PL/SQL and SQL, and then apply these concepts and principles.

  • Table format problem - Please help

    Here is what I am trying to do:
    I have a set of documents in xml fomrat following the docbook standard.  In these documents there are too types of table.  The standard table with its element tag TABLE and an informal table with element tag INFORMALTABLE.
    When these are opened and my format file and EDD applied I want the Standard Tables to have a blue shaded header and the Informal Tables to have a grey shaded header.  I have created the appropriate table templates.  I cannot figure a way via the EDD to specify the table format type that works.  When I open an xml and apply the edd and the format all the tables open using the table format that is first in the list.
    What can I do to the EDD to achieve my goal?
    Thank you in advance

    Russ,
         Thanks for letting me know my messages were not getting through. I just replied to the original rather than going through the forums interfaces and had no idea there was a problem. I attempted to post twice on this thread today:
        The messages were:
    Russ,
       You are correct. An EDD can specify an initial table format. The word "initial" is key. It is the format that is used when a new table is created, whether the new table is created interactively by the user or by opening an SGML or XML document. Initial table formats do not affect existing tables. In fact, for a table created interactively, the initial table format determines the format that is highlighted when the Insert Table dialog first comes up. The user is free to choose another format if desired.
        and
    Qualar,
        R/w rules are not context sensitive so that if you are using a tgroup element within FM, they will not be able to help. The definition of tgroup in your EDD can set an initial table format of Format A if the tgroup is within the table element and Format B if the tgroup is within informaltable. Just make sure you have imported the EDD into the template before opening the XML document. As you've noticed, if you open the XML document and then import the EDD, the tables already exist and their format is not affected.
              --Lynne

  • Dynamic number of PL/SQL tables help!!!

    Hi,
    I have a PL/SQL code in which I am using PL/SQL table of tables.
    The number of such tables created in the code can be dynamic.
    At the end of the procedure I want to insert the records from those PL/SQL tables into a database table.
    Something like this.
    insert into DBL.RA_CONTROL_REPORT (time_slot1,time_slot2,time_slot3,time_slot4,time_slot5,time_slot6,time_slot7,
    time_slot8,time_slot9,time_slot10,time_slot11,time_slot12,time_slot13,time_slot14,time_slot15,time_slot16,
    time_slot17,time_slot18,time_slot19,time_slot20,time_slot21,time_slot22,time_slot23,time_slot24,time_slot25,
    time_slot26,time_slot27,time_slot28,time_slot29,time_slot30,time_slot31,time_slot32,time_slot33,time_slot34,
    time_slot35,time_slot36,time_slot37,time_slot38,time_slot39,time_slot40,time_slot41,time_slot42,time_slot43
    ,time_slot44,time_slot45,time_slot46,time_slot47,time_slot48)
    values ( Outer_table(1)(i),Outer_table(2)(i),Outer_table(3)(i),Outer_table(4)(i),Outer_table(5)(i)
    ,Outer_table(6)(i),Outer_table(7)(i),Outer_table(8)(i),Outer_table(9)(i),Outer_table(10)(i),Outer_table(11)(i)
    ,Outer_table(12)(i),Outer_table(13)(i),Outer_table(14)(i),Outer_table(15)(i),Outer_table(16)(i),Outer_table(17)(i)
    ,Outer_table(18)(i),Outer_table(19)(i),Outer_table(20)(i),Outer_table(21)(i),Outer_table(22)(i),Outer_table(23)(i)
    ,Outer_table(24)(i),Outer_table(25)(i),Outer_table(26)(i),Outer_table(27)(i),Outer_table(28)(i),Outer_table(29)(i)
    ,Outer_table(30)(i),Outer_table(31)(i),Outer_table(32)(i),Outer_table(33)(i),Outer_table(34)(i),Outer_table(35)(i)
    ,Outer_table(36)(i),Outer_table(37)(i),Outer_table(38)(i),Outer_table(39)(i),Outer_table(40)(i),Outer_table(41)(i)
    ,Outer_table(42)(i),Outer_table(43)(i),Outer_table(44)(i),Outer_table(45)(i),Outer_table(46)(i),Outer_table(47)(i)
    ,Outer_table(48)(i));
    Here, DBL.RA_CONTROL_REPORT is my database table.
    And each Outer_table()() is my PL/SQL table.
    I need to make this query dynamic by inserting only from those many number of PL/SQL tales which are created.
    Assume that I know the number of PL/SQL tables created.
    But when I try to do so, and apply execute immediate to that query. It gives me an error as unimplemented feature.
    Sample code where I have tried doing so is as follows:
    Query3:='insert into DBL.RA_CONTROL_REPORT (';
    for i in 1..max_cnt loop
    for idx in 1..Interval_Count loop
    col_name :=col_name||'time_slot'||idx||',';
    table_name :=table_name||'Outer_table('||idx||')('||i||'),';
    end loop;
    col_name:=rtrim(col_name,',');
    table_name:=rtrim(table_name,',');
    Query3:=Query3||col_name||') values('||table_name||')';
    dbms_output.put_line(query3);
    execute immediate query3;
    commit;
    end loop;
    Where max_cnt -> No of PL/SQL tables created.
    Please help.

    Now using the above approach to determine the bucket for a row, this result can be (outer) joined to the 48 buckets for the day and one can determine whether there are values for that bucket or not.
    For example:
    SQL> with MV as(
      2          select
      3                  trunc(sysdate)+(dbms_random.value(1,24)/24) as TIME,
      4                  trunc(dbms_random.value(1,100)) as B
      5          from    dual
      6          connect by level <= 1000
      7  ),
      8  DATA_BUCKETS as(
      9          select
    10                  time,
    11                  --// determine the decimal hour
    12                  (to_number(to_char(time,'hh24'))*60)
    13                  +to_number(to_char(time,'mi'))          as MINUTES,
    14                  --// use the decimal minute to determine
    15                  --// which half-hour bucket it goes into
    16                  trunc(  ((to_number(to_char(time,'hh24'))*60)+
    17                          +to_number(to_char(time,'mi')))
    18                          /30
    19                  )+1                                     as BUCKET,
    20                  b
    21          from    mv
    22  ),
    23  ACTUAL_BUCKETS as(
    24          select
    25                  level as BUCKET
    26          from    dual
    27          connect by level <= 48
    28  )
    29  select
    30          actual_buckets.bucket,
    31          sum(b),
    32          case    --// is there data in the data bucket?
    33                  when sum(data_buckets.b) is null then 'No'
    34          else
    35                  'Yes'
    36          end             as BUCKET_HAS_DATA
    37  from       actual_buckets,
    38          data_buckets
    39  where      actual_buckets.bucket = data_buckets.bucket (+)
    40  group by
    41          actual_buckets.bucket
    42  order by 1
    43  /
        BUCKET     SUM(B) BUCKET_HAS_DATA
             1            No
             2            No
             3       1321 Yes
             4       1582 Yes
             5       1409 Yes
             6        786 Yes
             7       1082 Yes
             8       1323 Yes
             9        998 Yes
            10       1462 Yes
            11        850 Yes
            12        947 Yes
            13       1033 Yes
            14       1224 Yes
            15        655 Yes
            16        810 Yes
            17       1319 Yes
            18        702 Yes
            19        994 Yes
            20        671 Yes
            21       1136 Yes
            22       1199 Yes
            23       1034 Yes
            24       1184 Yes
            25       1470 Yes
            26        890 Yes
            27       1549 Yes
            28        740 Yes
            29       1229 Yes
            30        833 Yes
            31       1159 Yes
            32       1613 Yes
            33       1234 Yes
            34        770 Yes
            35       1196 Yes
            36       1324 Yes
            37       1263 Yes
            38       1155 Yes
            39        785 Yes
            40       1130 Yes
            41       1286 Yes
            42       1056 Yes
            43       1462 Yes
            44       1032 Yes
            45        831 Yes
            46        888 Yes
            47        806 Yes
            48        995 Yes
    48 rows selected.
    SQL>I leave the pivot of this into a single row with 48 columns for you to research and figure out. I'm also pretty sure that other forum members can provide a lot more elegant examples than what I've done here.
    The point is that SQL is a very powerful and very capable data processing language. And if you want to build Oracle solutions that are robust and performant and scalable, then you need to Mamimise Maximise SQL and Minimise PL/SQL*.
    In other words - do not use PL/SQL when SQL can do the job better and faster.
    Edited by: Billy Verreynne on Sep 16, 2011 9:40 AM

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • Can anyone help me in a problem with PL/SQL Tables & the Java getArray()

    The problem is the following:
    I would tike to get a PL/SQL Table (a table of varchar2) into a Java String Array.
    It works very well except that instead of getting the characters in the PL/SQL Table
    I receive the character codes in each string.
    In the following example i should get:
    spring
    summer
    outumn
    winter
    Instead I get:
    0x737072696E67
    0x73756D6D6572
    0x6F7574756D6E
    0x77696E746572
    Steps to try the sample
    1)Creating the following type
    create or replace TYPE CHAR_ARRAY IS TABLE OF VARCHAR(32767);
    2)Creating the following stored procedure
    create or replace PROCEDURE MQ_MSG_PROCESSOR
       MessageText in VARCHAR2,
       QueueName out VARCHAR2,
       RplyMessage out CHAR_ARRAY,
       HastoCommit out NUMBER
    AS
       RMessage CHAR_ARRAY;
    BEGIN
       QueueName:='DEV_OUT';
       RMessage:=CHAR_ARRAY();
       RMessage.Extend(4);
       RMessage(1):='spring';
       RMessage(2):='summer';
       RMessage(3):='outumn';
       RMessage(4):='winter';
       HastoCommit:=1;
       RplyMessage:=RMessage;
    END;
    3)Copiling and running the following java class
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.oracore.Util;
    import oracle.jdbc.driver.*;
    import java.util.Dictionary;
    public class ArrayExample
       public static void main (String args[]) throws Exception
          MSG Msg=null;
          oracle.sql.ARRAY RMsg=null;
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@test","test", "test");
          conn.setAutoCommit (false);
          try
             String []array={};
             ArrayDescriptor desc=ArrayDescriptor.createDescriptor("CHAR_ARRAY",conn);
             ARRAY CHAR_ARRAY=new ARRAY(desc,conn,array);
             OracleCallableStatement sproc = (OracleCallableStatement)conn.prepareCall("{call GSM.MQ_TST.MQ_MSG_PROCESSOR(?, ?, ?, ?)}");
             sproc.setString(1, "hello"); //MessageText
             sproc.registerOutParameter(2, OracleTypes.VARCHAR);   //QueueName
             sproc.registerOutParameter(3, OracleTypes.ARRAY,"CHAR_ARRAY");   //RplyMessage
             sproc.registerOutParameter(4, OracleTypes.NUMBER);      //HastoCommit
             sproc.execute();
             CHAR_ARRAY=(oracle.sql.ARRAY)sproc.getARRAY(3);
             array = (String [])CHAR_ARRAY.getArray();
             for(int i=0;i<array.length;i++)
                System.out.println(array);
          catch(SQLException e)
             System.out.println("Error while trying to execute MQ_MSG_PROCESSOR");
             System.out.println(e);
          conn.close();

    Hi,
    I tried the code with same procedure.
    That works out fine for me..
    and it prints out exactly the same words as you mentioned..:))
    may be you must have changed something later on.. which started printing character codes..
    but for me it works perfectly fine..
    All The Best..
    Regards
    Gurudatt
    The problem is the following:
    I would tike to get a PL/SQL Table (a table of
    varchar2) into a Java String Array.
    It works very well except that instead of getting the
    characters in the PL/SQL Table
    I receive the character codes in each string.
    In the following example i should get:
    spring
    summer
    outumn
    winter
    Instead I get:
    0x737072696E67
    0x73756D6D6572
    0x6F7574756D6E
    0x77696E746572
    Steps to try the sample
    1)Creating the following type
    create or replace TYPE CHAR_ARRAY IS TABLE OF
    VARCHAR(32767);
    2)Creating the following stored procedure
    create or replace PROCEDURE MQ_MSG_PROCESSOR
    ���MessageText in VARCHAR2,
    ���QueueName out VARCHAR2,
    ���RplyMessage out CHAR_ARRAY,
    ���HastoCommit out NUMBER
    AS
    ���RMessage CHAR_ARRAY;
    BEGIN
    ���QueueName:='DEV_OUT';
    ���RMessage:=CHAR_ARRAY();
    ���RMessage.Extend(4);
    ���RMessage(1):='spring';
    ���RMessage(2):='summer';
    ���RMessage(3):='outumn';
    ���RMessage(4):='winter';
    ���HastoCommit:=1;
    ���RplyMessage:=RMessage;
    END;
    3)Copiling and running the following java class
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.oracore.Util;
    import oracle.jdbc.driver.*;
    import java.util.Dictionary;
    public class ArrayExample
    ���public static void main (String
    args[]) throws Exception
    ���{
    ������MSG Msg=null;
    ������oracle.sql.ARRAY
    RMsg=null;
    ������DriverManager.regis
    erDriver(new oracle.jdbc.driver.OracleDriver());
    ������Connection conn =
    DriverManager.getConnection
    ("jdbc:oracle:oci8:@test","test", "test");
    ������conn.setAutoCommit
    (false);
    ������try
    ������{
    ���������S
    ring []array={};
    ���������A
    rayDescriptor
    desc=ArrayDescriptor.createDescriptor("CHAR_ARRAY",conn
    ���������A
    RAY CHAR_ARRAY=new ARRAY(desc,conn,array);
    ���������O
    acleCallableStatement sproc =
    (OracleCallableStatement)conn.prepareCall("{call
    GSM.MQ_TST.MQ_MSG_PROCESSOR(?, ?, ?, ?)}");
    ���������s
    roc.setString(1, "hello"); //MessageText
    ���������s
    roc.registerOutParameter(2,
    OracleTypes.VARCHAR);���//QueueName
    ���������s
    roc.registerOutParameter(3,
    OracleTypes.ARRAY,"CHAR_ARRAY");���//Rpl
    Message
    ���������s
    roc.registerOutParameter(4,
    OracleTypes.NUMBER);������
    //HastoCommit
    ���������s
    roc.execute();
    ���������C
    AR_ARRAY=(oracle.sql.ARRAY)sproc.getARRAY(3);
    ���������a
    ray = (String [])CHAR_ARRAY.getArray();
    ���������f
    r(int i=0;i<array.length;i++)
    ���������{
    System.out.println(array);
    ���������}
    ������}
    ������catch(SQLException
    e)
    ������{
    ���������S
    stem.out.println("Error while trying to execute
    MQ_MSG_PROCESSOR");
    ���������S
    stem.out.println(e);
    ������}
    ������conn.close();
    ���}

  • Help retreiving XML data in table format

    Hello,
    i have a field which stores IP and Domain data in XML format. The field data type is BLOB.
    here is the XML data sample stored in the field.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <DOMAIN Name="DOMAIN_NAME HERE">
    <IPADDRESS Address="X.X.X.X1"></IPADDRESS>
    <IPADDRESS Address="X.X.X.X2"></IPADDRESS>
    <IPADDRESS Address="X.X.X.X3"></IPADDRESS>
    <IPADDRESS Address="X.X.X.X4"></IPADDRESS>
    ... ETC
    Is it possible to run SELECT against this field and retrieve the data in the table format, so the output will have two fields and look like
    domain IPADDRESS
    DOMAIN_NAME HERE X.X.X.X1
    DOMAIN_NAME HERE X.X.X.X2
    DOMAIN_NAME HERE X.X.X.X3
    DOMAIN_NAME HERE X.X.X.X4
    I have tried many option with Extract, extractvalue and XMLQuery, not luck.
    Thank you very much!
    Sergei

    Try...
    xp20:format-dateTime(string($dateFromDatabase), '[D01]-[MN,*-3]-[Y0001] [H01]:[m01] P')Ref
    http://www.w3.org/TR/xslt20/#function-format-dateTime
    Cheers,
    Vlad

  • Need help with pl/sql tables

    i am trying but iam not understanding this....
    Evaluate this program fragment:
    DECLARE
    TYPE user_tab_rec IS RECORD (
    db_user dba_users.username%TYPE,
    DBA_TAB dba_tables%ROWTYPE);
    TYPE user_rec_tab IS TABLE OF test_rec
    INDEX BY BINARY_INTEGER;
    Tab_rec dba_tables%ROWTYPE;
    Obj_owner dba_objects.owner%TYPE;
    begin
    (processing)
    end;
    What line will generate an error?
    1.
    TYPE user_tab_rec IS RECORD (
    2.
    db_user dba_users.username%TYPE,
    3.
    DBA_TAB dba_tables%ROWTYPE);
    4.
    TYPE user_rec_tab IS TABLE OF test_rec
    5.
    INDEX BY BINARY_INTEGER;
    6.
    Tab_rec dba_tables%ROWTYPE;
    7.
    Obj_owner dba_objects.owner%TYPE;
    The correct answer is b. The line in b attempts to define a PL/SQL TABLE TYPE using a record that contains a composite datatype, which is not allowed. Answers a, c, and d are incorrect because they will not generate any errors when compiled.
    how can line b attempt to define a pl/sql table type..........
    thank u ramsy

    The correct answer is bB? I see no B.
    Do you mean three?
    But then again
    maybe line ten.
    Because (processing) isn't
    valid syntax you see.
    I know, I know
    Let's see what'll go.
    And then we'll see
    Is it A B or C?
    SQL> r
      1  DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11* end;
    TYPE user_rec_tab IS TABLE OF test_rec
    ERROR at line 5:
    ORA-06550: line 5, column 31:
    PLS-00201: identifier 'TEST_REC' must be declared
    ORA-06550: line 5, column 1:
    PL/SQL: Item ignored
    SQL> create type TEST_REC as object(a number);
      2  /
    Type created.
    SQL> DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> Hmmm........................
    Cheers, APC

  • How to join two pl/sql tables .,.,,Urgent pls help

    Hi,
    Please tell me how to join to pl/sql tables with example
    thanks
    asp

    If your main intention is to get the common records/or getting whole records from the 2 different pl/sql arrays then , pls check this piece of code & explanation
    The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside relational tables.
    Let's take a look at some of the syntax needed to do this, starting with UNION.
    First, I create a schema-level nested table type:
    CREATE OR REPLACE TYPE strings_nt
    IS TABLE OF VARCHAR2(100);
    Then I define a package and within it create and populate two nested tables of this type, each containing some of my father's and my favorite things:
    CREATE OR REPLACE PACKAGE favorites_pkg
    IS
    my_favorites strings_nt
    := strings_nt ('CHOCOLATE'
    , 'BRUSSEL SPROUTS'
    , 'SPIDER ROLL'
    dad_favorites strings_nt
    := strings_nt ('PICKLED HERRING
    , 'POTATOES'
    , 'PASTRAMI'
    , 'CHOCOLATE'
    PROCEDURE show_favorites (
    title_in IN VARCHAR2
    , favs_in IN strings_nt
    END;
    In this package, I also include a procedure to show the contents of a strings_nt nested table. This will come in very handy shortly.
    By defining these collections in a package, outside any program, they persist (they maintain their state and values) for the duration of my session or until I change or delete them. This means that I can now write programs outside the package to manipulate the contents of those collections.
    Note that this package has been simplified for the purposes of presenting collection functionality. In a production application, you should always take care to "hide" your package data, as with these collections, in the package body, and then provide procedures and functions to manage the data.
    Suppose, for example, that I would like to combine these two collections into a single collection of our favorites. Prior to Oracle Database 10g, I would have to write a loop that transfers the contents of one collection to another. Now, I can rely on the MULTISET UNION operator, as shown below:
    DECLARE
    our_favorites
    strings_nt := strings_nt ();
    BEGIN
    our_favorites :=
    favorites_pkg.my_favorites
    MULTISET UNION ---- Use INTERSECT , if you want to know common records
    favorites_pkg.dad_favorites;
    favorites_pkg.show_favorites (
    'ME then DAD', our_favorites);
    END;
    The output from this script is:
    ME then DAD
    1 = CHOCOLATE
    2 = BRUSSEL SPROUTS
    3 = SPIDER ROLL
    4 = PICKLED HERRING
    5 = POTATOES
    6 = PASTRAMI
    7 = CHOCOLATE
    ------------------------------

  • Help Using SQL*Plus Format Commands (like TTITLE) in Packages

    Where (within a package) can/should SQL*Plus format commands such as TTITLE, COLUMN & BREAK be coded?

    A package is coded in PL/SQL.
    TTITLE, COLUMN and BREAK are SQL*Plus commands, they cannot be used in PL/SQL.
    If you want to output data (using dbms_output) in your package, you'll have to implement the features yourself. But probably just using SQL*Plus is better in your case.
    Regards,
    Rob.

Maybe you are looking for

  • I cant add contacts with the new ios.5

    i cant add or remove contacts from my ipod with the new ios.5 so i cant use the imessage app

  • Cannot open document when emailed to someone.

    I was using LibreOffice and it was working fine as far as opening files on my computer, but when I sent an email with a document using LibreOffice, the person on the other end can't open it.  So, I downloaded OpenOffice and tried using that and still

  • Flash Player not working in 10.6.3 - arghhhh

    Ok so I installed Snow Leopard on my Macbook Pro and since then I haven't been able to get the flash player to work. I've check I have the latest version Adobe Flash Player 10.0 r45, I've reset the cache in Safari. Now I am at a loss what to do next.

  • How to install two Application Servers with shared Portal DB?

    I currently am supporting a 9ias 1.0.2.2.2 server that has an existing Portal database on another 9i RDMBS server. Everything runs well in this environment, but now management wants to add another 9ias server (different IP address and DNS Name), and

  • Date series graph

    Here's another doozy: I'm trying to create a bar graph that has dates along the x-axis and values up the y-axis. The dates will be approximately once a week over a year. According to the faq I should be able to do something like this: http://www.orac