Diff betwn Substitution and Dynamic Variable

Hi All,
As I'm new in hyperion planning I'm not able to figure out the difference between Substitution and Dynamic user variable. does anyone have any explanation with an example.. :(

Hi,
Substitution variables act as global placeholders for information that changes regularly.
Each variable has a value assigned to it that can be set and changed centrally on the Analytic Services server at any time. When you are creating a substitution variable it depends on the requirement that variable is going to used for all application and its database or for particulaer apllication and its databases.
Substitution variables are especially useful when you are developing and reporting on rolling forecasts.
You can also use substitution variable in web form , business rules.
Substitution variable is created in Essbase but from 11.1.2.2 we can create substitution variable from workspace.
There is nothing named as Dynamic User variable. If i am not wrong you are asking about user variable.
User variables act as filters in data forms, enabling planners to focus only on the members they are interested in, such as departments in a particular division. Before you can associate a user variable with a data form, you must create the user variable.
User variable can increase performance by helping planners focus on certain members.
It is available in the File -> New -> User variable. It is also available in the Administration -> Manage -> User Variable.
Hope this helps.
Regards
SST.....
Edited by: ss1988 on Mar 1, 2013 2:14 AM
Edited by: ss1988 on Mar 1, 2013 2:16 AM

Similar Messages

  • Variable Substitution and Dynamic Configuration

    Hi All,
    In Variable Substitution , the name that should be given the the receiver payload should be part of the Source Payload unlike the Dynamic Configuration wherein the file name can be generated dynamically during mapping.
    I have the following questions
    1.Dont we need to write the UDF for the Variable substitution?
    2.Cant we do the Dynamic configuration without writing UDF?If so then how?
    3.In Dynamic Configuration the file name is generated dynamically.But where does the file name come from if it is not the part of the source payload?
    Thanks in advance

    Hi Shwetha,
    1.Dont we need to write the UDF for the Variable substitution?
    No. Here we are accessing the contents of the payload to the target. So no UDF required.
    2.Cant we do the Dynamic configuration without writing UDF?If so then how?
    Yes and No.
    Because we can set only few Dynamic configuration  values without UDF.
    If both source and target are File, then check ASMA on both sender and receiver. Then u can get the source directory name and source file name for target also without any UDF.Also some other parameters.
    3.In Dynamic Configuration the file name is generated dynamically.But where does the file name come from if it is not the part of the source payload?
    The file name comes along with the source in the payload as a attribute in header. U can view this in SXMB_MONI, and Dynamic Configuration.
    In Dynamic Configuration the file name is generated dynamically.
    No the file name is taken as it is from the source, if u want to change dynamically that u have to do in a UDF.
    I hope this will clear all doubts,
    If nt pl post
    Babu

  • What is the difference btwn Variable Substitution and Dynami Configuration

    Hi Gurus
    Could you please explain the difference between the Variable Substituion and Dynamic Configuration.
    whn shall we use them and in what scenarios?
    thanx in advance

    Please go through this blog
    /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name
    Also this
    /people/madanmohan.agrawal/blog/2009/05/20/combining-three-different-aspects-of-pi-asma-af-module-and-variable-substitution-in-one-shot
    Edited by: Baskar Gopal on Mar 31, 2011 9:04 AM

  • AS2 syntax and dynamic variable names

    Hi all,
    Trying to learn AS2 and hoping someone can help me by
    explaining the problems with the following sample code and what
    would be needed to make it work (i.e. to create dynamic variables
    and movie clips from an array).
    Thanks for your time!

    kglad: Thanks for the super-quick and tremendously helpful
    response! Much appreciated!
    A couple of quick follow-up questions:
    kglad wrote that "createEmptyMovieClip() returns a reference
    to the created movieclip".
    How would I use/access this reference?
    Also, in the updated code below, I have two issues:
    1. rolling over a movie clip yields "this is button
    undefined" rather than "this is button a" for example; and
    2. clicking on a movie clip outputs the result of the trace
    command for all four clips (in reverse order) rather than just the
    one clicked.
    Any insights into what I need to do differently? Thanks
    again!

  • Credit Management: Difference Between Static and Dynamic Credit Check

    Hi,
    Could anyone tell the difference Between Static and Dynamic Credit Check?
    According to website: http://www.sap-basis-abap.com/sd/difference-between-static-and-dynamic-credit-check.htm ... this is the answer:
    ====================
    Simple Credit Check : Tr.Code - FD32
    It Considers the Doc.Value + Open Items.
    Doc.Value : Sales Order Has been saved but not delivered
    Open Item : Sales Order has been saved , Delivered, Billed & Transfered to FI, but not received the payment from the customer.
    Static Credit Check it checks all these doc value & check with the credit limit
    1) Open Doc.Value / Sales Order Value : Which is save but not delievered
    2) Open Delivery Doc.Value : Which is delivered but not billed
    3) Open Billing Doc.Value : Which is billed but not posted to FI
    4) Open Item : Which is transfered to FI but not received from the customer.
    Dynamic Credit Check         1) Open Doc
                                                2) Open Delivery
                                                3) Open Billing
                                                4) Open Items
                                                5) Horizon Period = Eg.3Months
    Here the System will not consider the above 1, 2, 3 & 4 values for the lost 3 months.    
    ====================
    Question 1: Could you further explain the above information, if there is any?
    Question 2:: What is the Tcode to customize settings of:
    a) Simple Credit Check (isn't this same with b) below?)
    b) Static Credit Check
    c) Dynamic Credit Check

    Hi Tanish,
    Diff between Static and Dynamic Filters.
    Example One at report Level.
    Create a variable for a Infoobject say ,Material .
    1)In the Query Designer and if u restrict it to some 10 materials at query level, the report will display for only those 10 materials only.This is Static Filter.UR AHrdcoding it to those materials.You cant change them at Query Run time.i.e not changeable by user.
    2)If u give the variable as input ,and when u run the query ,u can can choose the material,may 10 may be 1 or may 20 .It is dynamic.Changeable by user at run time
    Example Two at DTP and Start Routine Level,say Document Type.
    1)If u give filters in Start routine it is Static as u cannot change it in Production,not changeable by user.
    2)f u give filters in DTP it is Dyanamic as u can change it in Production.U can give any doc type,Changeable by user at run time.
    Hope it is Understood.
    Rgds
    SVU

  • 11.1.1.6.11  /  Essbase Substitution Variables / RPD Init Block / Dynamic Variables

    11.1.1.6.11  /  Essbase Substitution Variables / RPD Init Block / Dynamic Variables
    How do I update the Init Block which is populated with the Essbase Substitution variables.   This is dynamically created the first time I import an Essbase cube and is populated with the Substitution variables when it is first imported into the RPD.   If later on new Substitution variables are added, they are not being reflected in the Init Block or its dynamic variables.  I have done the re-import of the data source with no change to the Init Block Dynamic Variables.   How do I get these new Substitution variables imported?
    It appears that the only way is to delete it from the Physical Layer, however this deletes any changes I have made to Cube in the physical layer.

    So delete it from the Physical Layer, change the Substitution Variables associated with the cube.   Import it back into the physical layer.   It does NOT delete existing Init Block Dynamic variables that no longer exist as Substitution variables.  

  • Dynamic variable names and invalid_character_err

    I'm neither an expert at structure notation nor dynamic
    variable naming conventions and would appreciate any help with the
    following. Thanks!
    This code works fine.
    <cfset idx="123">
    <cfset form.product[idx]=StructNew()>
    <cfparam name="form.product[idx].product_nm"
    default="Raspberry Jam">
    <cfform name="data_entry" method="post" format="flash"
    height="525" width="675" action="formdump.cfm">
    <cfformgroup type="tabnavigator" height="400"
    width="650">
    <cfformgroup type="page" label="Product #idx#">
    <cfinput name="static_form_name" type="text"
    label="Product" value="#form.product[idx].product_nm#" height="350"
    width="600" readonly="yes">
    </cfformgroup>
    </cfformgroup>
    </cfform>
    The following code results in the following error:
    "ORG.W3C.DOM.DOMEXCEPTION ERROR. Message: INVALID_CHARACTER_ERR: An
    invalid or illegal XML character is specified." The only change is
    in the "name" attribute of the <cfinput> tag:
    <cfset idx="123">
    <cfset form.product[idx]=StructNew()>
    <cfparam name="form.product[idx].product_nm"
    default="Raspberry Jam">
    <cfform name="data_entry" method="post" format="flash"
    height="525" width="675" action="formdump.cfm">
    <cfformgroup type="tabnavigator" height="400"
    width="650">
    <cfformgroup type="page" label="Product #idx#">
    <!--- Change value of name attribute from
    "static_form_name" to "product[idx].product_nm" --->
    <cfinput name="product[idx].product_nm" type="text"
    label="Product" value="#form.product[idx].product_nm#" height="350"
    width="600" readonly="yes">
    </cfformgroup>
    </cfformgroup>
    </cfform>
    Pam Grieger
    [email protected]

    Thanks for the info. Knowing what WON’T work is
    helpful!
    Here’s what I’m trying to do. I’m rewriting
    one of my apps, switching out conventional HTML form controls for
    <cfform> controls in Flash format. Many of the existing forms
    in my app are for updating data contained in a central database.
    When such a form is rendered to the screen, each form control is
    pre-populated with existing data. All form controls are named
    dynamically based upon the unique ID of the record being updated.
    Here’s a streamlined but typical example:
    <!--- User selected projects 14, 15, 16, and 17 for
    update. Get existing project data. --->
    <cfquery name="get_project_detail"
    datasource="#application.DataSource#">
    SELECT project_oid_nbr, project_nm
    FROM project_table
    WHERE project_oid_nbr IN (14,15,16,17)
    ORDER BY project_oid_nbr
    </cfquery>
    <!--- Initialize the project_nm form control. Form names
    are dynamic, based upon get_project_detail.project_oid_nbr. --->
    <cfloop query="get_project_detail">
    <cfparam name="form.project_nm_#project_oid_nbr#"
    default="#get_project_detail.project_nm#">
    </cfloop>
    <!--- Create HTML form control. --->
    <table>
    <cfloop query="get_project_detail">
    <tr>
    <td>
    <cfoutput>
    Project #project_oid_nbr#:
    <input type="text" name="project_nm_#project_oid_nbr#"
    value="#Evaluate("form.project_nm_#project_oid_nbr#")#">
    </cfoutput>
    </td>
    </tr>
    </cfloop>
    </table>
    This has been working just fine. However, I’m wondering
    if using the Evaluate() function is the most efficient way to go.
    Therefore I wanted to use structure notation to avoid the
    Evaluate() function, but as mentioned in my original post, this
    naming convention won’t work with <cfform> tags.
    Any suggestions as to the most efficient way to get the same
    result while still using <cfform> tags? Thanks so much!

  • Dynamic Variables and New-Object - in a GUI

    so, i have not found anything that i can parlay into a solution for what i am attempting to do.  
    Basically i am using powershell to build a GUI to manage websites on various servers.  
    in a nutshell:
    - i have an array with the servers i want to query
    - a foreach loop gets me the site names for each server (number of sites can vary on a server).
    - need put checkboxes on a GUI for every site to do something (25-30 sites across 8 servers).
    currently i am passing the $dir.name variable to a function that will create the new variable using this command:
    $pName = $dir.name New-variable -name $pName -value (New-Object System.Windows.Forms.CheckBox)
    $pName.Location -value (New-Object System.Drawing.Size(10,$i))
    $pName.Size -value (New-Object System.Drawing.Size(100,20))
    $Pname.Text -value $dir.name
    $groupBox.Controls.Add($pName) 
    Problem is i am not able to do anything with my newly created variable.  I am trying to use the following code to position the new checkbox but i get nothing (same for text, size, etc.)  I am not seeing any errors, so i don't know what i have going
    wrong.  
    is this even possible?
    I am able to create static checkboxes, and i can create dynamic variables.  But i can't mix the two...

    Here is how we normally use listboxes to handle form situations like this one.  The listboxes can automatically select subgroups.
    The hash of arrays can be loaded very easily with a script or the results of the first list can be used to lookup and set the contents of the second.
    Notice how little code is actually used.  This is all of the setup code needed aside from the from definition:
    $FormEvent_Load={
    $global:serversToSites=@{
    Server1=@('S1_SITE1','S1_SITE2','S1_SITE3')
    Server2=@('S2_SITE1','S2_SITE2','S2_SITE3')
    Server3=@('S3_SITE1','S3_SITE2','S3_SITE3')
    $listbox1.Items.AddRange($serversToSites.Keys)
    $listbox1_SelectedIndexChanged={
    $listbox2.Items.Clear()
    $listbox2.Items.AddRange($global:serversToSites[$listbox1.SelectedItem])
    $listbox2_SelectedIndexChanged={
    [void][System.Windows.Forms.MessageBox]::Show($listbox2.SelectedItem,'You Selected Site')
    Here is the complete demo form:
    [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
    [System.Windows.Forms.Application]::EnableVisualStyles()
    $form1 = New-Object 'System.Windows.Forms.Form'
    $listbox2 = New-Object 'System.Windows.Forms.ListBox'
    $listbox1 = New-Object 'System.Windows.Forms.ListBox'
    $buttonOK = New-Object 'System.Windows.Forms.Button'
    $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
    $FormEvent_Load={
    $global:serversToSites=@{
    Server1=@('S1_SITE1','S1_SITE2','S1_SITE3')
    Server2=@('S2_SITE1','S2_SITE2','S2_SITE3')
    Server3=@('S3_SITE1','S3_SITE2','S3_SITE3')
    $listbox1.Items.AddRange($serversToSites.Keys)
    $listbox1_SelectedIndexChanged={
    $listbox2.Items.Clear()
    $listbox2.Items.AddRange($global:serversToSites[$listbox1.SelectedItem])
    $listbox2_SelectedIndexChanged={
    [void][System.Windows.Forms.MessageBox]::Show($listbox2.SelectedItem,'You Selected Site')
    $Form_StateCorrection_Load=
    #Correct the initial state of the form to prevent the .Net maximized form issue
    $form1.WindowState = $InitialFormWindowState
    $form1.Controls.Add($listbox2)
    $form1.Controls.Add($listbox1)
    $form1.Controls.Add($buttonOK)
    $form1.AcceptButton = $buttonOK
    $form1.ClientSize = '439, 262'
    $form1.FormBorderStyle = 'FixedDialog'
    $form1.MaximizeBox = $False
    $form1.MinimizeBox = $False
    $form1.Name = "form1"
    $form1.StartPosition = 'CenterScreen'
    $form1.Text = "Form"
    $form1.add_Load($FormEvent_Load)
    # listbox2
    $listbox2.FormattingEnabled = $True
    $listbox2.Location = '237, 26'
    $listbox2.Name = "listbox2"
    $listbox2.Size = '120, 134'
    $listbox2.TabIndex = 2
    $listbox2.add_SelectedIndexChanged($listbox2_SelectedIndexChanged)
    # listbox1
    $listbox1.FormattingEnabled = $True
    $listbox1.Location = '13, 26'
    $listbox1.Name = "listbox1"
    $listbox1.Size = '120, 134'
    $listbox1.TabIndex = 1
    $listbox1.Sorted = $true
    $listbox1.add_SelectedIndexChanged($listbox1_SelectedIndexChanged)
    # buttonOK
    $buttonOK.Anchor = 'Bottom, Right'
    $buttonOK.DialogResult = 'OK'
    $buttonOK.Location = '352, 227'
    $buttonOK.Name = "buttonOK"
    $buttonOK.Size = '75, 23'
    $buttonOK.TabIndex = 0
    $buttonOK.Text = "OK"
    $buttonOK.UseVisualStyleBackColor = $True
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($Form_StateCorrection_Load)
    #Clean up the control events
    $form1.add_FormClosed($Form_Cleanup_FormClosed)
    #Show the Form
    $form1.ShowDialog()
    You can easily substitute  CheckedListbox if you like checkboxes.
    ¯\_(ツ)_/¯

  • Spry XML data set and dynamic post variables

    Hi,
    I am trying to create an XML data set that has dynamic post
    variables.
    Everytime something is pressed on the page a variable changes
    and I then want to reload the XML data set using the new variable.
    I know I can just pull in an XML with all possible variables
    and filter client side but this would make it way too large.
    Does anyone know what I may need to do.
    I tried this:
    var myVar = 0;
    var dss = new Spry.Data.XMLDataSet (
    '../../cgi-bin/server_details.pl' , 'top' , { method: 'POST' ,
    postData: sid=ajaja21&ip=127.0.0.1&cid=' . myVar ,
    subPaths: [ "auth" , "plugins" , "plugins/plugin" ] , keepSorted:
    "true", sortOnLoad: "plugins/plugin/order", sortOrderOnLoad:
    "descending", useCache: false, loadInterval: 10000 } );
    onclick="myVar=1";
    But the script doesn't understand the post variables sent (it
    does when I remove the . myVar part and put in a static value). I
    think it isn't sending that dynamic variable with the post
    variables.
    Any ideas anyone?
    Thanks

    Well I had it working when I stripped back everything and
    just had the dss data set and a single onclick function, but now
    that I put it back together it hash foobared again.
    Here are the relevant bits of code that I've changed.
    The function to change server id:
    //function to run when changing the server id
    function changeServer ( sid ) {
    //set the url to use the current server id
    dss.setURL = ( '../../cgi-bin/server_details.pl' , { method:
    'POST' , postData:
    'sid=7gv1m3vjvagfl7h7qeefb8iodj8evhmb&ip=127.0.0.1&cid='+sid
    //force a reload of the server data
    dss.loadData();
    The inital load of the data set
    var dss = new Spry.Data.XMLDataSet (
    '../../cgi-bin/server_details.pl' , 'yams' , { method: 'POST' ,
    postData:
    'sid=7gv1m3vjvagfl7h7qeefb8iodj8evhmb&ip=127.0.0.1&cid=0' ,
    subPaths: [ "auth" , "plugins" , "plugins/plugin" ] , keepSorted:
    "true", sortOnLoad: "plugins/plugin/order", sortOrderOnLoad:
    "descending", useCache: false, loadInterval: 10000 } );
    And the part that changes the server id
    <td align="left" style="cursor:default; width:174px;"
    onclick="changeServer({dsv::servers/server/@id})">{dsv::servers/server/name}</td>
    I checked that the function is receiving the correct server
    id and I even tried hard coding the cid variable to 2 in the change
    function but it still wasn't changing on the server side.
    Any ideas?
    Thanks

  • I want to use system and job variables to make the information dynamic in the Email Subject Line

    Someone could mention the subject line character limitation needs to be expanded. 50 chars is not much to work with! 
    Is it possible to make SUBJECT Line to make , use system and job variables to make the information dynamic , Right now there is a limit for Characters in the Subject line ... is it possible to expand ???  

    I've encountered the same issue and worked around it by using generic variables that would always be the same for a certain email alert. eg =  "System XYZ -source file delay for :"
    So a sample subject would then be: 
    Where ENV = DEV/UAT etc.
    This functionality allows you to use generic alert templates for all filewait jobs, and just filling in the variables.
    A slight problem is that although this works very well, the use of group variables in email / alert actions is (/ wasn't) officially supported by Cisco when I last ran it past then. Cisco, any update in this?

  • Dynamic variable and/or XML LazyLoader HELP

    I am loading images via xml lazyloader into my air app
    I need var b to be "img" +  item.id dynamically
    any ideas???
    for each (var item : LoadingItem in lazy.items)
                        var b : Bitmap = lazy.getBitmap(item.id);
                        addChild(b);
    If you dont know the lazyloader code then can you please explain how to create a dynamic variable for a bitmap???

    so i should set type here
    var img:bitmap = {}
    then create the variable like this in my for statement?
    img[this[item.id]] = lazy.getBitmap(item.id);
    lets say item was 1,2,3
    Then
    img[1]
    img[2]
    img[3]
    would be able to hold a different bitmap
    thanks in advanced

  • Substitution vs bind variable

    Hi,
    Can you please give me the differences between substitution vs bind variables? I have done many searches and I am lost. Any examples would be great.
    Thanks.
    -U

    Perhaps what is needed is a simple example of both.
    h2. Substitution Variables
    The clue here is in the name... "substitution". It relates to values being substituted into the code before it is submitted to the database. These substitutions are carried out by the interface being used. In this example we're going to use SQL*Plus as our interface...
    So let's take a bit of code with substitution variables:
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn return varchar2 is
      2    v_dname varchar2(20);
      3  begin
      4    select dname
      5    into   v_dname
      6    from   dept
      7    where  deptno = &p_deptno;
      8    return v_dname;
      9* end;Now when this code is submitted...
    SQL> /SQL*Plus, parses the code itself, and sees the "&" indicating a substitution variable.
    SQL*Plus, then prompts for a value for that variable, which we enter...
    Enter value for p_deptno: 20
    old   7:   where  deptno = &p_deptno;
    new   7:   where  deptno = 20;... and it reports back that it has substitution the &p_deptno variable for the value 20, actually shoing us the whole line of code with it's value.
    This code is then submitted to the database. So if we look at what the code is, now created on the database we see...
    SQL> select dbms_metadata.get_ddl('FUNCTION', 'MYFN', USER) from dual;
    DBMS_METADATA.GET_DDL('FUNCTION','MYFN',USER)
    CREATE OR REPLACE FUNCTION "SCOTT"."MYFN" return varchar2 is
      v_dname varchar2(20);
    begin
      select dname
      into   v_dname
      from   dept
      where  deptno = 20;
      return v_dname;
    end;The database itself knows nothing about any substitution variable... it just has some fixed code with the value we supplied, that SQL*Plus substituted when we compiled it.
    The only way we can change that value is by recompiling the code again, and substituting a new value for it.
    Also, with substitution variables we don't necessarily have to use them just for 'values' (though that it typically what they're used for)... we can use them to substitute any part of the code/text that we are supplying to be compiled.. e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(x in number, y in number) return number is
      2  begin
      3    return &what_do_you_want_to_return;
      4* end;
    SQL> /
    Enter value for what_do_you_want_to_return: y*power(x,2)
    old   3:   return &what_do_you_want_to_return;
    new   3:   return y*power(x,2);
    Function created.
    SQL> select dbms_metadata.get_ddl('FUNCTION', 'MYFN', USER) from dual;
    DBMS_METADATA.GET_DDL('FUNCTION','MYFN',USER)
    CREATE OR REPLACE FUNCTION "SCOTT"."MYFN" (x in number, y in number) return number is
    begin
      return y*power(x,2);
    end;It really does substitute the substitution variable, with whatever text you type.
    So, that's substitution variables. In summary they are variables that the user interface detects and prompts for text to substitute into the code before submitting it to the database.
    h2. Bind Variables
    Bind variables are a completely difference concept to substitution variables.
    Bind variables typically relate to SQL queries, and are a placeholder for values within the query. Unlike substitution variables, these are not prompted for when you come to compile the code.
    Now there are various ways of supplying bind variables, and I'll use a couple of examples, but there are more (such as binding when creating queries via the DBMS_SQL package etc.)
    In the following exaxmple:
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_deptno in number) return varchar2 is
      2    v_dname varchar2(20);
      3    v_sql   varchar2(32767);
      4  begin
      5    v_sql := 'select dname from dept where deptno = :1';
      6    execute immediate v_sql into v_dname using p_deptno;
      7    return v_dname;
      8* end;
    SQL> /
    Function created.The ":1" is the bind variable in the query.
    If you examine queries running in the database you will typically see bind variables represented as :1, :2, :3 and so on, though it could be anything preceded by a ":" such as :A, :B, :C, :X, :FRED, :SOMETHING etc.
    When the query is passed to the SQL engine (in this case by the EXECUTE IMMEDIATE statement), the query is parsed and optimised and the best execution plan determined. It doesn't need to know what that value is yet to determine the best plan. Then when the query is actually executed, the value that has been bound in (in this case with the USING part of the execute immediate statement) is used within the execution of the query to fetch the required data.
    The advantage of using bind variables is that, if the same query is executed multiple times with different values being bound in, then the same execution plan is used because the query itself hasn't actually changed (so no hard parsing and determining the best plan has to be performed, saving time and resources).
    Another example of using bind variable is this:
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_deptno in number) return varchar2 is
      2    v_dname varchar2(20);
      3  begin
      4    select dname
      5    into   v_dname
      6    from   dept
      7    where deptno = p_deptno;
      8    return v_dname;
      9* end;
    SQL> /
    Function created.Now, this isn't immediately obvious, but what we have here is the ability of the PL langauge to seamlessly integrate SQL within it (giving us PL/SQL). It looks as though we just have an SQL statement in our code, but in reality, the PL engine parses the query and supplies the query to the SQL engine with a bind variable placeholder for where the PL variable (parameter p_deptno in this case) is within it. So the SQL engine will get a query like...
    select dname
    from   dept
    where  deptno = :1and then the PL engine will handle the binding of the value (p_deptno) into that query when it executes it, as well as dealing with the returning value being put INTO the PL variable v_dname. Again the SQL supplied to the SQL engine can be optimised and re-used by code because it isn't hard coded with values.
    So, here, the binding of values is implicit because the PL engine is removing the need for us to have to code them explicitly.
    The other advantage of using bind variables is that you don't have to worry about the datatypes.
    Often we see people creating code such as this (going back to a similar dynamic SQL example)...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_hiredate in date) return number is
      2    v_empno number;
      3    v_sql   varchar2(32767);
      4  begin
      5    v_sql := 'select empno from emp where hiredate = to_date('||to_char(p_hiredate,'DD/MM/YYYY')||',''DD/MM/YYYY'')';
      6    execute immediate v_sql into v_empno;
      7    return v_empno;
      8* end;
    SQL> /
    Function created.... where the developer is trying to concatenate in a date or varchar variable with the appropriate single quotes and formatting required to make the SQL make sense. Not only does that prevent the SQL explain plan from being re-used with different values, but it makes the code hard to maintain and get right in the first place (as well as leaving things open to SQL injection)
    But, with bind variable, that's not necessary... simply doing...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_hiredate in date) return number is
      2    v_empno number;
      3    v_sql   varchar2(32767);
      4  begin
      5    v_sql := 'select empno from emp where hiredate = :1';
      6    execute immediate v_sql into v_empno using p_hiredate;
      7    return v_empno;
      8* end;
    SQL> /
    Function created.... is all that is needed.
    The SQL engine knows that it is expecting a DATE datatype for the value because of what it's being compared against, and the USING statement is supplying a value of DATE datatype. No messy need to play with date formats or quotes etc. it just simply works. (and the same with other datatypes).
    So, that's bind variables. In summary they are placeholders in queries that allow SQL queries to be soft parsed rather than hard parsed when the query is re-used, help prevent SQL injection, and allow for the values to be supplied easily and seamlessly by the issuing code.

  • Binding dynamic variable in XQuery doesn't work: ORA-00932

    I have a table with several columns. One of those columns is a XMLType.
    My goal is to have a query which selects rows from the table of which the XML column matches certain criteria.
    I'm trying following example (JDBC) : http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_xquery.htm#insertedID11
    First, I created my own query, which looks like:
    select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement[contains(Element, "someValue")] return "true"' passing t.xmlColumn)This works as expected. Next, as done in the example, I'm trying to replace the "someValue" with a dynamic variable.
    Query then looks like:
    select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement[contains(Element, $val)] return "true"' passing t.xmlColumn, :1 as "val")This does not seem to work, neither in SQLDeveloper nor in java.
    I always get the :
    java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got CHAR(SQLDeveloper just gives ORA-00932)
    When I put $val between quotes (so "$val") then I get no error, but then I get no results either.
    I think it will not replace $val in that case but just use it as a literal, so thats not what I want
    I also tried to remove "contains" xpath and use the exact same example as on the oracle page
    select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement/Key = $val return "true"' passing t.xmlColumn, :1 as "val")But this doens't help either.
    I'm clueless about this, so any help would be appreciated
    Edited by: user5893566 on Nov 29, 2008 6:24 AM

    Ok, I tested it using the latest enterprise edition (11g) and there it works as expected.
    However, on 10.2.0.1.0 and 10.2.0.3.0 it gives this error.
    Is this a bug which has been fixed or should I do something special on 10g ?
    I installed all of these as normal without any special settings, created the tables and ran the query...

  • How do I use a dynamic variable from a prolog script?

    I have my test broken in to three scripts, a login, an update, and a logout. There is a dynamic variable, SERVICE_VIRTUAL_CLIENT, from the login script that I need to use in the update script, but I can't figure out how to do it. Any help would be appreciated.
    Edit: I forgot to mention that the login script is only run in the prolog portion of the UDP.
    Scott
    Message was edited by: scottmorgan

    Scott,
    You would do this the same way you would in a stand-alone script. Create the variable pattern in the login in script and name the variable. Save the login script and open the other script and select the parameter where you need the value. Set the parameter value to {{variableNameFromLogin}} (Variables are transferred from one script to the next in a UDP).
    I hope this makes sense

  • Dynamic variable Time for Select

    Hi,
    I try to develop some scripts but always I have the same problem , when I try to put in a Select instruction the variable Time, it doesn´t work correctly (for example):
    *SELECT(%example%,"ID","TIME","[ID]='%TIME_SET%' ")
    It doesn´t read correctly the variable Time_Set.
    Have you got any idea to try to do selects using dynamic variable?
    Thanks for all.

    Hi,
    Dynamic variables like %TIME_SET% do not interact very well with the compiled default logic (LGX files) when it is run after a data send. If you look at the Default.LGX file, you will notice that your *SELECT statement does not appear there because that *SELECT statement has already been compiled. That is why the logic works when it is run via the debugger (because the LGF file is getting executed at run time) and it does not work when it is run via a data send (because the LGX is being executed).
    What you will need to do is:
    1. Create a another logic file (for example: Calculation1.LGF) and copy the text from the Default.LGF to this new logic file.
    2.  Place the following text in the Default.LGF file:
    *RUNLOGIC
    *LOGIC=Calculation1.LGF
    *ENDRUNLOGIC
    3. Validate and save the Default.LGF file
    Now try running the logic after a data send and see if that works.
    Good luck,
    John

Maybe you are looking for