Hitachi Vantara Pentaho Community Forums
Results 1 to 11 of 11

Thread: Execute the PL/SQL if Condition

  1. #1
    Join Date
    Apr 2007
    Posts
    12

    Post Execute the PL/SQL if Condition

    HI,


    I am trying to do the following:-

    1. Retrieve a table using step table input
    2. Then would like to check rowcount<>1/rowcount==0. If the condition is true then only will we move forward else terminate. here I'm facing problems.

    Anyone please help here.

    Thanks
    Santosh

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    You probably need more than 1 transformation. Have a look at http://kettle.pentaho.org/tips/?tip=7 for a similar case.

    Regards,
    Sven

  3. #3
    Join Date
    Apr 2007
    Posts
    12

    Default

    Thanks Sven. Your reply is a good help for me.

    Thanks once again

  4. #4
    Join Date
    Apr 2007
    Posts
    12

    Post

    Hi Sven,

    Please refer to the link sent by you, I followed the instructions but facing problems in evaluation step for table input from a database.

    Please help.


    Thanks

    Regards
    Santosh

  5. #5
    Join Date
    May 2006
    Posts
    4,882

    Default

    Search in the document for "The "Group by" step simply counts the number of rows." and read from there.

    Which specific problem do you have?

    Regards,
    Sven

  6. #6
    Join Date
    Apr 2007
    Posts
    12

    Default

    I have following to process:-

    I have a table in SQL Server DB. On this table, we are executing one select operation. This operation will return 1/0 rows. Depending the No. of rows returned by the query we will process further.


    To do this, I've done following

    1. In CalculateParameter.ktr,
    a) File Input has been replaced by Table Input
    b) Gropy by has been replaced by Execute SQL Statements in which executing
    SELECT count(*)
    FROM SomeTable

    c) step 3 copy rows to result remains same

    2. In the .kjb file

    In the evaluationstep I need to check for

    No. of rows<>1 or No. of rows>0

    for which I've given following code

    var nrRows = rows.length
    nrRows > 0

    but, this statement is always true.

    Regards
    Santosh

  7. #7
    Join Date
    May 2006
    Posts
    4,882

    Default

    1b) is wrong... do the group by in 1a)

    rows ... not rows.length (if you name your new grouped field "rows").

    Regards,
    Sven

  8. #8
    Join Date
    Apr 2007
    Posts
    12

    Default

    Thanks a lot Sven for your quick and great replies.

    For no NO. of Rows is 0, the javascript condition is not compiling. Help again please.

    Regards
    Santosh

  9. #9
    Join Date
    May 2006
    Posts
    4,882

    Default

    attach the part you're having problems with and we can have a look at it.

    Regards,
    Sven

  10. #10
    Join Date
    Apr 2007
    Posts
    12

    Default

    Please find attached the kjb and ktr files for your kind inspection.

    The compilation error is coming in Evaluation step if nr==0.


    Thanks & Regds
    Santosh
    Attached Files Attached Files

  11. #11
    Join Date
    May 2006
    Posts
    4,882

    Default

    It's a bug... short term solution would be to always make sure the groupby receives 1 row. Either by:
    - adding 1 dummy row (via a row generator) and then taking as base 1 instead of 0 (if there are zero input rows you would get a count of 1)
    - removing the group by and counting the number of row in the table input step. Then you can always get 1 row back.

    I'll raise a bug tracker this evening.

    Regards,
    Sven

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.