Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    (bug) Case statement error in SQL Select when using ValueMap in DataSource

    SmartGWT:

    SNAPSHOT_v8.3d_2012-06-01/PowerEdition Deployment (built 2012-06-01)

    Firefox 9.0

    I have a data source that uses a value map like as defined in the attachment
    BCG_STA_Setup.ds.xml.txt.

    When it creates the SQL fetch query it is as in the attachment:
    Incorrect Select Generated.txt

    I have corrected the Select to add the CASE statement keyword back in as shown in the attachment:
    Corrected Select Generated.txt

    The corrected select works fine, just by adding the CASE keyword.

    This seems like a bug.

    If I change the Value map of the ENUM in the Datasource to where there is no ID defined for each entry the select is correctly generated but of course is missing the CASE statement.

    I need to us this form of ValueMap definition in the DS otherwise simple code like the following crashes with an exception on the line where valueMap is evaluated.

    DataSourceField[] dsFields = srcDS.getFields();
    Map valueMap = null;
    for (i = 0; i < dsFields.length; i++) {
    String fieldName = dsFields[i].getName();
    if (fieldName.contains("WaiveState")) {
    valueMap = dsFields[i].getValueMap();
    }
    }

    Please comment
    Attached Files

    #2
    Both SQL statements appear to have the same CASE statement, did you accidentally upload the same thing twice?

    Comment


      #3
      I downloaded both of these files back from your web site, and I can see the difference between the files.

      Use tkdiff to show it to you on a Linux box.

      Anyway the INCORRECT Select statement has this expression:

      SELECT *, ROW_NUMBER() OVER (ORDER BY x.WaiveState WHEN '1' THEN 'Waived' WHEN '2' THEN 'Pending' WHEN '3' THEN 'Not Waived' END) AS rowID

      The manually CORRECTED Select statement has this expression:

      SELECT *, ROW_NUMBER() OVER (ORDER BY CASE x.WaiveState WHEN '1' THEN 'Waived' WHEN '2' THEN 'Pending' WHEN '3' THEN 'Not Waived' END) AS rowID

      Yes they both have case statement, just the first has a missing CASE keyword

      Comment


        #4
        Ah sorry, we were focused on the CASE statement at the end (which is the same in both queries). We'll take a look.

        Comment

        Working...
        X