Dynamically creating variable names in javascript

Hi.
I have to create variable names dynamically in JavaScript.
My JSP file accesses information from Database and forms a String corresponding to the information received.
This String is passed to a JAvaScript function that should CREATE a variable with that NAME.
For Ex:
My database access resulted in a single row...
id name sal
34 John Smith 38000
the resulting VARIABLE NAME should be Menu34. 34 comes from the database result.
Is there any function to dynamically create a variable name in JavaScript?
Thanks in advance.

The JSP is printing the contents of an HTML page, and Javascript code can be part of that output...
So you would just write out the stuff, something like this....
<script>
<% while(rs.hasNext()) { %>
var Menu<%= rs.getInt("id") %> = '<%= rs.getString("name") %>';
<% } %>
</script>
In the browser, it'll just look like another long list of Javascript variables.

Similar Messages

  • Creating variable names?

    hi all
    is it possible to dynamically create variable names so you can keep track of them?
    I have to generate the following code a number of times depending on a number the user has input. So ideally Id like to create
    variables whose names i can keep track of for later reuse
    eg horHatch1, horHatch2.... without hardcoding them in. is this possible?? are there any better ways of accomplishing this task?
    this code just draws and adds labels on an x axis.
    thanks
    Line2D.Double horHatch1 = new Line2D.Double(horAxis.getP1().getX() + horInterval,
                                                    horAxis.getP1().getY() - HatchLength/ 2,
                                                    horAxis.getP1().getX() + horInterval,
                                                    horAxis.getP1().getY() + HatchLength/2);
        graphics.draw(horHatch1);

    hi
    i used the following code
    but i need to convert Line"d to Line2d.Double as explained below
    for(int i=1; i<x+1; i++)
    Line2D.Double horHatch1 = new Line2D.Double(horAxis.getP1().getX() + horInterval*i,
                                                    horAxis.getP1().getY() - HatchLength/ 2,
                                                    horAxis.getP1().getX() + horInterval*i,
                                                    horAxis.getP1().getY() + HatchLength/2);
        graphics.draw(horHatch1);
         v.addElement(horHatch1);
    Add text to hatches
        decorateVerticalLine(graphics, horHatch1, "M");
        decorateVerticalLine(graphics, horHatch2, "T");
    decorateVerticalLine(graphics, (Line2D)v.elementAt(i), names.elementAt(nColumn).toString());
    //compiler complains that (Line2D)v.elementAt(i) is not of type java.awt.geom.Line2D.Double  but of   java.awt.geom.Line2Di tried :
    horizontalAxisTicks[i] =((Double)(Line2D)v.elementAt(i)).doubleValue()).getX1();
    but this isnt correct i dont think.
    thanks

  • Dynamically create variables and names

    Hi,
    I am dealing with some software that will send
    me string variables and their values. I have
    to process each variable it sends me to get
    its value. The problem is I dont know how many
    its going to send me in advance, so I cant
    hard code the varible names into my class.
    At run time I will get a int. value as to the
    number of variables. An array won't work and
    a vector wont work cause I need to process
    each variable by its name. I also know that
    each variable name will be some alpha characters
    followed by a number. For example:
    int 6
    test1
    test2
    test3
    test4
    test5
    test6
    The next time it could be 50 ...or 1 or any number....
    Is there anyway I can get my class to dynamically
    delcare String variables and their names?.......

    Just use some kind of collection. If you know the alpha characters at compiletime you can use an array - instead of test1 to test6 as in you example, you'd get test[0] to test[5]. (or test[1] to test[6] if you want the numbers to match - just create the array one bigger than needed and leave the [0] unused.) If you don''t know the alpha characters you can use a HashMap or some similar collection, and use the strings "test1", "test2" etc. as keys.
    You can also make your own class to handle this, for example by wrapping some code around an array to simplify access to your Strings.

  • Creating variable names using a counter

    Hi all
    I have a snippet of code that I am trying to work in Flash 6,
    it is attached to this post. Inside the for loop I am trying to
    define the class variable instance names dynamically using the 'i'
    counter encapsulated within the eval function. Is there anyway I
    can add dynamically named variables or am I just kidding myself.
    regards
    John Walsh
    www.javono.com

    I think KGlad meant to post the following, probably
    accidentally did italics in bbcode
    import ButtonClass;
    var a:Array= new Array("alonso_btn", "gerrard_btn");
    for (var i = 0; i < a.length; i++) {
    this[a[ i ] = new ButtonClass();
    }

  • Dynamically create variables when read from txt file

    hi,
    need a little help on this one.
    im reading in the name of user defined classes from a text file into a string array. once i have them all read in i want to be able to declare instances of each class, but how?
    i have the string array with the names and i know that il have to use a loop with a counter to give each instance a unique name but im stomped on how to do the rest.
    anyone have any ideas?
    many thanks in advance.

    im getting it in the following line:
    Class cls = Class.forNames(behList[ i ]);
    behList is a list of names, im trying to loop through
    it and create an instance of each object in the list
    using
    Object x = cls.newInstance();
    but it never gets to this line cos of the top one.
    any ideas?stupid bb codes...
    now are you sure you got that error by java and not Eclipse(or another IDE)
    cause afaik, if the VM cant find the class, it will throw a ClassNotFoundException...

  • Problem passing dynamically created variables

    Hi,
    I have a procedure in which i am creating an object dynamically and i am using that object in another package . I am calling first the procedure that creating the object and recompiling the package and calling to that package but i want to integrate them and instead of calling them individually want to call a single procedure to achieve the requirement . Here i am giving the details of the procedure and package please guide me ..
    CREATE TABLE ip_lov_hdr
    (table_id VARCHAR2(50) NOT NULL,
    table_name VARCHAR2(30) NOT NULL,
    col_name VARCHAR2(30) NOT NULL,
    codetype VARCHAR2(2))
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    ALTER TABLE ip_lov_hdr
    ADD CONSTRAINT pk_lov_hdr PRIMARY KEY (table_id)
    USING INDEX
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    CREATE TABLE ip_lov_dtl
    (table_id VARCHAR2(50) NOT NULL,
    col_name VARCHAR2(30) NOT NULL)
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    ALTER TABLE ip_lov_dtl
    ADD CONSTRAINT pk_lov_dtl PRIMARY KEY (table_id, col_name)
    USING INDEX
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    ALTER TABLE ip_lov_dtl
    ADD CONSTRAINT fk_lov_hdr FOREIGN KEY (table_id)
    REFERENCES ip_lov_hdr (table_id) ON DELETE SET NULL
    CREATE TABLE emp
    (ename VARCHAR2(50),
    empno VARCHAR2(9),
    dept VARCHAR2(4))
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    CREATE OR REPLACE
    TYPE out_rec_lov AS OBJECT(ename VARCHAR2(50),empno VARCHAR2(9))
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('titu','111','10')
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('naria','222',NULL)
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('tiks','123','55')
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('tiki','221',NULL)
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('narayan',NULL,NULL)
    INSERT INTO ip_lov_hdr
    (TABLE_ID,TABLE_NAME,COL_NAME,CODETYPE)
    VALUES
    ('emp_id','emp','ename',NULL)
    INSERT INTO ip_lov_dtl
    (TABLE_ID,COL_NAME)
    VALUES
    ('emp_id','empno')
    CREATE OR REPLACE
    TYPE out_rec_lov AS OBJECT(ename VARCHAR2(50),empno VARCHAR2(9))
    CREATE OR REPLACE
    PROCEDURE p_recordtypevariable (tab_id IN VARCHAR2,err_msg OUT VARCHAR2)
       IS
          sqlstmt             VARCHAR2 (2000);
          col_str             VARCHAR2 (2000);
          i                   NUMBER := 0;
          l_table_name        ip_lov_hdr.table_name%TYPE;
          l_col_name          ip_lov_hdr.col_name%TYPE;
          l_codetype          ip_lov_hdr.codetype%TYPE;
          l_datatype          VARCHAR2 (100);
          invalid_tableid     EXCEPTION;
       BEGIN
          BEGIN
             SELECT a.table_name,
                    a.codetype,
                    a.col_name,
                    b.data_type || '(' || b.data_length || ')'
               INTO l_table_name,
                    l_codetype,
                    l_col_name,
                    l_datatype
               FROM ip_lov_hdr a, user_tab_columns b
              WHERE UPPER (a.table_id) = UPPER (tab_id)
                AND UPPER (a.table_name) = UPPER (b.table_name)
                AND UPPER (a.col_name) = UPPER (b.column_name);
          EXCEPTION
             WHEN NO_DATA_FOUND THEN
                RAISE invalid_tableid;
          END;
          col_str := l_col_name || ' ' || l_datatype;
          FOR rec IN  (SELECT b.col_name,
                              c.data_type || '(' || c.data_length || ')' datatype
                         FROM ip_lov_hdr a, ip_lov_dtl b, user_tab_columns c
                        WHERE UPPER (b.table_id) = UPPER (tab_id)
                          AND UPPER (a.table_id) = UPPER (b.table_id)
                          AND UPPER (a.table_name) = UPPER (c.table_name)
                          AND UPPER (b.col_name) = UPPER (c.column_name) )
          LOOP
             col_str := col_str || ',' || rec.col_name || ' ' || rec.datatype;
          END LOOP;
          sqlstmt := 'CREATE OR REPLACE TYPE out_rec_lov AS OBJECT(' || col_str || ')';
          dbms_utility.exec_ddl_statement(sqlstmt);
          dbms_utility.exec_ddl_statement('alter package pkg_lov_new compile');
       EXCEPTION
          WHEN invalid_tableid THEN
             err_msg := 'Table is not defined ';
          WHEN OTHERS THEN
             err_msg := SUBSTR (SQLERRM, 1, 500);
       END p_recordtypevariable;
    CREATE OR REPLACE
    PACKAGE pkg_lov_new
    AS
    TYPE listtable IS TABLE OF out_rec_lov index by binary_integer;
    PROCEDURE p_getlov (
    tab_id IN VARCHAR2,
    col_value IN VARCHAR2,
    outlist OUT listtable,
    err_msg OUT VARCHAR2);
    END;
    CREATE OR REPLACE
    PACKAGE BODY pkg_lov_new
    AS
      PROCEDURE p_getlov (
          tab_id                     IN VARCHAR2,
          col_value                  IN VARCHAR2,
          outlist                    OUT listtable,
          err_msg                    OUT VARCHAR2)
       IS
          query_str           VARCHAR2 (2000);
          col_str             VARCHAR2 (2000);
          TYPE cur_typ IS REF CURSOR;
          c                   cur_typ;
          i                   NUMBER := 0;
          l_table_name        ip_lov_hdr.table_name%TYPE;
          l_col_name          ip_lov_hdr.col_name%TYPE;
          l_codetype          ip_lov_hdr.codetype%TYPE;
       BEGIN
          BEGIN
             SELECT table_name,
                    codetype,
                    col_name
               INTO l_table_name,
                    l_codetype,
                    l_col_name
               FROM ip_lov_hdr
              WHERE UPPER (table_id) = UPPER (tab_id);
          EXCEPTION
             WHEN NO_DATA_FOUND THEN
                NULL;
          END;
          col_str := l_col_name;
          FOR rec IN  (SELECT col_name
                         FROM ip_lov_dtl
                        WHERE table_id = tab_id)
          LOOP
             col_str := col_str || ',' || rec.col_name;
          END LOOP;
          IF l_codetype IS NULL THEN
             query_str :=    'select out_rec_lov('
                          || col_str
                          || ') from '
                          || l_table_name
                          || ' where '
                          || l_col_name
                          || ' like :col_value';
             BEGIN
                OPEN c FOR query_str USING col_value;
                LOOP
                   FETCH c INTO outlist (i);
                   i := i + 1;
                   EXIT WHEN c%NOTFOUND;
                END LOOP;
                CLOSE c;
             EXCEPTION
                WHEN OTHERS THEN
                   err_msg := SUBSTR (SQLERRM, 1, 500);
             END;
          ELSE
             query_str :=    'select out_rec_lov('
                          || col_str
                          || ') from '
                          || l_table_name
                          || ' where code_type =:l_codetype and '
                          || l_col_name
                          || ' like :col_value';
             BEGIN
                OPEN c FOR query_str USING l_codetype, col_value;
                LOOP
                   FETCH c INTO outlist (i);
                   i := i + 1;
                   EXIT WHEN c%NOTFOUND;
                END LOOP;
                CLOSE c;
             EXCEPTION
                WHEN OTHERS THEN
                   err_msg := SUBSTR (SQLERRM, 1, 500);
             END;
          END IF;
       EXCEPTION
          WHEN OTHERS THEN
             err_msg := SUBSTR (SQLERRM, 1, 500);
       END p_getlov;
    END pkg_lov_new;
    /Regards,
    Dhabas
    Edited by: Dhabas on Dec 30, 2008 5:52 PM

    CREATE TABLE ip_lov_hdr
    (table_id VARCHAR2(50) NOT NULL,
    table_name VARCHAR2(30) NOT NULL,
    col_name VARCHAR2(30) NOT NULL,
    codetype VARCHAR2(2))
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    ALTER TABLE ip_lov_hdr
    ADD CONSTRAINT pk_lov_hdr PRIMARY KEY (table_id)
    USING INDEX
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    CREATE TABLE ip_lov_dtl
    (table_id VARCHAR2(50) NOT NULL,
    col_name VARCHAR2(30) NOT NULL)
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    ALTER TABLE ip_lov_dtl
    ADD CONSTRAINT pk_lov_dtl PRIMARY KEY (table_id, col_name)
    USING INDEX
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    ALTER TABLE ip_lov_dtl
    ADD CONSTRAINT fk_lov_hdr FOREIGN KEY (table_id)
    REFERENCES ip_lov_hdr (table_id) ON DELETE SET NULL
    CREATE TABLE emp
    (ename VARCHAR2(50),
    empno VARCHAR2(9),
    dept VARCHAR2(4))
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    CREATE OR REPLACE
    TYPE out_rec_lov AS OBJECT(ename VARCHAR2(50),empno VARCHAR2(9))
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('titu','111','10')
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('naria','222',NULL)
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('tiks','123','55')
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('tiki','221',NULL)
    INSERT INTO emp
    (ENAME,EMPNO,DEPT)
    VALUES
    ('narayan',NULL,NULL)
    INSERT INTO ip_lov_hdr
    (TABLE_ID,TABLE_NAME,COL_NAME,CODETYPE)
    VALUES
    ('emp_id','emp','ename',NULL)
    INSERT INTO ip_lov_dtl
    (TABLE_ID,COL_NAME)
    VALUES
    ('emp_id','empno')
    CREATE OR REPLACE
    TYPE out_rec_lov AS OBJECT(ename VARCHAR2(50),empno VARCHAR2(9))
    CREATE OR REPLACE
    PROCEDURE p_recordtypevariable (tab_id IN VARCHAR2,err_msg OUT VARCHAR2)
    IS
    sqlstmt VARCHAR2 (2000);
    col_str VARCHAR2 (2000);
    i NUMBER := 0;
    l_table_name ip_lov_hdr.table_name%TYPE;
    l_col_name ip_lov_hdr.col_name%TYPE;
    l_codetype ip_lov_hdr.codetype%TYPE;
    l_datatype VARCHAR2 (100);
    invalid_tableid EXCEPTION;
    BEGIN
    BEGIN
    SELECT a.table_name,
    a.codetype,
    a.col_name,
    b.data_type || '(' || b.data_length || ')'
    INTO l_table_name,
    l_codetype,
    l_col_name,
    l_datatype
    FROM ip_lov_hdr a, user_tab_columns b
    WHERE UPPER (a.table_id) = UPPER (tab_id)
    AND UPPER (a.table_name) = UPPER (b.table_name)
    AND UPPER (a.col_name) = UPPER (b.column_name);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    RAISE invalid_tableid;
    END;
    col_str := l_col_name || ' ' || l_datatype;
    FOR rec IN (SELECT b.col_name,
    c.data_type || '(' || c.data_length || ')' datatype
    FROM ip_lov_hdr a, ip_lov_dtl b, user_tab_columns c
    WHERE UPPER (b.table_id) = UPPER (tab_id)
    AND UPPER (a.table_id) = UPPER (b.table_id)
    AND UPPER (a.table_name) = UPPER (c.table_name)
    AND UPPER (b.col_name) = UPPER (c.column_name) )
    LOOP
    col_str := col_str || ',' || rec.col_name || ' ' || rec.datatype;
    END LOOP;
    sqlstmt := 'CREATE OR REPLACE TYPE out_rec_lov AS OBJECT(' || col_str || ')';
    dbms_utility.exec_ddl_statement(sqlstmt);
    dbms_utility.exec_ddl_statement('alter package pkg_lov_new compile');
    EXCEPTION
    WHEN invalid_tableid THEN
    err_msg := 'Table is not defined ';
    WHEN OTHERS THEN
    err_msg := SUBSTR (SQLERRM, 1, 500);
    END p_recordtypevariable;
    CREATE OR REPLACE
    PACKAGE pkg_lov_new
    AS
    TYPE listtable IS TABLE OF out_rec_lov index by binary_integer;
    PROCEDURE p_getlov (
    tab_id IN VARCHAR2,
    col_value IN VARCHAR2,
    outlist OUT listtable,
    err_msg OUT VARCHAR2);
    END;
    CREATE OR REPLACE
    PACKAGE BODY pkg_lov_new
    AS
    PROCEDURE p_getlov (
    tab_id IN VARCHAR2,
    col_value IN VARCHAR2,
    outlist OUT listtable,
    err_msg OUT VARCHAR2)
    IS
    query_str VARCHAR2 (2000);
    col_str VARCHAR2 (2000);
    TYPE cur_typ IS REF CURSOR;
    c cur_typ;
    i NUMBER := 0;
    l_table_name ip_lov_hdr.table_name%TYPE;
    l_col_name ip_lov_hdr.col_name%TYPE;
    l_codetype ip_lov_hdr.codetype%TYPE;
    BEGIN
    BEGIN
    SELECT table_name,
    codetype,
    col_name
    INTO l_table_name,
    l_codetype,
    l_col_name
    FROM ip_lov_hdr
    WHERE UPPER (table_id) = UPPER (tab_id);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    col_str := l_col_name;
    FOR rec IN (SELECT col_name
    FROM ip_lov_dtl
    WHERE table_id = tab_id)
    LOOP
    col_str := col_str || ',' || rec.col_name;
    END LOOP;
    IF l_codetype IS NULL THEN
    query_str := 'select out_rec_lov('
    || col_str
    || ') from '
    || l_table_name
    || ' where '
    || l_col_name
    || ' like :col_value';
    BEGIN
    OPEN c FOR query_str USING col_value;
    LOOP
    FETCH c INTO outlist (i);
    i := i + 1;
    EXIT WHEN c%NOTFOUND;
    END LOOP;
    CLOSE c;
    EXCEPTION
    WHEN OTHERS THEN
    err_msg := SUBSTR (SQLERRM, 1, 500);
    END;
    ELSE
    query_str := 'select out_rec_lov('
    || col_str
    || ') from '
    || l_table_name
    || ' where code_type =:l_codetype and '
    || l_col_name
    || ' like :col_value';
    BEGIN
    OPEN c FOR query_str USING l_codetype, col_value;
    LOOP
    FETCH c INTO outlist (i);
    i := i + 1;
    EXIT WHEN c%NOTFOUND;
    END LOOP;
    CLOSE c;
    EXCEPTION
    WHEN OTHERS THEN
    err_msg := SUBSTR (SQLERRM, 1, 500);
    END;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    err_msg := SUBSTR (SQLERRM, 1, 500);
    END p_getlov;
    END pkg_lov_new;
    /

  • Dynamic creating field names within Loop

    Hi,
    I've a record which comprises of a few key fields and then 52 qty fields, one for each week of the year. ( Not my design honest!!).
    Anyway with in a Cursor there are currently 52 "IF" statements clearing out values less than the current week number. I'd tried to replace this with the following. However I'm having trouble with the " 'c1_rec.qty'&#0124; &#0124;lv_count " bit.
    Has anyone got any ideas?
    lv_week:=22; ( added for clarity )
    lv_count:=1;
    WHILE lv_count < lv_week LOOP
    'c1_rec.qty'&#0124; &#0124;lv_count :=0;
    lv_count:=lv_count+1;
    END LOOP;
    John-Paul Thompson

    John-Paul;
    If I understand the question correctly, you have a table with 52 columns, one for each week of the year. You are trying to zero the quantity for each week prior to the current week. I'm going to take a sab at this. Bear in mind that I have no way to debug the code.
    DECLARE
    c NUMBER;
    n NUMBER;
    v_sql VARCHAR2(2000)
    lv_week NUMBER:=22; ( initialize week#)
    lv_count NUMBER:=1;
    BEGIN
    v_sql := 'UPDATE c1_rec SET '
    WHILE lv_count < lv_week LOOP
    v_sql := v_sql&#0124; &#0124;
    'qty'| |TO_CHAR(lv_count) &#0124; &#0124;' :=0';
    lv_count:=lv_count+1;
    IF lv_count < lv_week THEN
    v_sql := v_sql &#0124; &#0124; ', ';
    END IF;
    END LOOP;
    --sql := v_sql &#0124; &#0124; YOUR WHERE CLAUSE
    c:= dbms_sql.open_cursor;
    dbms_sql.parse(c, v_sql, dbms_sql.native)
    n:= dbms_sql.execute(c);
    dbms_sql.close_cursor(c);
    END;
    HTH
    Randall
    null

  • Creating on the fly dynamic named bind variable names.

    I have an application process which gets called by a Dynamic action and Javascript.
    Everything is working great however I'm using it to drive dynamic charts.
    I could use IF statements at the end of the application process to decide what BIND vairable to fill with the information the process has collected however I'd prefer just to create the BIND variable from the
    name of the submitted information.
    So I have an application level variable called WHICHCHART. this gets populated with text upon calling the application process...so let's say 'chart1' is what it gets filled with.
    What I"d like to have at the end of the application process is just a bind variable waiting called :chart_1.
    So no matter what the value of WHICHCHART it will create an on the fly a bind variable with the same name.

    Ok. I guess this question was more how do you do this..then OH NO there are not other ways to do this.
    So I have a page with a chart region. this chart will have 3 Y Axes which prohibits the use of the default XML.
    So..
    I have the following Javscript:
    function getdata(whichchart) {
      var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=VM_XML_GENERATION',0);
            get.add('WHICHCHART',whichchart);
            gReturn = get.get('XML');
      get = null;
    Which is called when the page loads by a dynamic action:
    getdata('production');
    When the javascript is called as you can see it fires off:
    declare
       chart_series_data VARCHAR(32767);
       type array_cols is varray(7) of varchar2(100);
       array array_cols := array_cols('VM_HOSTS_NUM','VM_NUMBER','VM_PHYS_MEM','VM_VIRT_MEM','VM_CPU_COUNT', 'VM_TOTAL_DISK','VM_PROVISIONED_DISK');
    BEGIN
    --IF :WHICHCHART IS NULL THEN
    --RAISE_APPLICATION_ERROR(-20001,'Chart variable not set');
    --END IF;
    chart_series_data := null;
    chart_series_data := '      <data>'||chr(10);
    chart_series_data := chart_series_data||  '        <series name="Hosts Number" type="Line" color="0x1D8BD1" >'||chr(10);
    for c1 in (SELECT VM_REPORT_DATE LABEL,VM_HOSTS_NUM from TABLE where VM_REPORT_DATE between add_months(SYSDATE,-24) and SYSDATE and lower(VM_DCNAME)=lower(:WHICHCHART) )
    loop
    chart_series_data := chart_series_data || '<point name="'||c1.LABEL||'" ';
    chart_series_data := chart_series_data || 'y="'||c1.VM_HOSTS_NUM||'"></point> '||chr(10);
    end loop;
    chart_series_data := chart_series_data|| '      </series>'||chr(10)||'</data>';
    :PROD_DATA := chart_series_data;
    END;
    The : production variable at the end of this I want to change the name of based on the value I'm sending of WHICHCHART from the javascript. I hope this is clearer now.
    AGAIN this is not really a need. It is a want to be able to create dynamic bind variable names going forward.
    Thanks

  • Dynamically create (global) variables

    Hi,
    Is it in anyway possible to dynamically create variables, like you can do in Forms:
    DEFAULT_VALUE('test', v_test);
    with v_test holding the variable, like 'GLOBAL.TEST'. Forms would then create me the variable as it doesn't exist yet, assigning the given value.
    Like this I could read my variables' names from a DB table, dynamically create them, and assign their values. Inside the report I would then use them as lexical references.
    I know I can create parameters inside the report achieving the same, but we need the table-approach for our translations. Getting rid of the parameters' overhead would be great!
    Any suggestions appreciated,
    K.

    Where the lov is attached set the VALIDATE FROM LIST property to YES and craate one trigger for each field called WHEN-VALIDATE-ITEM and use the code as below...
    IF GET_ITEM_PROPERTY('FORM_FIELD_NAME',ITEM_IS_VALID)='FALSE' THEN
      :FORM_FIELD_NAME:=:GLOBAL.EmpCode;
    END IF;
    Don't forget to set NULL for global variable in KEY-LISTVAL trigger after assigning value to the form's field.
    HTH.
    -Ammad
    Edited by: Ammad Ahmed on Nov 8, 2010 4:33 PM

  • Inventory forecast help - dynamically creating formulas?

    Post Author: ddenise
    CA Forum: Formula
    I am writing a report that reconciles sales orders to inventory - essentially, group sales orders by the scheduled production date, list out all the parts that are needed and forecast the impact on inventory, highlighting any areas where inventory is foretasted to go negative. The results right now look like this:                               Part          In Inventory          Needed         Inventory RemainingOrder Number 567     Product Number 311187          Part Number 8111234          100                  5                  95          Part Number 8111235      Product Number 311189          Part Number 8111234          100                 6                  94
              Part Number 8112235 You can see the problem is that once I calculate "Inventory Remaining", the next instance of part 8111234, should have an "In Inventory" value of 95, NOT 100, but 100 is what is stored in the database.  The next time that part number is used, the database value is pulled and 100 is displayed.  A running total or summary won't work because they cannot be used on 2nd pass formulas/variables; "Inventory Remaining" is a formula evaluated on the 2nd pass.The result that I NEED to come out would be:                                Part          In Inventory          Needed         Inventory Remaining
    Order Number 567
         Product Number 311187
              Part Number 8111234          100                  5                  95
              Part Number 8111235
          Product Number 311189
              Part Number 8111234          95                  6                  89
              Part Number 8112235  So.... I am thinking that I need to create a formula that does the following while records are printed:Check to see if a variable whose name is equal to the part number that is being printed (in this case "8111234") and if it doesn't exist, then create it, setting it's value to what is in the database (in this case "100")Use the variable's current value, subtract the quantity of those parts that are needed for the current record being printed and updated the variable's value to this difference.If the variable does already exisit, then use it's current value to display in the "In Inventory" column and,Use the variable's current value, subtract the quantity of those parts
    that are needed for the current record being printed and updated the
    variable's value to this difference.What this would do is essentially, dynamically create variables that can be used for display and other evaluation and update the particular variable that is related to the part number that is being printed. Has anyone done anything like this before?  I'm sure I'm not the first to encounter this situation.  Also, if there are other ways to solve this problem that Crystal can handle, please advice - I cannot seem to find any other solution. Regards,  

    XtrmeMelissa wrote:
    Haha! I got all the formulas down except for the boxes but thank you so much!
    I do have a new problem that just arrived, how can I get it to clear itself after I'm finished? So that it acts like a calculator and the columns are automatically cleared and the bars on hand turns into the total bars amount?
    It sounds very difficult
    Melissa
    Message was edited by: XtrmeMelissa, sorry about this! Boss brought up something new
    Melissa,
    I anticipated that problem and that's why I proposed the structure that I did.
    Good luck,
    Jerry

  • Dynamic Set Variable

    I am having a peculiar issue with the Set function. See the following code.
    In a workflow I'm performing this code and yet it seems as though the user object is not actually ever modified.
    <set name='resourcename'>
    <s>server1</s>
    </set>
    <set name='attributename'>
    <s>firstname</s>
    </set>
    <set name='fqname'>
    <concat>
    <s>user.accounts[</s>
    <ref>resourcename</ref>
    <s>].</s>
    <ref>attributename</ref>
    </concat>
    </set>
    <set>
    <ref>fqname</ref>
    <s>testvalue</s>
    </set>
    When I trace <ref>user.accounts[server1].firstname</ref> it returns testvalue correctly but when I check in the view it never updates the resource and does not show in the WFTrace. I'm thinking somehow that this user object is never truly updated. Anyone know of a better way to do this dynamically generated variable name?

    When you check out the view are you assigning a Form?
    The firstname attribute appears in the default user form and will be mapped from the global namespace. This can cause unexpected issues.
    While you may not be directly using the form, if one is not assigned... it will use the default.
    Create a completely empty form called myEmptyForm and add the variable Form to the checkout view with the value myEmptyForm.
    David

  • Creating variables using set()

    Does the set() function for dynamically creating variables
    have a substitute in AS3?
    This is a generic example written in AS2:

    You're welcome. Until your posting, I didn't know there was
    such a thing as set, so as often happens, I learn new things here.
    My approach normally would have been along the lines of the = one.
    If you're ever wondering about other changes, in the AS3 help
    docs you can search on "Migration" and one of the few choices there
    is titled as such wrt AS2. It tabulates the status of most of the
    AS2 code elements and identifies alternatives for AS3 when
    applicable.
    Also, there's this offering you might find useful...
    http://www.actionscriptcheatsheet.com/downloads/as3cs_migration.pdf

  • Creating dynamic variable names

    I know there has got to a way to do this but I am not finding anything on google. I want to create a dynamic variable name like name + i so when your in a loop the names come out name1, name2 and so on till however many you want. I have tried
    int name + i = 3;
    int name[i] = 3; // which obviously won't but I had to try
    int name{i} = 3;and I am out of ideas. Thanks for all your help.

    I'd suggest using variables named j or x when posting code which uses them as array indexes.
    [i] - is for italics formatting
    [u] - is for underlined formatting
    [code] is for class Example { ... } code formatting
    etc.

  • JSP : create variable dynamic variable name and get his value.

    //HI forums.sun.com !
    //What I want to do is above :
    //out.println("<td style=\"width: "+col_width_+h+" \">")
    //Variable Declaration
    String col_width_1 = "100px";
    String col_width_2 = "150px";
    //etc String col_width_N = "XXXpx";
    //loop
    for (int h = 0; h < hrecset.getRowCount(); h++)
    //some code
    //create the variable name (exemple : col_width_0 ) with the "loop counter name" to get the value
    out.println("<td style=\"width: "+col_width_+h+" \">")//Do you understand what i mean?
    //some code
    //Variable Declaration
    String col_width_1 = "100px";
    String col_width_2 = "150px";
    //etc String col_width_N = "XXXpx";
    //loop
    for (int h = 0; h < hrecset.getRowCount(); h++)
    //some code
    //create the variable name with a concat with the loop counter variable name to get the value of the concatened variable
    out.println("<td style=\"width: "+col_width_+h+" \">")//Do you understand what i mean?
    //some code

    I apologize
    1) Sure i understand it but i click on the "code" button after i inserted the text above but it doesn't worked now it do.
    2) Because the table element need to have the total width in the HTML table TAG equal to the addition of every HTML td TAG to be W3 conform
    because i have a lot of cell where i want to adjust the width.
    so here my solution
    <%
    //Variable für Breite
    String col_width_unit = "px"; // px, cm,
    Integer total_table_width = 0;
    String[] col_width=new String[3];
    col_width[0] =  "350";
    col_width[1] =  "75";
    col_width[2] =  "50";
    %>
    <table style="page-break-inside:avoid;width:<%=gesamt_table_width+col_width_unit%>;">
    <%
    for (int h = 0; h < hrecset.getRowCount(); h++)
    out.println("               <td id =\"cell"+h+"\" class=\"tdall\"  style=\"width:"+col_width[h]+col_width_unit+"\" >");               
    %>
    </table>thank you very much

  • Assigning a 'dynamically created sequence' value to a variable

    in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below
    v_seq_name := 'seq_'||loadid||v_table_name;
    execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
    and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working
    1) v_curr_value : = v_seq_name.currval ;
    2) select v_seq_name||'.nextval' into v_curr_value from dual;
    can you please suggest me how i can get the value in plsql block.

    DIVI wrote:
    in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below
    v_seq_name := 'seq_'||loadid||v_table_name;
    execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
    and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working
    1) v_curr_value : = v_seq_name.currval ;
    2) select v_seq_name||'.nextval' into v_curr_value from dual;
    can you please suggest me how i can get the value in plsql block.Well, you haven't given the error you are getting but I guess the procedure isn't compiling? You need to execute immediate any reference to the sequence.
    Having said that, your architecture is probably wrong if you are dynamically creating things in a procedure.
    Why do you need to create them dynamically?

Maybe you are looking for

  • FICA: clearing rules to applying payments against unpaid security deposits regardless of due date

    Hi Folks, We have a requirement in FICA clearing rules to apply the payment against unpaid security deposit irrespective of the due date. I have the below rule configured as the first step in my clearing variant. Grouping String: 019 (statistical ind

  • IDVD won't see movie folder

    Working on imovie project. Went to create idvd for the project. Wanted to rename the project and did so in finder. Now idvd won't see movies in the movie folder. Have tried resaving the project out of imovie as a different name, created a new folder

  • Support Pack SAPKB70012 NW2004s giving ABAP dumps

    Hello All, We are trying to apply Basis Support Pack 12 NW2004s in one of our systems. The support packed stoped in Import Proper step becuse of wp max runtime reached. So now when I try to kick it of it gives me the follwoing ABAP dump. Runtime Erro

  • Equium A60 notebook - installing Rio software

    Hi I have a problem with my Rio software. When ripping a CD it "stalls". I wondered if anyone in the Surrey & Hampshire area has any experience in reinstalling, which includes updating the USB/Chipset drivers and updating the BIOS amongst other thing

  • Creating Qualifications using PP01

    Hi everyone, I have created a program to automate the creation of Employee qualifications using the transaction PP01. This program runs OK if it is executed on-line (using SAP GUI and manually) because internally it is a simple batch input. This prog