This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Dec 1, 2011, 10:24 AM
46 Posts
topic has been resolvedResolved

@Dblookup wrong totals

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
Hi, i have problem with @DBLookup:
 
Sven Hasselbach improved my code and now it looks like:
 
var month_string ="2010-2";
var keys =["CU"+ month_string];
var result = new Array();
var v =null; var i = 0;
for (i = 0; i < keys.length; i++)
   { v =@DbLookup("","raport",keys[i],1);
    if( typeof(v) != "undefined" ){
        result.push(v.length);
    }
   }
result
 
@DbLookup works if the value in the view is grater than one.
 
if my key in the view occurs only once like: CU2010-2 I get this result = 8
for keys CU2010-1 end CU2010-3 
I get the correct values
 
Dec 1, 2011, 11:03 AM
272 Posts
Re: @Dblookup wrong totals
Hi,
 
you receive an eight for your single entry because you are adding the length of the returned object to your array. There are different results for this, dependent of what object type is returned by the @DBLookup.
If there is only one entry, the @DBLookup returns a string, which has a length of eight characters. If there are more entries, the @DBLookup returns a vector with a length of two elements for CU2010-1 and three elements for CU2010-3.
 
Hope this helps
Sven
 
 
EDIT:
Just use @Elements(v) instead:
 
var month_string ="2010-2";
var keys =["CU"+ month_string];
var result = new Array();
var v =null; var i = 0;
for (i = 0; i < keys.length; i++)
   { v =@DbLookup("","raport",keys[i],1);
        result.push( @Elements( v ) );
   }
result
 
Dec 1, 2011, 11:27 AM
46 Posts
Re: @Dblookup wrong totals
Sven once again helped me a lot.
 
Thank you very much.
Tomek
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal