Passing value of variable in SQL

Hi,
How to pass the value of variable from a shell script in the oracle sql command...,
for eg :
say echo $name returns 'test1'..
then, how i can pass this 'test1' for a tablespace_name column for a select query in dba_data_files view....
Also, can this be performed in a ddl statement?,
Pls help..thanks!

can this be performed in a ddl statement?It can be done with any sql statement :
$ cat test.sh
sqlplus -s test/test << EOF
create table $1 (a number, b varchar2(20));
exit
EOF
$ ./test.sh foo
Table created.
$ sqlplus test/test
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Jun 25 15:26:46 2007
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> desc foo
Name                                      Null?    Type
A                                                  NUMBER
B                                                  VARCHAR2(20)
SQL>

Similar Messages

  • Issue while Passing Values to Variable Dynamically in ODI

    Hi All,
    We are trying to pass values to ODI variable dynamically. The value passed is File path. We are successfully able to achieve this when we are passing the relative path i.e. ‘..\demo\xml’ but while we are trying to pass the absolute path i.e. ‘D:\ODI\oracledi\demo\xml\’ we are getting the below given error in the Load step of the interface..
    com.sunopsis.sql.SnpsMissingParametersException: Missing parameter
    at com.sunopsis.sql.SnpsQuery.completeHostVariable(SnpsQuery.java)
    at com.sunopsis.sql.SnpsQuery.updateExecStatement(SnpsQuery.java)
    at com.sunopsis.sql.SnpsQuery.executeQuery(SnpsQuery.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenario.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.i(e.java)
    at com.sunopsis.dwg.cmd.g.y(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Googling for the same has yielded the following results :-
    •     if the file name has : in it then ODI will consider it as a binding variable rather path. .. So try relative path. – Relative Path is working but we need to achieve this by giving absolute path.
    •     make sure you are using LKM File to SQL rather SQL to SQL. – We have tried by 3 different LKMS—File to SQL, SQL to SQL and SQL to Oracle but the error is same in all.
    Any pointers regarding the same will be very helpful.
    Thanks In Advance.
    Regards,
    Abhishek Sharma

    Hi Cezar,
    Thanks for the response. The issue here is we are picking this path from a table. We have FILE_PATH column in one database table and in ODI variable we have given SQL query as 'Select FILE_PATH from tablename'. Then we are taking the refresh value of this variable and passing it on to our interface.
    If the Path in table is given as relative path it works , else for absolute path it doesnt work. How can we achieve the solution recommended by you in this case. The FILE_PATH value in table may change, so we need to pick the file from whatever path it fetches from the select statement. Hence we cannot hard code it here.
    Please suggest.
    Thanks Again.
    Regards,
    Abhishek Sharma

  • How to pass values to variables in WAD 7.0 using java script

    Hi.,
    My requirement is based on WAD 7.0.
    The sales value has to displayed in WAD using graph with various chart types.
    I have created variables for plant and material group in a query.
    I have created drop down box for plant with all plants in it, check box for material group and a Submit button in WAD in FORM tag of HTML coding.
    Once all the values are set in drop down box, checkbox and if the user clicks on submit button, the values has to captured by the variables for which I have created and the graph has to be aligned to the new values in variables.
    Kindly help me how to use java script to get the values from FORM and pass it to variables.
    Regards,
    Selva

    Hi Selva,
    You do not need to use Javascript for this. Instead you can achieve this by using API Commands in WAD 7.0.
    Please configure Action on the ButtonGroup webitem to use 'Commands'.
    ->Choose Command 'Set Variables Values / SET_VARIABLES_STATE' under Commands for Web Templates
    ->Set Display Variable Screen setting to OFF
    ->Choose Query Variable for Plant, Select Variable Type as 'Binding Type', Binding Type as 'Data Provider Selection', Data Provider as the one you have assigned to the Dropdown webitem, Characteristic as 0PLANT or as that assigned to the Dropdown webitem
    ->Repeat above steps for Query Variable Material Group
    Now when you make a selection from the Dropdown webitems, the Chart output will change accordingly. Let me know if this helps.
    --Priya

  • Can we pass value of variable in Authorware5.2 to Flash 5

    Hi,
    I want to pass value of one variable which is in the
    Authorware5.2 to Flash 5. Depending on that value i want to
    duplicate the Movie clip.
    Is it possible and How?
    Thanks in advance.

    I urge you to look at the documentation for the Flash sprite
    as it will
    answer your question. #property can be a range of values.
    Place a Flash sprite, get its properties, click the Options
    button,
    click Help...
    Erik
    Jeevan_N_Salunke wrote:
    > Hi,
    > Using SetSpriteProperty(@"SpriteIconTitle", #property,
    value) we can changes
    > the properties of Sprite, but I want to pass one value
    to Flash 5 i.e. Sprite
    > and depending on that value I want to do some
    processing.
    >
    > For Example.
    > Suppose Flash file contain Dynamic text box who's
    variable name is "my_txt"
    > and when i load the Sprite Icon or by clicking on button
    displays the Sprite,
    > at that time i want to pass some txt to that (my_txt)
    variable.
    >
    > Please suggest me the solution.
    >
    >
    Erik Lord
    http://www.capemedia.net
    Adobe Community Expert - Authorware
    http://www.macromedia.com/support/forums/team_macromedia/
    http://www.awaretips.net -
    samples, tips, products, faqs, and links!
    *Search the A'ware newsgroup archives*
    http://groups.google.com/groups?q=macromedia.authorware
    *The Blankenship Caveat: Note that direct linking to http
    content
    through any Authorware icon will likely fail if a proxy
    server is present!*

  • Passing a Date variable to SQL

    Hi,
    I am trying to pass in a Date variable into SQL query, but I am getting this error:
    "inconsistent datatypes: expected DATE got NUMBER"
    and my code looks like this. I would appreciate any help on how I need to create the Date variable that SQL would accept it.
    THANKS A LOT!
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    String txt = "01/01/1990";
    java.util.Date startYear2 = (java.util.Date) formatter.parse(txt, new ParsePosition(0));
    java.sql.Date startYear = new java.sql.Date(startYear2.getTime());
    String txt2 = "12/31/1990";
    java.util.Date endYear2 = (java.util.Date) formatter.parse(txt2, new ParsePosition(0));
    java.sql.Date endYear = new java.sql.Date(endYear2.getTime());
    String scoredGoalsQuery = "SELECT count(name) from player_goal_rel where name = '" + pName + "' and pdate BETWEEN "+ startYear +" and "+ endYear;
    ResultSet scoredGoalsResult = stmt.executeQuery(scoredGoalsQuery);

    You should be using prepared statements.
    String scoredGoalsQuery = "SELECT count(name) from player_goal_rel where name = ? and pdate BETWEEN ? and ?":
    PreparedStatement pstmt = connection.prepareStatement(scoredGoalsQuery);
    pstmt.setString(1, pName);
    pstmt.setDate(2, startYear);
    pstmt.setDate(3, endYear);
    ResultSet scoredGoalsResult = pstmt.executeQuery();

  • How to swap column values using variable in sql?

    Hi,
    I have a table and i want to swap two column values using variable
    please help me

    Hi,
    Let us assume that the DeptNAME and DeptNo columns are of type VARCHAR2. However, DeptNO column is VARCHAR2(10) and DeptNAMe is VARCHAR2(100).
    First of all DeptNo column needs to be modified to be 100.
    i) ALTER TABLE DEPT MODIFY DEPTNO VARCHAR2(100);
    Secondly, you will swap DEPTNAME and DEPTNO values using the SQL as follows:
    ii) update dept t1
    set deptname = (select deptno from dept2 t2 where t1.deptno = t2.deptno),
    deptno = (select deptname from dept2 t2 where t1.deptno = t2.deptno);
    Now, finally you want the deptname columns to be VARCHAR2(10)
    iii) ALTER TABLE DEPT MODIFY DEPTNAME VARCHAR2(10).
    If DEPTNO is a NUMBER column, you cannot alter the datatype unless the table is empty; in that case the whole swapping requirement would be moot.
    Trinath Somanchi,
    ( http://www.myospages.com )

  • How to import values from txt and pass values to variables

    I need to export some variables from Indesign and import them in Illustrator.  I can export a txt file from InDesign but I don't know how to import and pass the values to variables in Illustrator.
    Can someone help?

    Well from you ID script Im presuming that you are simply writing a few lines of info to a plain text file like so…
    writeFile('SomeData');
    writeFile('AnotherData');
    writeFile('LastData');
    function writeFile(info) {
         try     {
              var log = File('~/Desktop/ID_Data.txt');
              log.open('a');
              log.write(info + '\r');
              log.close()
         catch (e) {
              alert(e);
    So you would just read this back where or when ever you need to use it in your Illustrator script…
    var log = File('~/Desktop/ID_Data.txt');
    log.open('r');
    var a = log.readln();
    var b = log.readln();
    var c = log.readln();
    log.close();
    alert(a);

  • Call function, pass value, access variable in movieclip class from main stage

    i am new to flash as.
    I got quite confused on some problems. as the function here
    is quite different from c and asp.net.
    I have a movieClip named MC, and it's enabled with action
    script, with the class name MC_Rectangle
    and a Stage.
    I override the MC_Rectangle class file in a mc_rectangle.as
    external file.
    here is the code:
    package{
    import flash.display.*;
    import flash.events.*;
    public class MC_Rectangle extends MovieClip {
    var sequence:int = new int();
    function setSequence(data:int):void{
    sequence = data;
    function addSequence():void{
    sequence ++;
    I have new a object in the main stage var
    mc_rect:MC_Rectangle = new MC_Rectangle()
    question:
    in main stage:
    1. how can i access the variable "sequence" in "mc_rect"
    2. how can i pass parametre from main stage to mc_rect via
    function setSequence(data:int)?
    3. how can i call the function in addSequence() in mc_rect.
    in asp.net, i usually use mc_rect.sequenct,
    mc_rect.setSequence(data), mc_rect.addSequence() to achieve my
    goals......
    btw, can function in mc_rect return out result to main stage?
    thanks in advance.

    Your as-file must be named MC_Rectangle.as (same upper/lower
    case as in the Class name)
    Ad 1) You have to declare sequence as a public property
    "public var sequence;" or - better - define a getter-function for
    sequence.
    Ad 2) mc_rect.setSequence(8); e. g. (you must write "public"
    in the Class-declaration of setSequence)
    Ad 3) mc_rect.addSequence(); e. g. (you must write "public"
    in the Class-declaration of addSequence)
    ... and yes, your methods can return a value: Replace "void"
    with the proper data type (int, String, ...) and place a "return
    myNumber;" or the like in the method's body.

  • Passing values to anonymous pl/sql block error

    Hi,
    I have update_table.sql sql script which updates the table MST_TOT. The sql script is being called from
    unix shell script in loop with 2 parameters values. 1. str# 2. rtl#.
    e.g. The shell script will call 5 time sql script with different str# and rtl#.
    update_table.sql
    DECLARE CURSOR cur_qty IS
    SELECT
    COL1,
    COL2
    FROM MST_DTL
    WHERE
         AND STR = &1
         AND RTL = &2;
    l_COL1 NUMBER;
    l_COL2 NUMBER;
    BEGIN
    OPEN cur_qty;
    LOOP
    FETCH cur_qty INTO l_COLtrans_dt, l_COL1, l_COL2;
    EXIT WHEN cur_qty%NOTFOUND;
    UPDATE MST_TOT
    SET item_total = l_COL1
    WHERE str_num = &1
    AND rtl_co_num = l_COL2
    END LOOP;
    CLOSE cur_qty;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    ROLLBACK;
    END;
    Problem: It completes first sql call and terminates with following error.
    old 32:      AND STR = &1
    new 32:      AND STR = 40
    old 33:      AND RTL = &2
    new 33:      RTL = 12
    PL/SQL procedure successfully completed.
    SP2-0042: unknown command "48|12|" - rest of line ignored.
    Any suggetion?
    Thanks in advance!!
    Dip

    At first sight I miss the semicolon at the end of your update statement:
    UPDATE MST_TOT
    SET item_total = l_COL1
    WHERE str_num = &1
    AND rtl_co_num = l_COL2;Additionally there may be a problem with your &-variables.
    If the columns/values are of varchar type you should put them into quotes inside your code:
    e.g.
    AND STR = '&1'

  • Passing shell script variable to sql file by reference (bind variable)

    Hi All,
    I need to import around 50 files every 15 minutes into my target table.
    I am using shell script and call procedure to do transform.
    I used crontab to do this automate task.
    Here is my shell script and sql file:
    shell script:
    #!/bin/sh
    export ORACLE_HOME=/u01/app/oracle/product/9.2.0.4.0
    export PATH=$ORACLE_HOME/bin
    find /path_rawfile/rawfile -iname raw\*.in > myfile.lst
    nfile=1
    while [ true ]
    do
    read iFile #read a line
    if [ $? -ne 0 ] #Break if EOF
    then
    break
    fi
    #$PATH/sqlplus -s /NOLOG @load_raw.sql $iFile
    #/bin/mv -f $iFile /path_rawfile/rawfile/done/
    done < myfile.lst
    sql file:
    connect test/test@evn1
    set serveroutput on
    variable filename varchar2(50)
    begin
    :filename := '&1';
    exec my_tranform(:filename);
    dbms_output.put_line(:filename);
    end;
    exit;
    Even I used bind variable pass to procedure my_transform...
    But when i query in sys.v_$sqlarea, the :filename:='&1' still hard parse to sqlarea.
    One filename one statement and keep increasing ..
    Could everyone help me to change it to bind varialbe(soft parse)?
    I would like to incresae my database performance.
    Thanks in advance.
    Cheer
    Message was edited by:
    lux

    It is the procedure.
    It's my fault.
    Here is my SQL file again:
    conn test/test@evn1
    variable filename varchar2(500);
    exec :filename:='&1';
    exec my_transform(:filename);
    exit;
    I call this sql file from shell script and call in loop due to i need to load all file one time.
    Once i use <<EOF it raise error that's why when I deleted it.
    Anyway, what I need to do here is to use bind variable (soft parse).
    Since I need to load around 50 files every 15 minutes.
    exec :filename:='&1'; this statmet have found hard parse in v_$sqlarea.
    I would like to change this to bind varialbe.
    Thanks again for your help.

  • Passing Session State Variables to SQL query

    Hi,
    I am using 3 pages in my application build by APEX 3.1.2. Login Page, Report Page and Form Page.
    I am using LDAP authentication for Login Page and I want the user session information to be feeded to the filter query
    being used to display data on Report Page. Is there any way to do that. I know
    there is one variable %LDAP_USER% which is using the userid given on login
    page. But I dont know how to use APEX session variables to filter query. Need
    assistance on that stuff.
    Thanks,
    Gaurav

    Hi Gaurav,
    Session "variables" (global items, application items and page items) can be accessed using v('ITEM_NAME') (for strings) or nv('ITEM_NAME') (for numbers) within sql queries/procedures/triggers etc.
    If you look at the Substitution Strings section here: http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/index.htm#S you'll find more information about this and a list of items that you can use that are set by Apex itself.
    Andy

  • Passing values and calling PL/SQL process via a column link

    Hello all
    I have a report and a link on one of the columns which takes you to another page and passes data from the report to that page. That all works fine. In addition to picking up the details from the report I'd also like the link to call a page process before it goes to the next page using some of the values picked up from the report. This I can get to work by changing the link to a URL and putting in some javascript ie javascript:doSubmit('TEST_PROCESS'); By doing this I "lose" the ability to pass the info from the report via the link.
    Can anyone give me a clue as to how I can achieve both please? I'm assuming I'll need to create my own javascript function but I don't know how to pick up information from a row in a report to pass on.
    Regards
    Helen

    Lets say your link would pass 2 items P1_ITEM and P1_ITEM2 to your process. Just write a quick javascript function to do this and put it in the header:
    <script type="text/javascript">
    function doSomething(pValue1,pValue2){
      $s('P1_ITEM',pValue1);
      $s('P1_ITEM2',pValue2);
      doSubmit('TEST_PROCESS');
    </script>This will set 2 hidden items equal to whatever you pass in. Then you can use these in your after-submit process. To call this from your url, just make the url:
    javascript:doSomething(#COL1#,#COL2#);#COL1# and 2 being your report columns. This should do what you need i think

  • Pass value text variables

    Hello… 
    I have the following slope in a development, have 2 variables of user exit for 0calmonth (present period and previous period), simultaneously I have 2 text variables (ZADVME06) that fill from the previous variables (to also user exits). 
    When control the value by Web, of the following way.  &TEMPLATE_ID=ZADWEB0197A&VAR_NAME_1=ZADVME02&VAR_VALUE_EXT_1=09.2006. 
    The problem is when control to call the value of this form the text variables do not fill, with which the headed one of the table shows: 
    <b>Sales
    (&ZADVME06&)</b>
    Somebody to had east problem and since it has been able to solve it?   
    Greetings and thanks.

    this should work
    <FORM NAME="searchForm" METHOD="post"
    ACTION="results.cfm">
    <input type="Text" name="TextQuery" size="30">
    <input type="submit">
    <cfoutput>
    <INPUT TYPE="Hidden" NAME="TextQuery2"
    value="#TextQuery#">
    </cfoutput>
    </FORM>
    <cfquery>
    SELECT titl
    FROM info
    WHERE
    titl LIKE '%#form.textquery#%'
    <cftry>
    <cfloop from="1" to="#listlen(form.textquery2)#"
    index="i">
    AND titl like '%#ListGetAt(form.textquery2, i )#%'
    </cfloop>
    <cfcatch type="any" />
    </cftry>
    </cfquery>

  • Not able to pass values to variables in extended Tree class

    Hi,
    I have a as class that extends from Tree, additionally this
    custom class defines
    new class level variables as follows:
    public class MyTree extends Tree {
    public var arrayColl:ArrayCollection;
    and i call this tree from mxml as follows:
    <customTree:MyTree
    arrayColl={list}
    xmlns:customTree="../../.*"/>
    Though my 'list' collections is not null, when i place an
    alert in the constructor of extended tree class
    it shows as null.
    Please advice.
    Thanks,
    Lucky

    below is the canvas:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import mx.collections.IViewCursor;
    import mx.collections.ArrayCollection;
    import com.citi.ascript.TreeData;
    import mx.controls.Alert;
    import com.citi.ascript.CitiTree;
    public var availableTreeDataColl:ArrayCollection;
    public var selectedTreeDataColl:ArrayCollection;
    public var treeData:TreeData;
    public var srcTree:CitiTree;
    public var availableTreeDataArray:Array = [{a:1},
    {b:2},
    {c:3}
    public function formTreeData():void {
    var tempColl:ArrayCollection = new
    ArrayCollection(availableTreeDataArray);
    availableTreeDataColl = new ArrayCollection();
    for (var i:int=0; i<tempColl.length; i++) {
    var tempTreeData:Object = tempColl
    treeData = new TreeData();
    treeData.a = tempTreeData.a;
    treeData.b = tempTreeData.b;
    treeData.c = tempTreeData.c;
    availableTreeDataColl.addItem(treeData);
    ]]>
    </mx:Script>
    <mx:VBox>
    <mx:Label text="Drag &amp; Drop the analysis sections
    that you would like to include in the report" width="450"
    height="20"/>
    <mx:HBox id="treeContainer"
    creationComplete="formTreeData();">
    <customTree:MyTree treeList={availableTreeDataColl} //
    here collection becomes null.
    </customTree:MyTree>
    </mx:HBox>
    </mx:VBox>
    </mx:Canvas>
    The collection of TreeData is iterated in the customTree to
    form xml which will act as dataprovider for tree.
    and this canvas is added as a child for a panel in my main
    application.
    Hope this gives an idea.
    Thanks,
    Lucky

  • Passing Global Variable in Sql Object

    Hi
    How can i pass my global variable into SQL object? I tried to pass it but then I tried to update the schema it giving me the error at varble
    Please advise me

    The Update schema is used only to get the structure for the Output.
    Once you have a valid structure and the SQL Parses without any variables use the syntax for applying variables as in any Script within DI.
    $GV_MyVar enclosed within square brackets will be replaced by Value of the variable.
    $GV_MyVar enclosed within curly brackets will be replaced by Value of the variable enclosed in single quotes.
    When the job runs, the variables will be replaced with values OR values with quotes. It is at this time, the SQL send to the database is validated for syntax.
    Therefore, you will not know the validity of your SQL with Global Variables until you run the job.
    Hope this helps!
    Thanks & Regards
    Tiji
    Edited by: Tiji Mathew on May 8, 2009 3:40 PM
    The actual syntax was being posted as a link. edited to make the text descriptive.

Maybe you are looking for

  • How can I print out the file directory?

    Years ago, I could print out a list of files in a folder from the finder window. Is there now a workaround utility to do that? I don't want to use screen shots, as the directory is too long and would require several screen shots.  thx.

  • How capture the value selected in the component ( Select Many Choice )

    Hello Everyone , I am new to ADF and i have a ADF page developed with Select Many Choice as one of the component , this field can be multiple numbers , i would like to capture each one the value being selected under each message choice and print them

  • Report on Schedule Agreement

    Hi All, I have a requirement to understand the Schedule line wise level open qty, qty delivered, qty PGId & qty invoiced, something similar to a Sales order line item's document flow, i cant use VBFA or VBAP referring the SA line item as it is consid

  • Problems with the WD2GO app from Western Digital

    I have a Western Digital Mybooklive and have downloaded the WDPhoto and WD2Go apps. The WDPhto app works perfectly, however the WD2Go app doesnt. I have been in discusson with WD and they have put forward numerous suggestions but I have found nothing

  • Runtime error when i open iTunes

    basically, i open iTunes, and get this error....i hit OK and it terminates the program... here's the error.. (in the title bar) "Microsoft Visual C++ Runtime Library" "Runtime Error! Program: c:/program files/iTunes/iTunes.exe This application has re