Nested loop variable in cf variable

Hi,
I have a set of dynamic text boxes that I create inside a
loop, like this:
<cfset counter = 0>
<cfoutput query="q1">
<cfset counter = counter+1 >
<input name="user_name#counter#" type="text"
maxlength="20">
<input name="desc#counter#" type="text"
maxlength="20">
</cfoutput>
I am trying to insert these values to a table called
user_temp.
<cfset list1 = ListQualify(form.InsRowID.trim(),"")>
<cfloop list="#list1#" index="i">
<cfquery datasource="abc">
insert into user_temp( user_name,desc
) values (
,'#form.user_name##i#'
,'#form.desc##i#'
</cfquery>
</cfloop>
Now the insert works, but it is appending the values to the
value from the text box. Let's say I entered:
User name: User desc:
a adesc
b bdesc
It is inserting as:
a1 adesc1
b2 bdesc2
I know this is because I have appended the index like this:
'#form.desc##i#'..
but if I try nesting like this: '#form.desc#i##' it gives me
an error saying "missing comma" and doesnt insert.
Is there some way I can make it evaluate this value to read
like form.desc1, form.desc2 etc...
Please help!!

The code works for textboxes, but for dropdowns I am getting
the same error "missing comma". Any ideas as to why this might be
the case? I am sure I am missing something obvious here:
This is my dropdown code:
(This dropdown is populated from an array instead of query)
<cfset total_records=q1.recordcount>
<select name="user_role_id#counter#">
<option value=""></option>
<cfloop index="Counter" from=1 to="#Total_Records#">
<option value="userArray[Counter][1]"
<cfif isdefined( "form.user_role_id ")>
<cfif form.user_role_id eq userArray[Counter][1]>
Selected
</cfif>
</cfif> >#userArray[Counter][2]#
</option>
</cfloop>
</select>
userArray[Counter][1] has nothing but the role ids.
And then I use this :
#form["user_role_id#i#"]#
Thank you

Similar Messages

  • What is the scope of implicit loop variables?

    Hi,
    I'm facing some strange error from the ABSL editor (syntax checker).
    In ABSL the loop variables are implicit and don't have to be declared in the head section of the script.
    My question now is simple: How is the scope/visibility of such loop variables specified ?
    There's a complete code snippet below.
    In line no.9, there's the first time use of implicit loop variable 'task_inst'.
    Because of type inference, it will be typed as MasterDataWanneBe/Tasks (which is my own BO type).
    In line no.20, I want to use the same variable name in a different loop, outside the parenthesis/scope of the first first use.
    Now the ABSL syntax checker complains about incompatible types (see code snippet)
    Thus the type inference should result in the, (lets say 'local') type Project/Task, which is the one I was querying for.
    To me it looks like, that loop variables implicitly get a global scope (hopefully bound to this ABSL file only).
    I would like to see the scope/visibility of loop variables restricted to the parenthesis.
    In other words only inside the loop.
    Hint
    I heard (from little sparrows), that local variable scoping is not possible because of underlying
    generated ABAP code. If so, than it would be helpful to print warnings, in case of types are compatible
    but used in different scopes. Think about the unintended side effects.
    import ABSL;
    import AP.ProjectManagement.Global;
    var query_tasks;
    var query_tasks_param;
    var query_tasks_result;
    foreach (empl_inst in this.Employees) {
         foreach (task_inst in empl_inst.Tasks) {
             //   ^^^^^^^^^  first time use
              task_inst.Delete();
    // ===========================================================================
    query_tasks = Project.Task.QueryByResponsibleEmployee;
    query_tasks_param = query_tasks.CreateSelectionParams();
    query_tasks_result = query_tasks.Execute(query_tasks_param);
    foreach (task_inst in query_tasks_result) {
          // ^^^^^^^^^ Error: 4
          // The foreach loop variable is already inferred to an incompatible type:
          // Node(MasterDataWanneBe/Tasks). Expected Node(Project/Task)

    Yes, variable declarations in ByD Scripting Language indeed have (snippet) global visibility. In the FP 3.0 release the variables can be declared anywhere in the snippet (not only in the beginning, as with FP 2.6), however still not within code blocks, i.e. within curly braces ({}). Therefore variable name shadowing is still not supported and because of the global visibility of variables they cannot be reused for a different type, later in the same snippet. This is because of the statically typed nature of ByD Script, despite the type inference convenience.
    Kind regards,
    Andreas Mueller

  • [svn] 4136: Find loop variables initialized with "weak" types, e.g., NULL or VOID, and

    Revision: 4136
    Author: [email protected]
    Date: 2008-11-18 14:50:38 -0800 (Tue, 18 Nov 2008)
    Log Message:
    Find loop variables initialized with "weak" types, e.g., NULL or VOID, and
    use the variable type used within the loop to normalize the local's type.
    Modified Paths:
    flex/sdk/trunk/modules/asc/src/java/adobe/abc/GlobalOptimizer.java

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Initalizing loop variable - best practice?

    Hello All,
    What do people think is the best way to initalise a variable that is going to be assigned in a loop and used afterwards.
    For instance say I had a vector of objects of some class (lets say class "Bean") and I want to find a bean in that Vector with a specific attribute value. I set up a loop variable, myBean, of type Bean and then test each object by assigning it to myBean:
    Iterator it = myVector.iterator(); //1
    while (it.hasNext()) {  //2
    myBean = (Bean)it.next(); //3
    if (myBean.getMyAttribute() == testValue) break; //4
    myBean.doSomething(); //5
    The question is how do I best set up myBean? I would like to simply place the line:
    Bean myBean;
    before the loop, except this is bad practice as the variable may never be initalised, I know it will in this simple case but in general its bad to leave null variables around.
    I could use:
    Bean myBean = new Bean();
    but that is creating an object for no reason, and if I set up the variable in the loop (Bean myBean = (Bean)it.next()) it will not be available to me after the loop has terminated?
    So is there a way to do this that doesn't require creating a useless object?
    cheers
    matt

    It's not clear whether you need to use myBean outside the while loop or not. If you are not going to use myBean outside the loop,
    while (it.hasNext()) { //2
       Bean myBean = (Bean)it.next(); //3
       if (myBean.getMyAttribute() == testValue) break; //4
       myBean.doSomething(); //5
    }If you are going to use myBean outside the loop, you must declare it outside the loop. But you can set it to null so you don't needlessly create an object.
    Bean myBean = null;
    while (it.hasNext()) { //2
       myBean = (Bean)it.next(); //3
       if (myBean.getMyAttribute() == testValue) break; //4
    if(myBean != null) myBean.doSomething(); //5

  • FieldLoop within TabPanel: HowTo pass loop variable to form within a Tab

    Dear all,
    I have a Tabbed User Form which contains a FieldLoop that creates Tabs based on the FieldLoop loop-variable.
    Each created Tab should include the same form which differs only by the value of the loop-variable.
    So I have a list of all my SAP systems, and want to create per SAP system a SAP User form that handles
    the specific SAP resource.
    In general this works, but it seems that only the first element of my list of SAP systems is passed through
    the underlying form.
    Here's an extract of the code I've wrote:
    ===[ FILE : MY TABBED USER FORM . XML ]========================================================
    <!-- define list of managed SAP systems / START -->
    <Field name='MANAGED_SAP_LIST'>
    <Display class='Text'>
    <Property name='title' value='MANAGED_SAP_LIST'/>
    </Display>
    <Default>
    <List>
    <String>SAP_XXX-AAA</String>
    <String>SAP_XXX-BBB</String>
    </List>
    </Default>
    </Field>
    <!-- define list of managed SAP systems / END -->
    <!-- main tabs / START -->
    <Field name='MainTabs'>
         <Display class='TabPanel'/>
         <!-- loop through assigned SAP systems / START -->
         <FieldLoop for='currentSAP' in='MANAGED_SAP_LIST'>
              <!-- new TAB / START -->
              <Field name='$(currentSAP)'>          
              <Display class='EditForm'/>
              <FieldRef name='accountId'/>
                   <!-- invisibe field containing current loop value (i.e. SAP system name) / START -->
    <Field name='SAP_SYSTEM'>
    <Display class='Text'>
    <Property name='invisible' value='true' />
    <Property name='title' value='SAP_SYSTEM'/>
    </Display>
    <Default>
    <ref>currentSAP</ref>
    </Default>
    </Field>
                   <!-- invisibe field containing current loop value (i.e. SAP system name) / END -->
              <!-- include the SAP User Form / START -->
    <FormRef name='MY SAP User Form'/>
              <!-- include the SAP User Form / END -->
         </Field>
              <!-- new TAB / END -->
         </FieldLoop>
         <!-- loop through assigned SAP systems / END -->
    </Field>
    <!-- main tabs / END -->     
    ===============================================================================================
    ===[ FILE : MY SAP USER FORM . XML ]===========================================================
    <Field name="thisSAP">
    <Display>
    <Property name="title" value="Managed SAP SYSTEM" />
    <Property name="readOnly" value="true" />
    </Display>
    <Expansion>
    <ref>SAP_SYSTEM</ref>
    </Expansion>
    </Field>
    ===============================================================================================
    So currently I got 2 new tabs (as I defined 2 SAP systems) but the field "thisSAP" allways displays the first element of my list (i.e. SAP_XXX-AAA)
    Is there another way to pass a FieldLoop loop-variable to an underlying form ?
    many thanks in advance
    Best regards
    Joerg

    Sorry i figured it out.
    I had other session variables i was referencing in my sql query and had to add an:
    or :p11_other is null
    to my SQL query for each of them.

  • Form with loop variable

    I have a form that has text boxes where the name is created
    dynamically with a loop variable.
    <cfset formcounter = 1>
    <cfoutput query="ViewParts">
    <input type="hidden" name="RecordID#formcounter#"
    value="#RecordID#">
    <cfset formcounter = formcounter + 1>
    </cfoutput>
    <cfoutput><cfset formcountermax =
    #formcounter#></cfoutput>
    on the page it submits to I have:
    <cfloop from="1" to="#formcountermax#"
    index="loopcount">
    <cfif form.Qtyshipped1 NEQ "0" AND form.Qtyshipped1 NEQ
    "">
    <CFQUERY NAME="InsertQty" DATASOURCE="mydatasource">
    INSERT INTO InvoiceTable
    InvoiceID,
    QtyShipped,
    RecordID
    VALUES
    '#GetLastInvID.InvoiceID#',
    #form.Qtyshipped1#,
    #form.RecordID1#
    </CFQUERY>
    </cfif>
    Instead of the "1" at the end of the inserted variables, I
    want it to be my loopcount. I just don't know how to name it so
    that is possible.

    Mark, try using the values I placed below, I believe that
    should work. Also, I didnt see a close tag for your <cfloop>
    so I left it out as well.
    <cfloop from="1" to="#formcountermax#"
    index="loopcount">
    <cfif form.Qtyshipped1 NEQ "0" AND form.Qtyshipped1 NEQ
    "">
    <CFQUERY NAME="InsertQty" DATASOURCE="mydatasource">
    INSERT INTO InvoiceTable
    InvoiceID,
    QtyShipped,
    RecordID
    VALUES
    '#GetLastInvID.InvoiceID#',
    '#evaluate('form.Qtyshipped' & '#loopcount#')#',
    '#evaluate('form.RecordID' & '#loopcount#')#'
    </CFQUERY>
    </cfif>

  • Can you nest ESI variables?

    For example, I want to lookup a value in an ESI Environment file. However, the name of the value to lookup is specified in the query string.
    So I'd be doing something like the following to extract the desired value:
    $(env{$(QUERY_STRING{name})})
    ...where 'env' is the name of the esi:environment.
    However, this does not work. Is it possible to nest esi variables in this way. If so, how?
    Many thanks,
    Francis

    Any plans to implement this?
    It would be very useful in some situations. For example, you have a page that outputs a value from an esi environment file, where the name of that value is specified in the Query String.
    So your URL is something like:
    lookup.jsp?lookup=firstName
    Then, in lookup.jsp, you have something like:
    $(env{$(QUERY_STRING{lookup})})
    ...which does a look up in the environment file for the key specified using the 'lookup' query string parameter. In the example above, the value for 'firstName' would be retrieved from the environment file.
    Any chance of implementing nested ESI variables in the near future?

  • Why optimizer prefers nested loop over hash join?

    What do I look for if I want to find out why the server prefers a nested loop over hash join?
    The server is 10.2.0.4.0.
    The query is:
    SELECT p.*
        FROM t1 p, t2 d
        WHERE d.emplid = p.id_psoft
          AND p.flag_processed = 'N'
          AND p.desc_pool = :b1
          AND NOT d.name LIKE '%DUPLICATE%'
          AND ROWNUM < 2tkprof output is:
    Production
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          4           0
    Execute      1      0.00       0.01          0          4          0           0
    Fetch        1    228.83     223.48          0    4264533          0           1
    total        3    228.84     223.50          0    4264537          4           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 108  (SANJEEV)
    Rows     Row Source Operation
          1  COUNT STOPKEY (cr=4264533 pr=0 pw=0 time=223484076 us)
          1   NESTED LOOPS  (cr=4264533 pr=0 pw=0 time=223484031 us)
      10401    TABLE ACCESS FULL T1 (cr=192 pr=0 pw=0 time=228969 us)
          1    TABLE ACCESS FULL T2 (cr=4264341 pr=0 pw=0 time=223182508 us)Development
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.01          0          4          0           0
    Fetch        1      0.05       0.03          0        512          0           1
    total        3      0.06       0.06          0        516          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 113  (SANJEEV)
    Rows     Row Source Operation
          1  COUNT STOPKEY (cr=512 pr=0 pw=0 time=38876 us)
          1   HASH JOIN  (cr=512 pr=0 pw=0 time=38846 us)
         51    TABLE ACCESS FULL T2 (cr=492 pr=0 pw=0 time=30230 us)
        861    TABLE ACCESS FULL T1 (cr=20 pr=0 pw=0 time=2746 us)

    sanjeevchauhan wrote:
    What do I look for if I want to find out why the server prefers a nested loop over hash join?
    The server is 10.2.0.4.0.
    The query is:
    SELECT p.*
    FROM t1 p, t2 d
    WHERE d.emplid = p.id_psoft
    AND p.flag_processed = 'N'
    AND p.desc_pool = :b1
    AND NOT d.name LIKE '%DUPLICATE%'
    AND ROWNUM < 2
    You've got already some suggestions, but the most straightforward way is to run the unhinted statement in both environments and then force the join and access methods you would like to see using hints, in your case probably "USE_HASH(P D)" in your production environment and "FULL(P) FULL(D) USE_NL(P D)" in your development environment should be sufficient to see the costs and estimates returned by the optimizer when using the alternate access and join patterns.
    This give you a first indication why the optimizer thinks that the chosen access path seems to be cheaper than the obviously less efficient plan selected in production.
    As already mentioned by Hemant using bind variables complicates things a bit since EXPLAIN PLAN is not reliable due to bind variable peeking performed when executing the statement, but not when explaining.
    Since you're already on 10g you can get the actual execution plan used for all four variants using DBMS_XPLAN.DISPLAY_CURSOR which tells you more than the TKPROF output in the "Row Source Operation" section regarding the estimates and costs assigned.
    Of course the result of your whole exercise might be highly dependent on the actual bind variable value used.
    By the way, your statement is questionable in principle since you're querying for the first row of an indeterministic result set. It's not deterministic since you've defined no particular order so depending on the way Oracle executes the statement and the physical storage of your data this query might return different results on different runs.
    This is either an indication of a bad design (If the query is supposed to return exactly one row then you don't need the ROWNUM restriction) or an incorrect attempt of a Top 1 query which requires you to specify somehow an order, either by adding a ORDER BY to the statement and wrapping it into an inline view, or e.g. using some analytic functions that allow you specify a RANK by a defined ORDER.
    This is an example of how a deterministic Top N query could look like:
    SELECT
    FROM
    SELECT p.*
        FROM t1 p, t2 d
        WHERE d.emplid = p.id_psoft
          AND p.flag_processed = 'N'
          AND p.desc_pool = :b1
          AND NOT d.name LIKE '%DUPLICATE%'
    ORDER BY <order_criteria>
    WHERE ROWNUM <= 1;Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Nested loop vs Hash Join

    Hi,
    Both the querys are returning same results, but in my first query hash join and second query nested loop . How ? PLs explain
    select *
    from emp a,dept b
    where a.deptno=b.deptno and b.deptno>20;
    6 rows
    Plan hash value: 4102772462
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |         |     6 |   348 |     6  (17)| 00:00:01 |
    |*  1 |  HASH JOIN                   |         |     6 |   348 |     6  (17)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     3 |    60 |     2   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN          | PK_DEPT |     3 |       |     1   (0)| 00:00:01 |
    |*  4 |   TABLE ACCESS FULL          | EMP     |     7 |   266 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("A"."DEPTNO"="B"."DEPTNO")
       3 - access("B"."DEPTNO">20)
       4 - filter("A"."DEPTNO">20)
    select *
    from emp a,dept b
    where a.deptno=b.deptno and b.deptno=30;  
    6 rows
    Plan hash value: 568005898
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |         |     5 |   290 |     4   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |         |     5 |   290 |     4   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     1 |    20 |     1   (0)| 00:00:01 |
    |*  3 |    INDEX UNIQUE SCAN         | PK_DEPT |     1 |       |     0   (0)| 00:00:01 |
    |*  4 |   TABLE ACCESS FULL          | EMP     |     5 |   190 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("B"."DEPTNO"=30)
       4 - filter("A"."DEPTNO"=30)

    Hi,
    Unless specifically requested, Oracle picks the best execution plan based on estimates of table sizes, column selectivity and many other variables. Even though Oracle does its best to have the estimates as accurate as possible, they are frequently different, and in some cases quite different, from the actual values.
    In the first query, Oracle estimated that the predicate “ b.deptno>20” would limit the number of records to 6, and based on that it decided the use Hash Join.
    In the second query, Oracle estimated that the predicate “b.deptno=30” would limit the number of records to 5, and based on that it decided the use Nested Loops Join.
    The fact that the actual number of records is the same is irrelevant because Oracle used the estimate, rather the actual number of records to pick the best plan.
    HTH,
    Iordan
    Iotzov

  • Help with my nested loop...

    this application allows a user to enter two int values, rows(height) and columns(length), that are used to create a box of asterisks.
    my createBox() does not work correctly, only prints first line, loops infinitely, or doesnt loop. can someone help me out please?
    import java.io.*;
    public final class AsteriskBox
    /****InstanceVariables****/
    public static int row;
    public static int col;
    /****Constructor()****/
    public AsteriskBox()
    /****Access()'s****/
    public void createBox(int x, int y)
    if((x > 0) && (y > 0))
    for(int i = x; i > 0; i--)
    for(i = y; i > 0; i--)
    System.out.print("*");
    System.out.println();
    } // createBox()
    public void getInput() throws IOException
    BufferedReader input = new BufferedReader
    (new InputStreamReader(System.in));
    System.out.print("Enter a number of rows: ");
    String inputString = input.readLine();
    row = convertStringToInteger(inputString);
    System.out.print("Enter a number of columns: ");
    inputString = input.readLine();
    col = convertStringToInteger(inputString);
    } // getInput()
    /****Helper()****/
    private int convertStringToInteger(String s)
    Integer intObject = Integer.valueOf(s);
    return intObject.intValue();
    } // convertStringToInt()
    } // AsteriskBox class
    import java.io.*;
    public class AsteriskBoxUser
    public static void main(String args[]) throws IOException
    AsteriskBox box = new AsteriskBox();
    System.out.println("This program creates a box made of asterisks with values given by you!");
    System.out.println();
    box.getInput();
    box.createBox(AsteriskBox.row, AsteriskBox.col);
    }

    You will never break out of the first loop because you are using the same index variable i for both of your nested loops. Use a different variable, say j for your inner loop.
    Incidentally, your row and col variables are mislabeled. If you use the static modifier, they are class variables, not instance variables. This could cost you points on your assignment since it would imply that you don't know the difference.

  • @@FETCH_STATUS in nested loops

    Does fetch status in nested loops conflict?
    I have a script that should output a cluster record line and for each cluster record it must create a line for each household in the cluster.  All the data is pulled from one table, 'LFS_APRIL_2015.dbo.LISTING'.
    This is the script:
    --VARIABLE DECLARATION
    DECLARE @CLUSTER FLOAT, @HOUSEHOLD_NUMBER FLOAT, @FULL_ADDRESS CHAR(50), @HEAD_NAME CHAR(24)--CLUSTER LOOP
    DECLARE CLUSTER_CURSOR CURSOR FOR
    SELECT [LFS_APRIL_2015].[dbo].[LISTING].CLUSTER
    from [LFS_APRIL_2015].[dbo].[LISTING] where CLUSTER IS NOT NULL and DISTRICT = 1
    OPEN CLUSTER_CURSOR
    FETCH NEXT FROM CLUSTER_CURSOR INTO @CLUSTER
    WHILE @@FETCH_STATUS = 0
    BEGIN--OUTPUT THE CLUSTER RECORD
    PRINT STR(@CLUSTER,3) + STR(1,1) + STR(24,3)
    --HOUSEHOLD LOOP
    DECLARE HOUSEHOLD_CURSOR CURSOR FOR
    SELECT [LFS_APRIL_2015].[dbo].[LISTING].HOUSEHOLD_NUMBER, FULL_ADDRESS, HEAD__INSTITUTION__BUSINESS_NAME
    from [LFS_APRIL_2015].[dbo].[LISTING] where CLUSTER IS NOT NULL AND IS_HOUSEHOLD = 1 AND CLUSTER = @CLUSTER
    OPEN HOUSEHOLD_CURSOR
    FETCH NEXT FROM HOUSEHOLD_CURSOR INTO @HOUSEHOLD_NUMBER, @FULL_ADDRESS, @HEAD_NAME
    WHILE @@FETCH_STATUS = 0
    BEGIN
    --OUTPUT THE HOUSEHOLDS IN THE CLUSTER
    PRINT right('000'+cast(@CLUSTER as varchar(10)),3) + STR(2,1) + STR(@HOUSEHOLD_NUMBER,2) + @FULL_ADDRESS + @HEAD_NAME + '000' + ' ' + STR(0,1)
    FETCH NEXT FROM HOUSEHOLD_CURSOR INTO @HOUSEHOLD_NUMBER, @FULL_ADDRESS, @HEAD_NAME
    END
    CLOSE HOUSEHOLD_CURSOR
    DEALLOCATE HOUSEHOLD_CURSOR
    FETCH NEXT FROM CLUSTER_CURSOR INTO @CLUSTER
    END
    CLOSE CLUSTER_CURSOR
    DEALLOCATE CLUSTER_CURSOR
    It appears however that the clusters are being repeated.
    Where have I gone wrong!

    >> I have a script that should output a cluster record [sic] [sic] line and for each cluster record [sic] it must create a line for each household in the cluster. All the data is pulled from one table, 'LFS_APRIL_2015.dbo.LISTING'.<<
    Please follow the basic Netiquette of all SQL forums. Post DDL that follows ISO-11179 rules for data element names. Use ISO-8601 formats for temporal data. Use induSTRy standard encodings (ISBN, UPC, GTIN, etc) and avoid needless dialect. Give clear specifications.
    Give sample data.
    If you do not know that rows are not records, fields are not columns and tables are not files, then you should not be posting. SQL is a declarative language, so we hate cursors. We hate local variables, too. 
    Using upper case letters is a code smell that says your mindset is still in punch cards and sequential processing. And finally you used a date in a data STRuctured name! Back in the 1960's, this is how we named magnetic tapes. In RDBMS, we name tables for the
    set of entities they model. 
    Why are you using FLOAT? Is there really household number like 3.141592653 in your data model? But if it is really an integer, you still screwed up. What math do you do with it? 
    The USPS standards use 5 lines of VARCHAR(35) for a Street address. But you pack all of that in CHAR(50). Think about how vague “cluster” is – Size? Name? Location? WHAT?? 
    The purpose of PRINT in T-SQL is debugging and not output. The purpose of SQL is to handle the data, not to format and display data, like you are doing. Learn what a “presentation layer” in RDBMS is. 
    Follow the rules, and post that DDL, then we will try to help you. All you can get is a stinking kludge with this posting. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Building Tree hierarchy Using nested loops and class cl_gui_column_tree

    Hello gurus,
    I want to create a tree report using custom container and class cl_gui_column_tree. I have read and understood the standard demo report which SAP has provided i.e. SAPCOLUMN_TREE_CONTROL_DEMO. But in this report all the levels nodes are created as constants and hardcoded. I want to create hierarchy using nested loops. For this i took one example of a hierarchy of VBAK-VBELN->VBAP-POSNR Like One sales order has many line items and each line item can have number of line items in billing plan.
    I have done some coding for it.
    FORM build_tree USING node_table TYPE treev_ntab
                                           item_table TYPE zitem_table.              " i created the zitem_table table type of mtreeitm in SE11.
      DATA: node TYPE treev_node,
                 item TYPE mtreeitm.
      node-node_key = root.
      CLEAR node-relatkey.
      CLEAR node-relatship.
      node-hidden = ' '.
      node-disabled = ' '.
      CLEAR node-n_image.
      CLEAR node-exp_image.
      node-isfolder = 'X'.
      node-expander = 'X'.
      APPEND node TO node_table.
      item-node_key = root.
      item-item_name = colm1.
      item-class = cl_gui_column_tree=>item_class_text.
      item-text = 'Root'.
      APPEND item TO item_table.
      item-node_key = root.
      item-item_name = colm2.
      item-class = cl_gui_column_tree=>item_class_text.
      item-text = 'Amount'.
      APPEND item TO item_table.
      LOOP AT it_vbeln INTO wa_vbeln.
        node-node_key = wa_vbeln-vbeln.
        node-relatkey = root.
        node-relatship = cl_gui_column_tree=>relat_last_child.
        node-hidden = ' '.
        node-disabled = ' '.
        CLEAR node-n_image.
        CLEAR node-exp_image.
        node-isfolder = 'X'.
        node-expander = 'X'.
        APPEND node TO node_table.
        item-node_key = wa_vbeln-vbeln.
        item-item_name = colm1.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_vbeln-vbeln.
        APPEND item TO item_table.
        item-node_key = wa_vbeln-vbeln.
        item-item_name = colm2.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_vbeln-netwr.
        APPEND item TO item_table.
        LOOP AT it_posnr INTO wa_posnr.
        node-node_key = wa_posnr-posnr.
        node-relatkey = wa_vbeln-vbeln.
        node-relatship = cl_gui_column_tree=>relat_last_child.
        node-hidden = ' '.
        node-disabled = ' '.
        CLEAR node-n_image.
        CLEAR node-exp_image.
        node-isfolder = ' '.
        node-expander = ' '.
        APPEND node TO node_table.
        item-node_key = wa_posnr-posnr.
        item-item_name = colm1.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_posnr-posnr.
        APPEND item TO item_table.
        item-node_key = wa_posnr-posnr.
        item-item_name = colm2.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_posnr-netpr.
        APPEND item TO item_table.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.
    Now this program compiles fine and runs till there is only one level. That is root->vbeln. But when i add one more loop of it_posnr it gives me runtime error of message type 'X'. The problem i found was uniqueness of item-item_name as all the sales order have posnr = 0010. What could be done? I tried giving item_name unique hierarchy level using counters just like stufe field in prps eg. 10.10.10, 10.10.20,10.20.10,10.20.20,20.10.10 etc.. etc.. but still i am getting runtime error when i add one more hierarchy using nested loop. Plz guide.
    Edited by: Yayati6260 on Jul 14, 2011 7:25 AM

    Hello all,
    Thanks the issue is solved. The node key was not getting a unique identification as nodekey. I resolved the issue by generating unique identification for each level. Thanks all,
    Regards
    Yayati Ekbote

  • Problem with Nested loop in Fox-Formula

    Dear Experts,
    Let s share the scenario :
    MaterialGroups with following Keys for Example AAAA, BBBB, CCCC..., Materialgroups are selected in the 1st input ready query, which is assigned to DataProvider DP_1 in a  webtemplate.
    every Materialgroup has several Materials, for instance:
    Materialgroup AAAA has following Materials: AAAA10, AAAA11, AAAA12, AAAA13...
    Materials are  selected in a second  input ready Query, which is assigned to a second DataProvider DP_2 in the Same Webtemplate as the query 1.
    Both Materialgroup and Material are based on the same Aggreagtion level and same real time cube.
    I want to copy the input values for every  MaterialGroup ( 1st query, DP_1) only to it s own Materials (2cond Query, DP_2).
    To resolve this Issue i wrote the following Fox Formula code with a nested loop, however it does not work properly. when I m debugging the code, i could release that the second Loop was ignored.but wehn i replace the second loop (nested loop) with a fixed value it s seems to work properly
    DATA MG1 TYPE MATG.<------ MaterialGroup
    DATA MT1 TYPE MAT.<----
    Material
    DATA S1 TYPE STRING.
    DATA S2 TYPE STRING.
    DATA S3 TYPE STRING
    DATA K TYPE F.
    DATA Z TYPE F.
    FOREACH MG1.
    To check Materialgroup in debugger
    S1= MG1.
    BREAK-POINT.
    K = {KEYfIG, #, MG1}.
    BREAK-POINT.
    FOREACH  MT1.   <----- if i set MT1 to a fixed value like AAAA11 then S3 get the wished value namely AAAA
    S2 = MT1.
    BREAK-POINT.
    S3 =  SUBSTR (MT1, 0, 4).  
    BREAK-POINT.
    IF S1 = S3.
    {KEYFIG, MT1, #} = K.
    following Statement is only used To check in debugger if Material has become the same Materialgroup value
    Z = {KEYFIG, MT1, #}.
    BREAK-POINT.
    ENDIF.
    ENDFOR.
    ENDFOR.
    Thakns for any help
    Frank
    Edited by: FRYYYBM on Mar 17, 2011 10:54 PM
    Edited by: FRYYYBM on Mar 17, 2011 11:06 PM

    Hi,
    Please try this way.
    DATA MG1 TYPE MATG.<------ MaterialGroup
    DATA MT1 TYPE MAT.<----
    Material
    DATA S1 TYPE STRING.
    DATA S2 TYPE STRING.
    DATA S3 TYPE STRING
    DATA K TYPE F.
    DATA Z TYPE F.
    FOREACH MT1.
    FOREACH MG1.
    To check Materialgroup in debugger
    S1= MG1.
    BREAK-POINT.
    K = {KEYfIG, #, MG1}.
    BREAK-POINT.
    FOREACH MT1. <----- if i set MT1 to a fixed value like AAAA11 then S3 get the wished value namely AAAA
    S2 = MT1.
    BREAK-POINT.
    S3 = SUBSTR (MT1, 0, 4).
    BREAK-POINT.
    IF S1 = S3.
    {KEYFIG, MT1, #} = K.
    following Statement is only used To check in debugger if Material has become the same Materialgroup value
    Z = {KEYFIG, MT1, #}.
    BREAK-POINT.
    ENDIF.
    ENDFOR.
    ENDFOR.
    ENDFOR.
    Thanks.
    With regards,
    Anand Kumar

  • Creating nested loops

    Hi!
    I would like to list all Combinations of a list A and a list B (each containing 5 integers) in a third list C in order to get 25 combinations. I am intending to use nested loops so that on the first loop the second loop starts and then the result lets say list A + list B are listed in the list C. Is there any other way of doing this with Labview or I am on the right track?
    Best Regards,
    Hamid  

    You can use the polymorphic array math to accomplish this.  Inside of a single for loop, index Array A and add that to the entire Array B in one shot.  At this point, there are numerous ways to take the output.  Probably the simpliest is to reshape the output 2D array into a 1D array.  For better memory allocation, you can preinitialize a 1D array and replace elements in the for loop but in the end it accomplishes the same task.  See attached example (LV7.1.1).  Of course everything is dependant on what you are going to do with this, what operations, when and where the numbers come from.
    Paul
    Paul <--Always Learning!!!
    sense and simplicity.
    Browse my sample VIs?
    Attachments:
    arrayMath.vi ‏33 KB

  • XML nested Loop?

    hi all.
    I´ve just completed a little test for making a tree
    component with custom
    icons / bransch.
    However, i can only get my first branch to show custom
    icons.(links -
    document) I figure I need to make a nested loop to Iterate
    over
    nextSibling?. I tried ALOT, but i guess I´m doing
    something completely
    wrong.
    here is code for my tree so far:
    my_xml = new XML();
    my_xml.ignoreWhite = true;
    my_xml.load("tree.xml");
    my_xml.onLoad = function(){
    myTree.dataProvider = this.firstChild;
    var folders = my_xml.firstChild.firstChild;
    var docs = folders.childNodes;
    for (var i=0; i < docs.length; i++){
    currDoc = docs
    trace(docs);
    var docIcon = currDoc.attributes.pic;
    switch(docIcon){
    case "pdf":
    myTree.setIcon(currDoc, "pdfIcon");
    break;
    case "word":
    myTree.setIcon(currDoc, "wordIcon");
    break;
    case "excel":
    myTree.setIcon(currDoc, "excelIcon");
    break;
    case "ie":
    myTree.setIcon(currDoc, "ieIcon");
    break;
    }//switch
    } //for
    };//onLoad
    And here is the XML I used:
    <node label="» Dokument typer">
    <node label="» links - document">
    <node label="test.url" url="
    http://www." pic="ie" info="test text" />
    <node label="test.doc" url="test.doc" pic="word"
    info="test text" />
    <node label="test.excel" url="test.xls" pic="excel"
    info="test text" />
    <node label="test.pdf" url="test.pdf" pic="pdf"
    info="test text." />
    </node>
    <node label="» Links - document">
    <node label="test URL" url="
    http://www." pic="ie" info="test text."
    />
    <node label="test URL" url="
    http://www." pic="ie" info="test text."
    />
    </node>
    </node>

    Solved it ..works nicely :D
    ty anyways.
    //cleaner
    "cLeAnEr" <[email protected]> skrev i meddelandet
    news:ekm1vc$r8h$[email protected]..
    > hi all.
    >
    > I´ve just completed a little test for making a tree
    component with custom
    > icons / bransch.
    > However, i can only get my first branch to show custom
    icons.(links -
    > document) I figure I need to make a nested loop to
    Iterate over
    > nextSibling?. I tried ALOT, but i guess I´m doing
    something completely
    > wrong.
    >
    >
    > here is code for my tree so far:
    >
    > my_xml = new XML();
    > my_xml.ignoreWhite = true;
    > my_xml.load("tree.xml");
    >
    > my_xml.onLoad = function(){
    > myTree.dataProvider = this.firstChild;
    >
    >
    > var folders = my_xml.firstChild.firstChild;
    > var docs = folders.childNodes;
    >
    > for (var i=0; i < docs.length; i++){
    > currDoc = docs
    > trace(docs);
    >
    > var docIcon = currDoc.attributes.pic;
    >
    > switch(docIcon){
    > case "pdf":
    > myTree.setIcon(currDoc, "pdfIcon");
    > break;
    > case "word":
    > myTree.setIcon(currDoc, "wordIcon");
    > break;
    > case "excel":
    > myTree.setIcon(currDoc, "excelIcon");
    > break;
    > case "ie":
    > myTree.setIcon(currDoc, "ieIcon");
    > break;
    > }//switch
    > } //for
    > };//onLoad
    >
    >
    > And here is the XML I used:
    >
    > <node label="» Dokument typer">
    > <node label="» links - document">
    > <node label="test.url" url="
    http://www." pic="ie" info="test text" />
    > <node label="test.doc" url="test.doc" pic="word"
    info="test text" />
    > <node label="test.excel" url="test.xls" pic="excel"
    info="test text" />
    > <node label="test.pdf" url="test.pdf" pic="pdf"
    info="test text." />
    > </node>
    > <node label="» Links - document">
    > <node label="test URL" url="
    http://www." pic="ie" info="test text."
    />
    > <node label="test URL" url="
    http://www." pic="ie" info="test text."
    />
    > </node>
    > </node>
    >

Maybe you are looking for