How to get the number of rows written to the header of the spool file.

Hi
I need to create a header line for the spool file .
the header line should include fixed length values .
The header should include the number of records found in the table with a maximum begin date (begin_date is the column of the table)
To get the header in the spool file , i wrote a select query has :-
--SPOOL 'C:\Documents and Settings\abc\Desktop\output.TXT'
select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
rpad(' ',76,' ')
from dad.school
group by sysdate;
SPOOL OFF
which gets me all the rows in the table , but i only want the rows with the latest school_begin_date .
how can i achieve that ...
I know that a subquery should be written in the from clause to get the number of rows found with a maximum school_begin_date.
select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
rpad(' ',76,' ')
from dad.school where
select rownum from dad.school
where school_begin_date = max(school_begin_date) ;
the error i get is
ORA-00934: group function is not allowed here
I NEED HELP ..IN GETTING THE ROWNUM JUST FOR THE LATEST BEGIN_DATE ?
PLS HELP ME IN WRITING THE QUERY .
THANKS IN ADVANCE .

Try this:
select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000')||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) || rpad(' ',76,' ')
  from dad.school
where school_begin_date = (select max(school_begin_date)
                              from dad.school);

Similar Messages

  • Need to know how to get imei number from an iphone i no longer have the box, i have the serial number any help!?

    hi i need help if anyone knows how i can find imei number i have the serial number??

    Hey bud sorry i forgot to mention that my phone was stolen, so i go online to see the phone i bought in the apple web page and all i can see is the serial number for the phone, my question is if i can use the serial number to know the imei number?

  • How to get total number of rows return by query

    hi all
    i am using forms 6i with oracle 10G in windows environment....
    i have a tabular form now i want to know that how many rows return by the query...like when user click on enter query and then give any search criteria and then execute query..it displays the records but i want to count the records that how many rows are return.............
    hope you understant what i mean
    Thanks in advance
    Regards

    U can use
    "Select count(*) from <table> where <condition>"
    <condition> is the where clause being used during "Execute Query"
    this will give u the no of records in query.
    And second option is to take a summary column. whose function is set "COUNT" and
    "Summarized item" should contain a column that will never be blank. After execute query this column will give u no of records in block.
    Regards....

  • How to get thr number of rows of an SQL query in JSTL

    hi guys,
    can anyone please tell me how do i perform a function which finds out the particular rownumber of an sql query in JSTL.....
    the same code in jsp is:
    <% plateRSet.getRowNum() %>
    how do i do this given plateRset is the var for a given iteration
    thanks
    rahul

    make your result set scrollable...Not such a good idea. With Oracle, the JDBC driver will read and cache all the ResultSet in memory (with other DBMSs/drivers the behavior will probably be different, but you will still have some unnecessary overhead).
    You can do the caching yourself if you think it's worth it. If the piece of code you posted is why you need this for, then use a List or Vector and you won't need to know the size upfront.
    Alin,
    The jTDS Project.

  • How to get physical number of selected row on the screen.

    Hi,
    We have block defined with Numbers of Records Displayed = 3. In the same time the data set contains 10 records. We would like to know how to get a number of row selected on the screen. i.e. in our case that the number will be always between 1 and 3 independent of the current row position in the data set.
    Best regards,
    Constantin.

    You can calculate that number by subtracting :SYSTEM.CURSOR_RECORD and GET_BLOCK_PROPERTY('BLOCK', TOPMOST_RECORD)

  • How to set the number of rows that an awt.Choice can display

    Dear Sir,
    I want to ask how an awt.Choice  can set the number of rows that it can display, like the method setMaximumRowCount in JCombobox. Since I want to set more row can be displayed, but choice no any method can set. And I have tried to add Jcombobox into awt.frame, then, the handling event function cannot receive event for the right-top cornet button(minimize, maximum, close).
    Best Regards,

    please post a Short, Self Contained, Correct Example showing your problem.
    bye
    TPD

  • How to know the number of rows in a cursor?

    Hi all,
    How can i know how many rows a cursor has ?
    Glen

    dbms_sql... you can use when you want to know how many lines of code the cursor has.
    If you want to know how many rows it will fetch, you have to fetch all rows - the number of rows actually fetched are assigned to the variable <cursor_name>%ROWCOUNT.
    When you don´t want to fetch all rows, all you can do is count(*)...
    Regards,
    Gerd

  • Get the number of rows in a cursor?

    Currently I have a pretty simple stored procedure that builds some dynamic SQL then returns those results to some code.
    I would like also to be able to return the number of rows in that cursor back to the Java code, how can I do this? Some sample SQL is shown below:
    l_query := 'Select * from customer';
    OPEN searchResults FOR l_query;
    ???? Select count(*) into totalResults from searchResults; ????
    (^^This last row is the issue)
    I need to return the varaible totalResults as the count
    Thanks heaps!!

    Mark,
    If I understand you correctly, what you desire cannot be done.
    When Oracle opens a cursor, it doesn't know how many rows that cursor will return.
    The only two options is either do a separate query to count the number of rows that the original query will return, or fetch all the rows and see how many you got.
    I recall seeing an example of that in the JDBC sample code on the OTN Web site.
    (But I'm too lazy to look for it for you.)
    Good Luck,
    Avi.

  • Getting the number of rows returned from ResultSet

    Hi,
    Does anyone know a method to get the number of rows returned with a query using the Resultset class?
    Thanks.

    Hi 281080,
    If your database and JDBC driver support it, in order to use the solution that da-alexj has suggested, you need to create a 'scrollable' "ResultSet" -- the javadoc for method "createStatement()" (in class "java.sql.Connection") has more details.
    However, I have found with Oracle 8.1.7.4 database and Oracle (thin) JDBC driver, that part of their implementation of the "last()" method (in class "java.sql.ResultSet") is to actually iterate through the entire "ResultSet" in order to reach the last row. If your "ResultSet" is very large (I tested it with a 100,000 row "ResultSet"), this will take a long time.
    Just wanted to make you aware of that.
    Of-course, this may be irrelevant to you since I didn't see any mention in your post of what database and JDBC driver you are using.
    Hope this has helped you, anyway.
    Good Luck,
    Avi.

  • Count the number of rows in an array

    Hi there,
    I'm quite new with Labview, maybe somebody can help me.
    I have a .vi that controls two pump with certain ratios (to make a composition gradient). I export the data to an ascii file, which write the displacement of the two pumps in 2 colums. However, the number of rows is related to the ms-counter, and thus related to the processor of the computer. Now I need, at the end of the vi, to get the number of rows written to the ascii file, to do some further calculations. Does anybody know how to do this?!
    Thanks

    You could wire the loop-counter to a variable outside the loop, so you can see the number of iterations (don't forget to add 1).
    You also can use the Array Size-Function. Here you get different outputs, according to the dimensions of the array to get the size of.
    Here you can see what you get if you use this function:
    1D-Array: one value
    2D-Array: array, item 0 = number of rows, item 1 = number of columns
    3D-Array: array, item 0 = number of pages, item 1 = number of rows, item 2 = number of columns
    So if (in your case) you wire a 2D-Array you can use the array-size function, select item 0 of the array you get and you get the number of rows.
    You can also have a look at the attachement.
    Hope it helps.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    ArraySize.vi ‏17 KB

  • Displayin message and fixing the number of rows in a table

    Hi Experts,
    I have a requirement like this
    there is a table, where i need to diplay a message when there are no records and no rows should be visible on that table.
    Also, when the records are populated from the context, i need to fix the number of rows in that table and display the records.
    Please let me know hw this can be achieved.
    Also in the table I have Link to URL, please let me know how to handle this reference, when i set the reference Property, its giving me an error stating that the file doesn't exist when the table gets loaded.
    Thanks in Advance
    Regards,
    Palani

    Hi
    Oh!!  You should to  explain it at first thread itself that you want to display a JPG imange or other WDWebResourceTypetaken form the backend.
    1. So this is not at all a URL
    2. You have to convert binary data to WDWebResource then display it in either Image UI element or other (like PDF , txt etc)
    3
    try
                   //        Read the datasource of the FileUpload
                   IWDResource res = wdContext.currentContextElement().getResource();
                   InputStream in = res.read(false);
                   ByteArrayOutputStream bOut = new ByteArrayOutputStream();
                   int length;
                   byte[] part = new byte[10 * 1024];
                   while ((length = in.read(part)) != -1)
                        bOut.write(part, 0, length);
                   in.close();
                   bOut.close();
                   IPrivateUploadCompView.IImageTableElement ele = wdContext.nodeImageTable().createImageTableElement();
                   ele.setImage(wdContext.currentContextElement().getResource().getUrl(0));
                   ele.setText(res.getResourceName());
                   wdContext.nodeImageTable().addElement(ele);
              catch (Exception e)
                   wdComponentAPI.getMessageManager().reportWarning(e.toString());
    Here I assume that you convert that data to IWDResource type or
    4.
    WDWebResource.getWebResource(wdContext.currentContextElement().getresource(), type);
    // getResource of type binary which u read from BAPI and set it in local context , type is MIMETYPE or hardcode it as "JPG"
    5. Further help
       [Help1|To Displayan Image in Webdynpro Java from Standard Function Module;
    [Help2|http://wiki.sdn.sap.com/wiki/display/KMC/GettinganimagefromKMDocumentstobeusedinWeb+Dynpro]
    [Help3|http://wiki.sdn.sap.com/wiki/display/KMC/GettinganimagefromKMDocumenttobeusedinWeb+DynPro]
    It might code look strange at first , please do some reserch in SDN ,I did my best at this level.
    Best Regards
    Satish Kumar

  • How to get the number of rows returned by a report?

    Hi,
    I'm developing my first application in APEX and so far everything seems fine, except I can't figure out this very simple thing: I have a report based on a PL/SQL block returning an SQL string. I'd like to have a message (something like "X rows returned") just before the report. The closest thing I could find was "X to Y out of Z" in the pagination styles, but that's not what I want. Also I don't think running the same query to get COUNT() is wise.
    Any help would be appreciated.
    Thanks,
    Konstantin

    My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

  • How to get the number of rows in a repeating frame ?

    Hi all,
    When I launch a report from forms then sometimes there are data in the report and sometimes there are no data. And the problem is that when there are no data then the frame containing the repeating frame is still displaying and a blank page displays on the report.
    So I want to get the number of rows from the repeating frame so that I can code a format trigger on the frame to display or not the enclosing frame depending on the existence of data from the repeating frame.
    Thank you very much indeed.

    Dear Friend,
    You can achieve this. Define a summary column (say cnt). Select summary type as "COUNT". select any one of columns that are getting displayed in your repeating frame as summary column and provide "reset at" group name (or set this to report if you are defining this field at report level) . This "cnt" variable will contain how many records that will be fetched for your repeating frame (i.e. Group of Repeating frame). You can use this "CNT" variable in your format trigger.
    In this case there is no need to write before report trigger or anything.
    Regards,
    Manish Trivedi

  • How to get the number of rows in a DB-Cursor

    When i open a database cursor i do not know how much rows are stored in the cursor. To solve this problem i have to send a 'select count(1) ...' to get the number of rows before i set up the cursor. I think that this is not very clever and could possibly cause performance problems. But i need the num of rows to show the percentage of processed rows. Is there any other way to get the num of rows? May be by checking the cursor directly?
    Please help!
    Thanx a lot

    In order to find out how may rows are going to be processed, oracle has to visit every row. So with a cursor, there is no property that will accurately reflect the number of rows until you get to the last one. That said, you could use
    select count(*) over() as row_count, <rest of your columns> FROM <your table>
    which will give you the total row count agaist each row in the result set. There are performance penalties involved but they will be less than issuing the query twice, once to get the count and once to get the rows.
    Have a look on asktom for some very usefull info about all this.
    HTH

  • How to get the number of rows in a ResultSet

    Hello,
    I'm an intern and I'm trying to get the number of rows from result set in oracle using rs.last() and rs.beforeFirst() methods
    but I got an error. Could Below is my sample code:
    import java.sql.*;
    public class SarueckConnect {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet re = null;
    String[] ParamArray;
    ParamArray = new String[24];
    //Properties logon;
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
    con = DriverManager.getConnection
    ("jdbc:oracle:thin:@258.8.159.215:1521:test_DB","data","data"); //making the connection DB.
    stmt = con.createStatement ();// Sending a query string to the database
    //stmt.executeUpdate("UPDATE test_table set steuk = 6 WHERE steuk = 5");
    ResultSet rs = stmt.executeQuery("SELECT mandt,kokrs,werks,arbpl,aufnr,vornr,ile01,"+
    "lsa01,ism01,ile02,lsa02,ism02,ile03,lsa03,ism03,ile04,lsa04,ism04,steuk,matnr,budat,"+
    "kostl,pernr,rueckid FROM test_table where steuk =6");
    //Print the result out.
    rs.last(); //This is the line which gives an error.
    int rows = rs.getRow();
    rs.beforeFirst();// I presume this is wrong to.
    ParamArray = new String[24*rows];
    int counter=0;
    while (rs.next()) {
    for (int i = 1; i <= 24; i++){
    ParamArray[i-1+(counter*24)] = rs.getString(i);
    System.out.print(rs.getString(i) + '\t');
    System.out.println();
    counter++;
    } catch(Exception e) {
    e.printStackTrace();
    } finally {
    try
    if(stmt != null) stmt.close();
    if(con != null) con.close();
    } catch (Exception exception) {
    exception.printStackTrace();
    TryBapi sap = new TryBapi(ParamArray);
    }When I run the code I do have the following ERROR Message:
    java.sql.SQLException: Invalid operation for forward only resultset : last
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.driver.BaseResultSet.last(BaseResultSet.java:91)
    at SarueckConnect.main(SarueckConnect.java:28)Please could any body Help me out here to figure out how to correct this?
    Any Help would be highly apprecited.

    make your result set scrollable...Not such a good idea. With Oracle, the JDBC driver will read and cache all the ResultSet in memory (with other DBMSs/drivers the behavior will probably be different, but you will still have some unnecessary overhead).
    You can do the caching yourself if you think it's worth it. If the piece of code you posted is why you need this for, then use a List or Vector and you won't need to know the size upfront.
    Alin,
    The jTDS Project.

Maybe you are looking for

  • Skip a column in BI Publisher Excel Template

    Hi, Do anyone know how to skip an entire column based on a condition in BIP Excel Template.  We are able to skip a row in Excel Template using XDO_SKIPROW, Do we have a similar one for skipping columns? Thanks in advance

  • Payment budget not checked in MIGO against last years PO

    We are using Former Budgeting. We have customised specific tolerance (OF23) to generate error message when budget exceeds 100% against payment budget. (not commitment budget). Now we have a scenario: Purchase order was created in the last year. Good

  • Import script to remove zeros in Account field

    Dear FDM Experts, The problem is our source system always extracts 10 characters but we use 7 characters in HFM. Example, Account 0001201010 (10 characters) must be 1201010 (7 characters). I want to write an Import Script to remove, if any, all zeros

  • Change the appleid on a computer

    We gave a MacBook (10.7) to granddaughter for college (smart girl, will use it well) which I set up initially which means it was born with my AppleID. She has her own ID, so I'd really like to switch it to hers, but i cant figure out where to do that

  • Which kind of the CPU can support the FMLE3 to encoding the h264 format

    The Signal is yuv or pcm stream ,  i use the fmle3.0 to encoding to the h.264 format. Once started.the CPU utility rate is going up to the 100%. I want to konw,which kind of the CPU can support the live stream. In other words,My require is encoding t