Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Embarrassing question

  1. #1
    Join Date
    Jul 2008
    Posts
    14

    Default Embarrassing question

    Because I'm certain it will be dead obvious.

    I'm using version 3.1. I've got a snippet of Javascript where I'm attempting to set the value of two variables (defined upstream as type Boolean). I've tried as many things I can think of (1's and 0's, true and false, Y and N) to set the values of the variables.

    the problem is there is a downstream DB Procedure Call step that requires these two variables of type Bit (which according to the SQL Help, is a Boolean). The procedure call always fails complaining it can't convert an nvarchar to a bit, (unless I set them data type of isFix and isVar to be Integers, with length 1, but then the function isn't interpreting them as boolean, and I don't get back the right values).

    So, long story short, how do I set the value of the booleans so they aren't interpreted as a nvarchar (or double).
    Thanks

    ian

    var
    uvol = UnitVolume.getString();

    if
    (uvol == "")
    {
    isFix.setValue(1);
    isVar.setValue(0);

    // isFix = 1;
    // isVar = 0;
    // isFix = (isFix)bit;
    }
    else
    {
    isVar.setValue(1);
    isFix.setValue(0);
    // isVar = 1;
    // isFix = 0;
    }



  2. #2

    Default

    Actually I didn't understand exactly what you need, but it looks you need something about data types. Try to pass through Java. Call java.lang.xxx or any other package within your script, and then put that variable as a field.

    Hope it helps.

    Iuri

  3. #3
    Join Date
    Nov 1999
    Posts
    9,729

    Default My take...

    1) do NOT use setValue(), just create another field
    2) Turn off compatibility mode and get rid of getString() and the likes
    3) Comparing to "" is not done, try:

    Code:
    var newFix;
    var newVar;
    
    if (UnitVolume==null) {
       newFix = 1;
       newVar= 0;
    } else {
      newFix = 0;
      newVar = 1;
    }




  4. #4
    Join Date
    Jul 2008
    Posts
    14

    Default

    Matt and Biuri,

    Thanks for the info. I guess I didn't properly explain the problem I'm running into.

    Downstream of the javascript step I have a call to a database procedure, which takes as part of its arguments, two Bit parameters (isFix and isVar).

    No matter what I do in the javascript (unless I define these two variables as Integers, but then the results of the function call are incorrect), I get an error message that the two fields (isFix and isVar) cannot be converted to type bit (either from a double, or an nvarchar).

    I'm not a java programmer, but I tried Biuri's suggestion to call directly through (java.lang.xxx), but haven't yet been able to find the function that will allow me to set a boolean value. I'll use some of the reference manuals here at work.

    thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.