Need to get select result into a shell variable.

Hi,
I want to get below command output into a OS variable. Which will be used later in the shell script. Can you please advice how to go about it?
VAR v_tool_execution_id NUMBER;
EXEC :v_tool_execution_id := trcanlzr.trca$p.get_tool_execution_id;
SELECT TO_CHAR(:v_tool_execution_id) tool_execution_id FROM DUAL;
I can't do following
VAR1=`sqlplus -s $unpwd <<EOF
VAR v_tool_execution_id NUMBER;
EXEC :v_tool_execution_id := trcanlzr.trca$p.get_tool_execution_id;
SELECT TO_CHAR(:v_tool_execution_id) tool_execution_id FROM DUAL;
EOF`
Since tool execution is specific to session and exiting will not server my purpose since i need to run another command which generates a file name using tool execution id.
Thanks for your time.
Regards,
Nagendra Chillale

Actually the idea is the same. Instead of getting the variable into a shell script, call the shell script which use the variable from sqlplus. I attempted to include the line to call a shell script but had a mistake :P
The last line should be
SQL> host /path/to/second/part.sh &exec_idAnother way is to spool the variable into a file, then read the file into a variable in your shell script. You need to use head / tail command to extract the desired row, because Oracle adds blank lines, headers, etc in its spool output
In your SQL script
SQL> spool tool_execution_id.txt
SQL> SELECT TO_CHAR(:v_tool_execution_id) tool_execution_id into :vtemp FROM DUAL;
SQL> spool offIn your shell script (the desired line appeared in the second last line in my case)
tool_execution_id=`tail -2 tool_execution_id.txt|head -1`
echo $tool_execution_idEdited by: thtsang on Mar 30, 2010 11:43 AM

Similar Messages

  • HT201263 i need to get my iphone into recovery mode with a broken home button and is disabled, my exgirlfriend has the laptop i synced it with, what should i do??

    i need to get my iphone into recovery mode with a broken home button and is disabled, my exgirlfriend has the laptop i synced it with, what should i do??

    i have the same probelm did u get it solved if yess how ?

  • I need to divide selected row into multiple rows when i navigate  ADF 11g

    Hi
    I'm using jdeveloper 11.1.1.2.0 with ADF 11g.
    I need to divide selected row into multiple rows when i navigate to other page . Scenario - in first page i'm displaying some records with columns like empno , empstatus , empworkdepts ,curdepts
    Here empworkdepts gives the numeric number like no of departments work shifts 3 or 4 or 5. when i select any particular employee and fire next button to navigate next page.I have to divide the selected employee with same information into multiple times based on the empworkdepts value.
    empno empstatus empworkdepts curdept
    001 eds 2 TS
    002 hr 1 FO
    003 eds 4 TS
    *004 eds 3 TS*
    now i selected employee 004 , when i navigate to next page.
    Empno EmpStatus EmpWorkDepts CurDept
    004 eds 3 TS
    004 eds 3 TS
    004 eds 3 TS
    i did with java code in bean .but not stable .
    any help............
    thanks advance.............
    Edited by: user9010551 on May 5, 2010 10:48 PM
    Edited by: user9010551 on May 10, 2010 11:31 PM

    user9086775 wrote:
    Hi Experts,
    I have a requirment where i need to fetch parts of a single row into multiple rows from a singlt Query, i am sure it is possible using Pivots but just cant figure out an approach. Any help on this is highly appriciapted.
    Requirment:
    This is a sample set record in a table
    Product     Sub Product          Name    Age
    New Car    Nissan                   Tom        49
    New Car    Nissan                   Jack         36
    Old Car      Audi                     Sam         24
    Old Car      Jaguar                  Pint          26
    Old Car      Audi                     Smith       41
    I need to be able to fetch the above data in the below fashion
    Product     Sub Product          Name    Age
    New Car
    Nissan
    Tom        49
    Jack        36
    Old Car     
    Audi            
    Sam        24
    Smith      41
    Jaguar                   Pint         26Please help with ideas as to how can i achive the above without using PLSQL.
    Thanks in advance!You should be doing this in the client on not in the DB. Use the reporting tool that you use to do this.
    For example if you are in SQL Plus you can use the BREAK command.

  • How can i get select result in varray

    Hi,
    I am new in oracle. I have the following sproc it return around 500 records but OCCI takes long time to get all records due to one-by-one records fetch.
    TYPE rec_type is record ( f1 integer, f2 integer, f3 integer,f4 integer );
    TYPE id_rec_type IS REF CURSOR RETURN rec_type;
    PROCEDURE get_s_data (
    v_s IN VARCHAR2,
    v_p IN INTEGER ,
    v_d IN INTEGER ,
    o_cd OUT NUMBER ,
    o_id OUT id_rec_type ) IS
    BEGIN
    DECLARE
    v_start_date DATE;
    BEGIN
    select get_start_date(TO_CHAR(SYSDATE,'DD-MON-YYYY') ,-1* v_d ) into v_start_date from dual;
    OPEN o_id FOR
    SELECT f1 , f2 , f3, f4
    FROM T1
    WHERE s1 = v_s
    AND timestamp >= v_start_date;
    END;
    I want to convert above sproc in VARRAY/Table to utilize bulk fetch
    I am not sure how to convert multicolumns select result in varray.
    example in document use only one column in varray from select statement.
    some exmple use cursor with bulk fetch but problem is cursor need to define in declare section.
    I have one condition in where clause and get calculate in sproc.
    any suggestion?

    thanks for reply.
    It doesn't work with ref cursor as output parameter in sproc.
    Please see my post in OCCI forums.
    Performance problem with sproc and out parameter ref cursor
    after spending some time found one way.
    prcedure p1 ( i1 IN integer , i2 IN integer, v1 OUT varray_type )
    declare
    cursor c1 is
    select c1 , c2 , c3 , c4
    from t1
    where c1 > i1 and c2 > i2;
    begin
    open c1;
    fetch c1 bulk collect into v1;
    close c1;
    end;
    procedure p2 ( v1 OUT varry_type )
    declare
    i1 integer
    i2 integer
    begin
    i1 := new_calculate_value(i2);
    i3 := calculate_s(i2);
    p1(i1,i3,v1);
    end;
    above method allow us to calculate where clause value before cursor define and get filter data.
    I am working OCCI to get varray from above method.

  • Getting Step Results into Labview

    Hi,
    I'm having what seems to be an easy problem but one which I cannot figure out quickly.
    I'm trying to do the following. I am trying to do some custom logging to a specific format for my Teststand results. I'd basically like to pass the Results parameters of each step into Labview Code where I will process there. To make it more user friendly I have created a Callback for SequenceFilePostResultListEntry. What I don't exactly know how to do is get the Results from the current step into LabVIEW
    At first I used the SequenceContext.PreviousStep but that did not give me what I needed. Hopefully I'm clear in what I am asking.
    Thanks for the help,
    Patrick

    Hi Patrick,
    Are you having trouble doing this with a LabVIEW Adapter Action Step?  If you are trying to pass specific run-time values to your LabVIEW VI, you will be able to find them by setting breakpoints and looking at the available variables.  
    For example, in your SequenceFilePostResultListEntry callback, if you wanted to use the test's Status result as an input to your LabVIEW Adapter Action Step, you could use the expression RunState.Caller.Step.Result.Status as the value you pass.
    Please let me know whether this answers your question.
    Warm Regards,
    Daniel D.
    National Instruments
    Automated Test Software R&D

  • What cord to I need to get a video into iMovie?

    What cord do I need to get video into iMovie? I have a Canon HDV video camera, a Thunderbolt to FireWire adapter but not a cord from the camera that matches. I am using a Macbook Air.

    You need a Firewire DV cable like this one.
    Russ

  • Bex : Get KF result in a formula variable

    Hi,
    I'd like to get the global result of a Key Figure into a formula variable but i see no way to do it...
    This is to use this variable in an exception so as to color the individual results in comparison with the result caught in the variable...
    if u have any idea.
    Thanks.

    Hi,
    Try using SUMCT, SUMGT,SUMRT which are there in data functions in query designer.
    You need to first create formula and then use SUMCT,SUMGT, SUMRT.
    Hope it helps.
    Praveen Tati

  • Assign SQL select result to a java variable

    In a custom IKM, I need to check the LOGGING setting of target table, save the setting, then change the setting, then restore the setting.
    I am having problem saving the setting. I do something like the following, where tgtLogging is the current LOGGING setting of the target table. I need to save the value to sTgtLogging so that it can be accessed in a later step. I can't figure out the syntax. just saying sTgtLogging = tgtLogging does not work either in the pl/sql or the <% %> context.
    <%
    String sTgtLogging = "";
    %>
    declare
    tgtLogging varchar(5);
    begin
    select logging into tgtLogging from dba_tables where table_name='<%=odiRef.getPop("TABLE_NAME")%>';
    some other code.....
    end;
    Edited by: user611482 on Jul 8, 2010 3:34 PM

    Hi,
    we use this for saving the login time of the user. There are few therads about creating a custom login module (for example: [Custom Login Module - how to go on |http://forums.sdn.sap.com/thread.jspa?threadID=357616]).
    We have created a login module which extends AbstractLoginModule, in login() method :
    public boolean login() throws LoginException  {
    Object option = g_sharedState.get("javax.security.auth.login.name");
    if (option != null && !option.equals(""))  {
      String l_userID = (String)option;
      IUserAccount l_account = UMFactory.getUserAccountFactory().getUserAccountByLogonId(l_userID);
      IUserAccount mutableAccount = accountFactory.getMutableUserAccount(account.getUniqueID());     
      l_mutAccount.setLastSuccessfulLogonDate(new Date());
      l_mutAccount.commit();
    about login modules and login stacks start here: [http://help.sap.com/saphelp_nw04/helpdata/en/8c/f03541c6afd92be10000000a1550b0/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/8c/f03541c6afd92be10000000a1550b0/frameset.htm]
    Hope this helps,
    Romano

  • How to select data into multiple bind variables

    Hi,
    I need to load data into multiple bind variable how to do that
    As of now i am using this
    select a , b into :a, :b from dual
    But i want even a to be loaded into both :a and :c also b to be loaded into :b and :d Please suggest
    Thanks
    Sudhir.

    Thanks much it worked
    Thanks
    Sudhir

  • How to execute a function and return the result into a bind variable

    Hi,
    I am trying to calculate the sum of salaries of all persons with a particular JOB_ID using a function TOTAL_INCOME(v_job_id).
    create or replace function total_income
    +(v_job_id IN varchar2)+
    RETURN number IS
    v_total number(6);
    cursor get_sal is
    select salary from employees
    where job_id = v_job_id;
    BEGIN
    v_total := 0;
    for emp in get_sal
    loop
    v_total := v_total emp.salary;+
    end loop;
    dbms_output.put_line('Total salary of '||v_job_id||' is: '|| v_total);
    return v_total;
    END;
    Now I woud like to execute this function and assign the returned value into a bind variable test_sal
    variable test_sal number(6)
    SELECT total_income('AD_VP') into :test_sal FROM DUAL;
    dbms_output.put_line('Total Sal:'||:test_sal);
    This is returning the below errors:
    SELECT total_income('AD_VP') into :test_sal FROM DUAL
    *+
    Error at line 0
    ORA-01036: illegal variable name/number
    dbms_output.put_line('Total Sal:'||:test_sal);
    Error at line 3
    ORA-00900: invalid SQL statement
    Could someone help me what could be the problem?? Thanks for your time...

    Dear,
    If everything you will do will be done inside PL/SQL (stored procedure or stored function) then you don't have to care about bind variable.
    When using PL/SQL (static SQL) you will never encounter issues related to bind variables. PL/SQL itself takes care of your code and uses bind variables behind the scene.
    The only situation where you have to look carefully to the use of bind variables within PL/SQL is when you use Dynamic sql into stored procedures or functions.
    So, see in the light of the above comment, if you have to care about returning your function into a bind variable?
    Best regards
    Mohamed Houri

  • How to get the results for given Bind Variable

    Hi
    Can any one help me how to get the result rows from the View Object after executing the view object query by setting bind variable?
    snippet as follows
    viewObject.setNamedWherClauseParams("name","hei");
    viewObject.executeQuery();
    How to get the results from viewObject is my question..?
    Thanks in advance

    Should be something like
    while (vo.hasNext()){
    Row r = vo.next();
    r.getAttribute....
    You might want to read the "most commonly used methods" appendix in the ADF Developer Guide.

  • Complete novice needs help getting SQL Query into Crystal Reports XI

    Post Author: MissMarnie
    CA Forum: Data Connectivity and SQL
    So I was given an intro level web course and a monster reference guide in prep to format a report. One of our developers wrote me everything I need for the report into a SQL Query and now I'm supposed to format it in CR XII literally do not know what to do from here. I'm able to set up the correct server as a datasource, if that's useful, but I don't know how to make the querey into a bunch of formattable fields in  CR. If anyone can walk me through this, I'd be so grateful. I've attempted to look up SQL query in both the help and the book but I keep hitting a wall. The help dialog says things like "press this button" with no reference to what "this button" is. I'm sure it's obvious to the knowledgeable but I'm in a complete fog. Thanks in advance   

    Post Author: synapsevampire
    CA Forum: Data Connectivity and SQL
    IF you're trying to get assistance with setting up a query as the source for a report, try posting your Crystal version and the database type.
    Different software works differently.
    In CR 9 and above, under the connection to the database you'll see Add Command. Select that and you can paste the query in.
    As for not knowing how to generate a report, that requires experience, there's no generic solution of course..
    -k

  • What kind of cable do I need to get digital video into my Imac?

    I just purchased a JVC Mini DV video camera "GR-D347U" refurbished, just to get the feel of bringing digital video clips into Imovie and combining them with still clips and music. The camera came with just the AV cables and I was wondering what I need to port the video over to my Imac. There wasn't much help on their web site. They do offer a DV cable, that what I am looking for? Thanks for your help.
    Dick Skover

    Nearly all MiniDV cameras have a 4pin Firewire connector. Looking at the manual (link) for the JVC confirms that. 
    Macs all have the 6pin Firewire connector (and later iMac have 9pin connectors too) so you simply need a 4pin-to-6pin Firewire cable like this (example).
    Once connected simply load iMovie and click import.
    regards
    mrtotes

  • My old PC blow and I need to get my music into Itunes on new laptop

    My old PC blow up and I want to know how to get my Ipod music on my new laptop. I down loaded the new Itunes version and used my ID but none of my stuff is there. I am afraid that if I plug in my Ipod I will loose my music.
    How do I transfer the Ipod music into my Itunes?

    Don't worry about plugging the iPod into the computer, the first time you do iTunes will say that the iPod is synced with another computer and ask if you want to erase it and sync it with this computer. Click no or its equivalent and don't worry about it.
    After that, you can use iTunes to transfer content purchased from the iTunes Store from your iPod to your new computer. It should be under the File menu.
    If you did not buy everything on your iPod at the iTunes Store, take a look here before you transfer just the purchased content, http://www.everymac.com/systems/apple/consumerelectronics/ipodfaq/transfer-copy-songs-ipod-to-computer.html or just google transfer from ipod to computer and select your OS of choice.

  • Rookie needs help getting WMA files into itunes

    I bought a Olympus digital recorder. The files are WMA files and I cannot figure out how to get them into my itunes. Any advice?
    thanks

    Have a look at EasyWMA audio converter. You can convert the files to an iTunes friendly format and import them, in fact the program has a setting that will add the files to iTunes for you: EasyWMA

Maybe you are looking for

  • How to make On Account Payment

    Hi all, How to make On Account Payment. What is the difference between On Account Payment and Down Payment Thanks

  • Convert data to MSWORD, MSEXCEL or PDF

    Hi, I have a requirement of sending SAP std report output as an attachment via email. I am thinking of using SUBMIT TO MEMORY or SPOOL and then get the data from there and convert and send as file attachment using SO_DOCUMENT_SEND_API1 or class CL_BC

  • Licensing serial number required every time I open Aperture

    I have recently purchased a new iMac and transferred my Aperture over to this new computer. Now every time I open Aperture it asks me to enter the licensing serial number before opening the program. How can I stop this from happening?

  • When transporting multiproviders and cubes transport failed.

    HI Experts, When transporting cubes and multiproviders in a request the transport failed with return code 8. The described below as: Start of the after-import method RS_CUBE_AFTER_IMPORT for obje Error/warning in dict. activator, detailed log    > De

  • Writing server proxy in SAP BW

    Hi Experts,    I am new to SAP BW. I have one below requirement Third party ==> SAP PI ( JAVA STACK) 7.4 ==> SAP BW We are writing a server proxy in BW. Data from SAP PI will be sent across to SAP BW i.e. to data source. We have already got the DataS