Substitutional Variables

Q. Create a script name LOADEMP.sql to load rows into my_employee table. Concatenate first letter of firstname and first 7 characters of second name to produce the user id .
my code
INSERT INTO my_employee(id,last_name,first_name,userid,salary)
VALUES (&id ,'&lastname','&firstname',LOWER(CONCAT(SUBSTR ('&firstname',1,1),SUBSTR('&lastname',1,7))),&salary);
the code works fine on isql *plus , but when i use the sql plus command prompt it asks for the firstname and lastname twice . how can i use the value stored in the variable &firstname again without invoking it again.
i'm a newbie , please help me

SQL> var lname varchar2(50)
SQL> var fname varchar2(50)
SQL> accept lname prompt "enter last name :"
enter last name :abcdef
SQL> accept fname prompt "enter first name :"
enter first name :xxxxxxx
SQL> INSERT INTO my_employee(id,last_name,first_name,user_id,salary)
  2  VALUES (&id ,'&lname','&fname',
  3         LOWER(CONCAT(SUBSTR ('&fname',1,1),SUBSTR('&lname',1,7))),&salary);
Enter value for id: 1
old   2: VALUES (&id ,'&lname','&fname',
new   2: VALUES (1 ,'abcdef','xxxxxxx',
Enter value for salary: 1000
old   3:        LOWER(CONCAT(SUBSTR ('&fname',1,1),SUBSTR('&lname',1,7))),&salary)
new   3:        LOWER(CONCAT(SUBSTR ('xxxxxxx',1,1),SUBSTR('abcdef',1,7))),1000)
1 row created.
SQL> select * from my_employee;
        ID LAST_NAME  FIRST_NAME USER_ID      SALARY
         1 abcdef     xxxxxxx    xabcdef        1000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Assigning a value to a substitute variable

    Hi, I would like to know if it is possible to assign a value to a substitute variable.
    This is what I'm doing:
    - Prompting user for input
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    (displayed list of options are numbers 0-5)
    - Based on input, open corresponding file
    (start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql)
    Problem:
    - Default selection is 0, meaning use the CURRENT UOM system (a number, 1-5)
    - That being said, &&uom must be assigned a 1-5 value in order to open the file that corresponds to the CURRENT UOM system
    Let me know if any additional information is needed.
    Thanks!

    I apologize for the format. I tried to make it more legible, but was not able to. FYI: It appears to be easier to read in "Edit" view.
    Thanks, I tried the &&uom := your_function(); suggestion, but I am getting an error. It looks like the "value" of &&uom is being read in the assignment statement, not the variable name.
    I have copied the piece of the code, for your reference.
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    DECLARE
    v_uom_sys_selection NUMBER;
    v_curr_uom_sys VARCHAR2 (50);
    v_uom_num NUMBER;
    BEGIN
    v_uom_sys_selection := to_number(&uom);
    v_curr_uom_sys := EG.GET_CURRENT_UOM();
    v_uom_num := eg.get_user_selected_uomnum(v_curr_uom_sys);
    &&uom := to_char(v_uom_num);
    dbms_output.put_line('v_uom_num = ' || v_uom_num);
    dbms_output.put_line('&&uom = ' || &&uom);
    END;
    --prompt "&&uom"
    start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql
    Below are the results I get when commenting out the &&uom := to_char(v_uom_num); line. NOTE: the "value" of &&uom = 0.
    v_uom_num = 1
    0 = 0
    If I leave that line in, I get the following error:
    PLS-00103: Encountered the symbol "0" when expecting one of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "<an identifier> was inserted before "0" to continue.
    Message was edited by:
    user449676

  • "Save output of a query in Substitute variable"

    Hi All,
    I am using oracle11g r1 on windows platform. i want to know how can i save the output of a query in a substitute variable so that i can user that variable in other query .i am using this query and i want to store the output in *"&Schema*" variable.
    select substr('D:\activities\expLive_vikash',23,instr('D:\activities\expLive_vikash','0')-22) from dual;
    Thanks & Regards,
    Vikash chauradia(junior DBA)

    Thanks for replyng..
    i am using this in sqlplus prompt . actually i am using a batch file to cange the dump .
    DEFINE FILE_NAME=&file_name; -- This will ask the Dump file name as an input.
    declare Schema varchar2(20);
    begin
         select substr('&&file_name',23,instr('&&file_name','0')-22) into Schema from dual; -- this will give the Schema name as an output.
    dbms_output.put_line(Schema);
    end;
    Drop user &&Schema Cascade;--(Now i am facing the problem in this line. I am not getting Schema name to drop)
    Can u tell me what's the problem in this Script.

  • Substitute variables for external process activity in process flows

    Has anyone used with success substitute variables such as ${Working.Rootpath} for external process activity?
    I can't get it working. Variables aren't substituted and my scripts fail.
    Sample value for parameter_list parameter for external process I use is:
    |${Working.Rootpath}|
    and in the script I get:
    ${Working.Rootpath}
    which is of course not what I expected.

    In documentation is Working.Rootpath so there is a bug in documentation. It is ugly because it's hard to guess.
    Thank's for your reply Michael. I checked all that you described. Previously I had Working location set to "Use default location". When I changed it to actual location substitute variables started to work properly.
    If I correctly understand "Use default location" means: use location associated with process module. And for execution it works but for substitute variables doesn't. So I think it is a bug.
    Next thing is variables in the script itself. From examples sent by Mark (script: cd ${Working.RootPath}...) they should be set in environment and accessible to shell. This doesn't work for me but it is not described in documentation and can be easily achieved by passing parameters. So that's not a problem.
    One more question: Should I open tars and file bugs describing what we found?

  • How to make cursor record/variable dynamic or substitute variable

    Hi
    I have couple of cursor records define in my PL/SQL procedures, they are all same structure type.
    For example
    C_rec_1 c_currsor%ROWTYPE;
    C_rec_2 c_currsor%ROWTYPE;
    C_rec_3 c_currsor%ROWTYPE;
    C_rec_4 c_currsor%ROWTYPE;
    C_rec_5 c_currsor%ROWTYPE;
    C_comm_rec c_currsor%ROWTYPE;
    BEGIN
    fetch .... into C_rec_1;
    fetch .... into C_rec_2;
    fetch .... into C_rec_3;
    fetch .... into C_rec_4;
    fetch .... into C_rec_5;
    IF c_rec1.dept = 100 then
    C_comm_rec := c_rec1;
    END IF;
    IF c_rec2.dept = 100 then
    C_comm_rec := c_rec2;
    END IF;
    IF c_rec3.dept = 100 then
    C_comm_rec := c_rec3;
    END IF;
    IF c_rec4.dept = 100 then
    C_comm_rec := c_rec4;
    END IF;
    IF c_rec5.dept = 100 then
    C_comm_rec := c_rec5;
    END IF;
    Here rather than coding 5 IF statement, Can I make c_rec_? dynamic?
    Something like but this does not work :)
    For i IN 1..5 loop
    If c_rec_&l = 100 then
    C_comm_rec := c_rec5;
    End if
    End loop;
    END;

    Hi Jaun,
    You have to go CMOD  Transaction .
    Create a project  and then write code in the exit EXIT_SAPLRRS0_001.
    there is include
    INCLUDE ZXRSRU01  double click on it and write code like below.
    Coding for Variable
        WHEN 'ZTES'.     YOUR variable name
    if     i_step = 1
          l_s_range-LOW = sy-datum +0(6).
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
    Hope this will help you.
    Regards
    vikas saini

  • Substitute Variables VI does not work for names with underbars. What can I do?

    For example, I want to change "p_0=p_1+p_2;" into "x0=x1+x2;". However the VI does not do it and returns just the same formula. Is this the specification? I enclosed a sample VI to show it.
    Attachments:
    SubTest.vi ‏44 KB

    You problem is in "Find String Identifier" (a subVI of "Substitue Variables") - it searches your variables and tries to split any other characters out of it (it only accepts alphanumeric and spaces as variable names, not special characters - hence your "p_0" becomes "p", and then "p" is not found in your substitution rules, so the original is piped through instead.
    Copyright © 2004-2015 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.

  • Substitute Variable

    <p>Hi All</p><p> </p><p>I had defined a subtitute variable in my instant server for allapplication and all database that variable was CurrYr</p><p>but when I used variable in calculation script theb variabledidn't recognized, the error was 'Invalid member '</p><p> </p><p>I wrote script like bellow:</p><p> </p><p>FIX(&CurrYr)</p><p> </p><p>END FIX</p><p> </p><p> </p><p>Please help!!!</p><p> </p><p>Thanks</p><p> </p><p>Why</p>

    Also...if CurrYr is just a number, like 2007, you'll want to put it in quotes in the Substitution Variables dialog box:<BR><BR>Variable Name: CurrYr<BR>Value: "2007"<BR><BR>That way, when you refer to &CurrYr in your calc script, the quotes will be included. This is necessary in calcs (and filters, etc.) when referring to member names that are numeric.<BR><BR>Jared

  • Message with substitutable variables but nothing substituted into them

    I see this message and stack trace in a Faces JSP at page load time. I cannot debug it as I cabnnot get my debugger to stiop anywhere useful.
    Environment is IBM Rational Application Developer 7001.
    ---- Begin backtrace for Nested Throwables
    java.lang.IllegalArgumentException: "{2}" Conversion Error setting value ''{0}'' for ''{1}''.
         at com.sun.faces.util.Util.getSelectItems(Util.java:679)
         at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:605)
         at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:566)
         at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:500)
         at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeEnd(DefaultAjaxRenderer.java:83)
         at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:754)
         at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:492)
         at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:335)
         at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
         at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:735)
         at javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:611)
         at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:548)

    This means that one or more of the values of the f:selectItems doesn't fit in the valuebinding of the wrapped selectbox.

  • Where is explanation of variable substitution for localization files in Adobe docs???

    It's odd, I was looking over the live docs about localization in Flex and no where did I see any mention of how you could substitute variables dyanmically? For example  maybe in English I want "Welcome Rick!" but in some other language I want "Rick, Welcome!" (where "rick" as name is the dynamic portion.)
    After many google searches I found this helpful post on another site: http://soenkerohde.com/2008/07/flex-localization/
    That describes how you could do it, but shouldn't this be in the docs somewhere? Can someone point me to the adobe doc page that I'm missing. It's probably covered in some other area other than localization, but I'm not finding it.
    Thanks

    Hello Carme,
    I have not found a solution for this type of event.
    I was attempting this because the FTP site I was connecting to would DELETE a file the moment XI touched it.  So when XI (using FTP Transfer protocol) configured with a DELETE or ARCHIVE (Processing Mode), it would error off because the file was no longer on the FTP site.  I contacted the site but they refused to deactivate their script to auto-delete files.  Using TEST processing mode is not recommended per SAP in a server pool environment.  You would think SAP XI would provide a fourth option in which a DELETE command is not issued back to the FTP site.
    The FTP site did have sub-directories in which copies of the original files were stored, but I could not figure out how to dynamically change the XI Source Directory as the current date changed. 
    I settled on using File NFS (Transfer Protocol) and running the FTP commands from a .bat (batch file).  I put the command I run down at the bottom of the XI page with a 60 second timeout.
    I still do not change to each folder dynamically because the standard FTP  (GET and MGET) commands do not attempt a Delete after file retrieval.
    Perhaps using a batch file is an option you may want to consider using.
    Cheers,
    Ralph

  • Using CASE in a SQL predicate to return variable IN values ...

    Environment:
    Oracle EE 10.2.0.2 on AIX 5.3
    I am trying to use a CASE statement in a SQL predicate to fill in the values needed in an 'IN' clause.
    Here is my test case:
    create table tt (model varchar2(10), brand varchar2(10));
    insert into tt (model, brand) values ('modela','ajax');
    insert into tt (model, brand) values ('modelb','ajax');
    insert into tt (model, brand) values ('modelc','acme');
    insert into tt (model, brand) values ('modeld','acme');
    insert into tt (model, brand) values ('modele','acme');
    insert into tt (model, brand) values ('modelf','zeus');
    insert into tt (model, brand) values ('modelg','zeus');
    insert into tt (model, brand) values ('modelh','mojo');
    insert into tt (model, brand) values ('modeli','mojo');
    insert into tt (model, brand) values ('modelj','mama');
    Here is what I'm attempting to do. For a given starting letter for a brand I would like all the models printed out whose brand starts with the entered letter.
    Here is what I started with:
    select model, (case '&brandfirstletter'
    when 'a' then '(''ajax'',''acme'')'
    when 'z' then '(''zeus'')'
    when 'm' then '(''mojo'')'
    end) pred
    from tt
    where brand in
    (case '&brandfirstletter'
    when 'a' then '(''ajax'',''acme'')'
    when 'z' then '(''zeus'')'
    when 'm' then '(''mojo'')'
    end);
    When executed I get 'no rows selected'
    I wanted to print out the results of my CASE statement just to be sure it was doing what I thought I wanted.
    When I comment out the WHERE clause to see what the PRED values are I get:
    gww@dwt1> /
    Enter value for brandfirstletter: a
    old 1: select model, (case '&brandfirstletter'
    new 1: select model, (case 'a'
    Enter value for brandfirstletter: a
    old 8: -- (case '&brandfirstletter'
    new 8: -- (case 'a'
    MODEL PRED
    modela ('ajax','acme')
    modelb ('ajax','acme')
    modelc ('ajax','acme')
    modeld ('ajax','acme')
    modele ('ajax','acme')
    modelf ('ajax','acme')
    modelg ('ajax','acme')
    modelh ('ajax','acme')
    modeli ('ajax','acme')
    modelj ('ajax','acme')
    I believe this is what I want the results of the CASE statement to look like when I select 'a' for the substitute variable but I don't get the output I would like from the table.
    What am I missing?
    Thanks very much!!
    -gary

    gwicke wrote:
    select model, (case '&brandfirstletter'
    when 'a' then '(''ajax'',''acme'')'
    when 'z' then '(''zeus'')'
    when 'm' then '(''mojo'')'
    end) pred
    from tt
    where brand in
    (case '&brandfirstletter'
    when 'a' then '(''ajax'',''acme'')'
    when 'z' then '(''zeus'')'
    when 'm' then '(''mojo'')'
    end);You can't do this.
    ok, let's imagine you provide an 'a' as your substitution variable. What you get as a result is...
    select model, (case 'a'
    when 'a' then '(''ajax'',''acme'')'
    when 'z' then '(''zeus'')'
    when 'm' then '(''mojo'')'
    end) pred
    from tt
    where brand in
    (case 'a'
    when 'a' then '(''ajax'',''acme'')'
    when 'z' then '(''zeus'')'
    when 'm' then '(''mojo'')'
    end);
    so if we logically remove the case statement as oracle would do when processing...
    select model, ('(''ajax'',''acme'')') pred
    from tt
    where brand in ('(''ajax'',''acme'')');
    Are you really going to have a brand that is stored as
    (''ajax'',''acme'')as a single value?
    You can't dynamically assign values to an IN list.

  • Dynamic SQL substituting dynamic table name with slct statement having date

    Hello,
    I just wanted some help with the following PL block. My problem is whenever I try to run this block it ask for invoking values for 2 substitute variables, though no substitute variables present in the code. Please find the code below:
    Declare
    cursor C_1 is
    select unique table_name from gsi_daily_count;
    table_names varchar2(240);
    Begin
    Open C_1;
    Loop
    Fetch C_1 into table_names;
    EXIT WHEN C_1%NOTFOUND;
    EXECUTE IMMEDIATE' select last_extract_date,
    to_char(min(greatest(nvl(last_update_date,'||01-Jan-10||'),nvl(program_update_date,'||01-Jan-10||'))),'||DD-MON-YY HH24:MI:SS||') mi,
    to_char(max(greatest(nvl(last_update_date,'||01-Jan-10||'),nvl(program_update_date,'||01-Jan-10||'))),'||DD-MON-YY HH24:MI:SS||') ma
    from' || table_names ||'
    group by last_extract_date
    order by last_extract_date desc';
    End Loop;
    Close C_1;
    COMMIT;
    End;
    Please help.
    Thanks in advance.

    You cannot specify your dates the way you have since they are being intepreted as bind variables:
    Try this:
    Declare
      cursor C_1 is
        select unique table_name
        from gsi_daily_count;
        table_names varchar2(240);
    Begin
      Open C_1;
      Loop
        Fetch C_1 into table_names;
        EXIT WHEN C_1%NOTFOUND;
        EXECUTE IMMEDIATE' select last_extract_date,
                                  to_char(
                                          min(
                                                greatest(
                                                          nvl(last_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                                         ,nvl(program_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                             ),''DD-MON-YY HH24:MI:SS''
                                         ) mi
                                  to_char(
                                          max(
                                                greatest(
                                                          nvl(last_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                                         ,nvl(program_update_date,to_date('''|| '01-Jan-10' ||''',''dd-Mon-yy''))
                                             ),''DD-MON-YY HH24:MI:SS''
                                         ) ma
                          from ' || table_names ||'
                          group by last_extract_date
                          order by last_extract_date desc';
      End Loop;
      Close C_1;
      COMMIT;
    End;
    / There is not way for me to test this, so you may have to play around with all the quotes!

  • Delete with variable name

    I need to run a SQL command in one of the step in my procedure where I need to run command like >>>> Delete from TableA where Column1 LIKE 'MY_VAR' but while running its not substituting the value of MY_VAR.....Any clue how can I run command like this where I have refresh the variable before executing the procedure in the package so variable is declared before procedure execution.I dont wanna refresh the variable with Quotes around because I am using this variable in different places. Any clue how can I put quotes around MY_VAR in Like stament.
    I have also tried this>> Delete from TableA where Column1 LIKE '''MY_VAR''' but still variable value is not substituting.

    The substituted variable will never appear in the log, how are you figuring out it does not get substituted?
    In the syntax, you should use something like the following:
    Delete from TableA where Column1 LIKE '#MY_VAR'If you use the expression editor to do select the variable name, it should ensure that it is put in correctly. To see if it is actually recognised, in the log, you should see
    Delete from TableA where Column1 LIKE '#MyProject.MY_VAR'Craig

  • Write privileges on Essbase outline, substitiute and calc script variables

    Hi,
    What exact privileges need to be provision to the user\group to have the write access on outline, substitute variables and cal script without provision them to Database Manager.
    Thanks.

    To view the content of the calc, you'll have to edit it and edit needs databasemanager privileges.
    I don't think you achieve what you are looking for out-of box. So how about writing a bat file which copies the calc script to a shared folder where you can provide a read access to the users and they can view the calc scripts. (They can use text editor to view the script contents.)
    Regards
    Celvin
    http://www.orahyplabs.com

  • Eval Formula Node variable names

    I am using the Evaluate Formula node to allow programatic changes to formula
    in my data acquisiiton VI. Has anyone built any code to enable using full
    descriptive names as variables, instead of the a0 to z9 that this VI limits
    you to?

    You can replace full decriptive names with short names like a0...z9 using Substitute Variables.vi, which you will find at 'Mathmatics'->'Formula'->'Advanced Formula Analysis'.

  • Environment Variable Properties file

    Using log4j and creating a log4j properties file. "log4j.properties".. How do I specify the home directory in the properties file ? On command line I might use $HOME but I don't think that works in a properties file. I'd like any log file generated to be placed in a directory under the home directory. So the log4j.properties file needs to contain the line..
    log4j.appender.A2.File=$HOME/foo/log.txt
    But I'm seeing FNFE set file failed...

    Or, do what I should have done in the first place:
    read the API documentation for PropertyConfigurator
    where it says
    "All option values admit variable substitution. The
    syntax of variable substitution is similar to that of
    Unix shells. The string between an opening "${" and
    closing "}" is interpreted as a key. The value of the
    substituted variable can be defined as a system
    property or in the configuration file itself. The
    value of the key is first searched in the system
    properties, and if not found there, it is then
    searched in the configuration file being parsed. The
    corresponding value replaces the ${variableName}
    sequence. For example, if java.home system property
    is set to /home/xyz, then every occurrence of the
    sequence ${java.home} will be interpreted as
    /home/xyz."
    So your guess was close.Good to know I can do that with all variable names. I should have know to look at the API too. Thanks again :o)

Maybe you are looking for

  • F110 automatic Payment for Customer

    Hi, I want to pay to a customer for the credit memo thru' F110 automatic payment program. If I maintain the document number in the 'free selection' tab then there is a error during proposal *'company codes xxxx/xxxx do not appear in the proposal 04.0

  • SD related CIN transactions

    Hi SD Guru's, Can you please tell me what are the SD related CIN transactions. I am confused about this because, My client  have Sales and coordination department. This department handles all the functions related to duties and taxes. It will be very

  • Adobe AIR on iPhone OS-based Apple Tablet?

    http://www.pcworld.com/businesscenter/article/187791/quick_draw_publisher_leaks_apple_tabl et_details.html So if Flash is already on the iPhone OS, can we expect to see our Adobe AIR app running on the modified iPhone OS that will power this new Appl

  • Data being duplicated because of setModel

    hi, we are trying to show unique values on our facet filter dropdown. first time it works correctly,from second selection it starts to duplicate the snippet is as follows           var oList = oEvent.getSource();                    var sKey = oList.g

  • Two Level PR Strategy Classification Error

    Hi Gurus , I am creating a PR Strategy with Following Scenario. Two Level of Approvals : Plant manager & Plant Head. Created a Release Strategy with Classifications for Plant manager. In this i have activated a characteristic stating Total Amount of