How to use SQL query result in DOS commands

Hi
Currently i am runnig below DOS commands manually
d:\apps\bin>TrueGridsCalc period="Aug 2010"
Now I want to write one batch file and schedule job on windows and make value of "period" to be dynamic. So to get that value i need to fetch it from DB
Steps which i am taking are
1. connect DB from command line (using SQLPLUS)
2. run query to fetch result
3.How to use query result in "period" parameter ?
I am good at step 1 and 2. Dnt know how to use query result in command to make it dynamic
Thank you
Sachin
Edited by: sachin.mali on Oct 26, 2010 4:39 PM
Edited by: sachin.mali on Oct 26, 2010 4:43 PM

sachin.mali wrote:
Hi
Currently i am runnig below DOS commands manually
d:\apps\bin>TrueGridsCalc period="Aug 2010"
Now I want to write one batch file and schedule job on windows and make value of "period" to be dynamic. So to get that value i need to fetch it from DB
Steps which i am taking are
1. connect DB from command line (using SQLPLUS)
2. run query to fetch result
3.How to use query result in "period" parameter ?
I am good at step 1 and 2. Dnt know how to use query result in command to make it dynamic
Thank you
Sachin
Edited by: sachin.mali on Oct 26, 2010 4:39 PM
Edited by: sachin.mali on Oct 26, 2010 4:43 PMYOu'll have to have sqlplus spool the output to a file, then figure out some way of parsing that file. Too bad you're stuck with Windows. With any *nix you could do the file parsing with one line of code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to use sql query in java ?

    i don't know how to use sql query in java code.
    who can give me some advice?
    thanks

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • How to Use SQL Query having IN Clause With DB Adapter

    Hi,
    I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
    Thanks

    invoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter

  • How to use one query results in another query

    hi,
    in help.sap I have founded that using variable type replacement path I can use one query results in another query. It is wrote there that I have to choose query name results I want to get in variable definition but I do not know where.
    How I can do this?
    Result I want to get is:
    In one query I have material prices in another material quantities. I want to calculate inventory value (price * quantity). Moreover prices are on plant level, quantities on storage type level. Plant is atribute of storage type.
    Can I do this?
    Regards,
    Andrzej

    Hi Andrzej,
    please check out this thread: Set parameters values depending on other parameters
    I had a discussion about query results as input for another query in there.
    For creating a workbook, just click on the save button after you ran your query in the bex.
    Siggi
    Message was edited by: Siegfried Szameitat

  • How to send SQL query results to XML ?

    Hey Guys, I am querying a DB with huge amount of traffic. A user select a particular lot and then details of the lot will be displayed in the following page. My concern here is that it takes really LONG to retrieve back the results coz it has to requiry in the following JSP page.
    I was told to use XML to retrieve the dataset and store it. Hence, in the following query it will re-query only from the recordsets in the XML file (...Logically, should be faster rite ? ). Hence, how do parse my recordsets retrieved from the SQL query to an XML file ?
    Any sort of suggestion , help, reference would be deeply appreciated ..Thanks !

    <HTML>
    <BODY>
    <H1>Manufacturing Summary beta </H1><BR>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.text.*" %>
    <jsp:include page="/index.html" flush="true"/>
    <P><B>Returned result<B><BR>
    <B>Query String :</B><%=request.getParameter("date") %>
    <TABLE BORDER=1 cellpadding=0 cellspacing=0>
    <%!
    static double roundDouble(double toBeRounded, int fractionDigits)
    NumberFormat format = NumberFormat.getInstance();
    format.setMaximumFractionDigits(fractionDigits);
    String tempDouble = format.format(toBeRounded);
    return Double.parseDouble(tempDouble);
    %>
    <%
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@klmomnidb:1521:
    OMNIDB","omni","omni");
    Statement stmt = null;
    ResultSet rset = null;
    String S_date = new String();
    String temp = new String();
    String lot_id = new String();
    String result = new String();
    String SQL_String = new String();
    double yield;
    int bad_cnt;
    S_date = request.getParameter("date");
    lot_id = request.getParameter("lot_id");
    temp = request.getParameter("TST_TEMP");
    SQL_String = "SELECT LOT_ID, FLOW_ID, TST_TEMP, MODE_COD, RTST_COD, PART_CNT, GO
    OD_CNT, OPER_NAM, JOB_REV, PROC_ID, START_T, FACIL_ID, TSTR_TYP, NODE_NAM FROM L
    OT where START_T > TO_DATE('"+ S_date + "','MM/DD/YYYY') AND TST_TEMP <='" + tem
    p+"' order by START_T";
    out.println(SQL_String);
    stmt = conn.createStatement();
    rset = stmt.executeQuery (SQL_String);
    out.println("<TR>");
    out.println("<TD> Select Lot(s)</TD>");
    out.println("<TD>Flow </TD>");
    out.println("<TD>Temp </TD>");
    out.println("<TD>Test Mode </TD>");
    out.println("<TD>Retest</TD>");
    out.println("<TD>Total </TD>");
    out.println("<TD>Good</TD>");
    out.println("<TD>Bad</TD>");
    out.println("<TD>Yield </TD>");
    out.println("<TD>UserID</TD>");
    out.println("<TD>Program</TD>");
    out.println("<TD>Mask</TD>");
    out.println("<TD>Start Time </TD>");
    out.println("<TD>Loc </TD>");
    out.println("<TD>Tester</TD>");
    out.println("<TD>System </TD>");
    out.println("</TR>");
    if (! rset.next()) {
    result ="No records found matching seach criteria.";
    while (rset.next()) {
    bad_cnt = Integer.parseInt(rset.getString(6)) - Integer.parseInt(rset.getString(
    7));
    yield = (Double.parseDouble(rset.getString(7)) / Double.parseDouble(rset.getStri
    ng(6))) * 100;
    result= "<TR>";
    result = result + "<TD><a href=coolpage.jsp?LOT_ID=" + rset.getString(1)+ ">" +
    rset.getString(1) + "</A></TD>";
    result = result + "<TD>" + rset.getString(2) + "</TD>";
    result = result + "<TD>" + rset.getString(3) + "</TD>";
    result = result + "<TD>" + rset.getString(4) + "</TD>";
    result = result + "<TD>" + rset.getString(5) + "</TD>";
    result = result + "<TD>" + rset.getString(6) + "</TD>";
    result = result + "<TD>" + rset.getString(7) + "</TD>";
    result = result + "<TD>" + bad_cnt + "</TD>";
    result = result + "<TD>" + roundDouble(yield,2) + "% </TD>";
    result = result + "<TD>" + rset.getString(8) + "</TD>";
    result = result + "<TD>" + rset.getString(9) + "</TD>";
    result = result + "<TD>" + rset.getString(10) + "</TD>";
    result = result + "<TD>" + rset.getString(11) + "</TD>";
    result = result + "<TD>" + rset.getString(12) + "</TD>";
    result = result + "<TD>" + rset.getString(13) + "</TD>";
    result = result + "<TD>" + rset.getString(14) + "</TD>";
    result = result + "</TR>"; %>
    <%=result%>
    <% }
    rset.close();
    stmt.close();
    conn.close();
    %>
    <%=result%>
    </TABLE>
    </BODY>
    </HTML>

  • How to use SQL Query in OBIEE Reports

    Hi all,
    I need to use direct sql query in report function column.. How can I implement that.
    For example
    Our report name is /shared/Automotive/Vehicle Services/Most Serviced Vehicle Models
    we have to eliminate /shared/Automotive/Vehicle Services/ part from above report name.. I have done this in sql using the Query SUBSTR(COL,INSTR(COL,'/',1,4)+1).
    So kindly help how to implement above sql query in Obiee.. Urgent.
    Thanx in advance

    796797 wrote:
    Hi all,
    I need to use direct sql query in report function column.. How can I implement that.
    For example
    Our report name is /shared/Automotive/Vehicle Services/Most Serviced Vehicle Models
    we have to eliminate /shared/Automotive/Vehicle Services/ part from above report name.. I have done this in sql using the Query SUBSTR(COL,INSTR(COL,'/',1,4)+1).
    So kindly help how to implement above sql query in Obiee.. Urgent.
    Thanx in advanceArrggh. I wish people wouldn't just answer a question without taking the time to actually think about what the user is asking for and if it makes sense. I like Diney's response best: Why not use the Title View? (i.e., asking questions until it is clear what is needed.) So along those lines, why are you trying to put the name of your report in a column of your report?? And why do you need to use direct sql to do this??
    Kindly or not, urgent or not, state what you are trying to achieve and why you need it (if the obvious answer like "using the Title View" doesn't work for you), instead of simply assuming your method is right and you need to know how to do what envision. Your method may not be correct or necessary.

  • How to use sql:query/ tag to retrive the system date?

    hi all,
    i want to know if i can use the <sql:query/> tag in jstl to get the database server time. please send me a code snippet to retrive n display the result. i'm new to jstl tags. please help.
    thank you,
    AM

    Check out the first hits: http://www.google.com/search?q=jstl+sql+tutorial+site:sun.com

  • How to use SQL Query from VC

    Hi all, with the adoption of SQ01 transaction, now I've a SQL Query defined in SAP R/3 system.
    How to use it with Visual Composer 7.0 SP14 ?
    Thanks in advance
    Gianfranco

    Hi ,
    It is simple to use quiery in Vc.
    Go for Find data control in Right side of  V.C .
    Enter System name:The system used for your quiery i.e R3 (Before u should mapp the R3 alias to the VC user in portal)
    Look for :Look for service by name.
    Service :Ur quiery
    Regards,
    Govindu

  • How to order SQL query results in order given in IN Clause

    Hi,
    I Need to construct a query, which takes a string as input and results for those should be sorted in the order in which request was made.
    Say, we have a couple of students, and the grades in different subjects to be the result of the query.
    If John and Jane are the two students,
    and if input is John,Jane
    my output should be listing John, his subjects and grades
    and then Jane, her subjects and grades.
    I read somewhere in other posts, that i could use a query combined with regular expression to split a string into a temp table/array and use this as my input for my select query. Then use the rownum or level from this temp table to sort the data in order sent in.
    But am not able to put together a query which would work for me.
    Anyone with any pointers on this would be highly appreciated.
    Thanks

    Hi,
    [This thread|http://forums.oracle.com/forums/thread.jspa?threadID=702891&tstart=0] is about splitting up delimited lists. You'll want to keep the n-th value from the user-supplied list, as well as n itself, in a result set, so you can use it in both your WHERE- and your ORDER BY clause.
    If you're using SQL*Plus, you can also keep the whole list in a substriution variable, and use INSTR to see where individual values appeard in that list. Personally, I'd trust the first method (split and store) more.

  • How to print sql query results

    how to print sqlplus query results

    Hi,
    Spool sql.txt
    Execute the query
    Spool off
    And find the sql.txt file in the current directory.
    Regards
    Jafar

  • How to return SQL query results as resultset

    I am developing a site in ASP to support back end as oracle or SQL server.
    In SQL Server, from stored procedure it is possible to return resultset by writing sql query in procedure using input parameters as filters (where condition).
    Is there a way to return a resultset from oracle procedures or functions.

    http://asktom.oracle.com/~tkyte/ResultSets/index.html
    In 9i or above you no longer need to define your own weak ref cursor type in a package spec, you can use the built-in SYS_REFCURSOR.

  • How to use SQL query in ADF

    Hi Team,
    I want to fire one sql query to retrive some data. I cant make VO of that query as its from many DB link.
    Query is like SELECT query.
    Can anyone suggest me
    My Jdev :- 11.1.1.6.0
    Thanks In Advance
    Ramit

    I mean to say that the query is made by one or more than one schema .
    something like this:-
    Select hcsua.location , msib.description,
    hl.address1,hl.address2,hl.city,hl.state, hl.postal_code,hl.country, xmnd.part_number
    from hz_party_sites hps, hz_cust_acct_sites_all hcasa, hz_cust_site_uses_all hcsua, hz_locations hl, xxnin_moca_nmi_display xmnd, mtl_system_items_b msib
    Where hps.party_id = 176220
    And hps.party_site_id=hcasa.party_site_id
    And hcasa.cust_acct_site_id=hcsua.cust_acct_site_id
    And hcsua.site_use_code='SHIP_TO'
    And hps.location_id=hl.location_id
    and hcsua.location=xmnd.location_acct_num
    and msib.segment1=xmnd.part_number;
    when I am making SQL VO then its saying cant make attribute of this query.
    Please guide me on this.

  • How yo use SQL Query in XSLFO

    Hi Guys,
    I am customizing the PO Standard XSLFO file is there a way to execute a sql query in XSLFO ?
    Thanks
    Tom...

    Here you go.. Patch 4670662

  • How can i make the results of dos command print to text area in a gui????

    I need to get the results from a command line application to print in a text area located in a gui... i have the following code written, which should run the command... if run from a dos window, the command prints the list of what's in a jar file to the screen.... i want that info that is printed to go in a text area which i have named textBox which is global to the program.. i know textBox.appends() is what i should use but how do i retrieve the info from the dos window to put in the appends method?
    The code is below for the method..
    Thanks,
    DH
         /*     Runs the DOS Command for listing a JAR File     */
         public void jarList ( ) // Needs To Be Fixed!!
              listFieldText = listField.getText();
              String command;      
              command = "jar tf " + listFieldText;
              System.out.println(command);
              Runtime rt = Runtime.getRuntime();
              try
                   Process child = rt.exec(command);
                   child.waitFor();
                   System.out.println("Process exit code is: " + child.exitValue());
              catch(IOException e)
                   System.err.println("IOException starting process!");
              catch(InterruptedException e)
                   System.err.println("Interrupted waiting for process!");
    }

    Replace child.waitFor()with:          BufferedReader br=new BufferedReader(new InputStreamReader(child.getInputStream()));
              String s="";
                    while((s=br.readLine())!=null) {
                        textbox.append(s);
                    }Mark

  • How to obtain sql query result in JavaScript

    hello, i want to know if this is possible : i have a Javascript function that make this:
    var szPLANT = document.getElementById("hid_Plant").value;
       var szLINE = document.brs_Line.getSelectedItem();
       var cell = document.brs_Cell.getSelectedItem();
       var GetLineDownload = document.GetLineDownload.getQueryObject();
       document.GetLineDownload.getQueryObject().setParam(1,szLINE);
       document.GetLineDownload.getQueryObject().setParam(2,cell);
       document.GetLineDownload.executeCommand();
    but i to catch the result of the sql ...to use in another things in this function...how to to this?..like this:
    result = document.GetLineDownload.results
    regards
    Mário

    Mario,
    your script suggests that you are using a iCommand query. The iCommand is used to execute a query that does not return a value, like an update, insert or delete query.
    If you are expecting a result, you would normally use an iGrid, and then you can use the functions that Suresh proposed to read out the result cells. If you do not want the iGrid to be displayed, but only need the values in your JavaScript, then you can omit the "DisplayTemplate" parameter in your iGrid so it won't be displayed on the web page.
    You can however read the values from the iCommand also by using the function "iCommand.getValue(Col, Row)".
    Please have a look at [http://help.sap.com/saphelp_xmii120/helpdata/en/44/d91ad2d06f3ee2e10000000a114a6b/content.htm].
    Michael
    Edited by: Michael Otto on Nov 13, 2009 1:25 PM

Maybe you are looking for