Announcement

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

    How can I exclude a SQL Server computed column from an update statement?

    I have a computed column in a SQL Server table. The column cannot be modified, but I need to add it to the DataSource in order for it to display in a ListGrid. How can I instruct SmartGWT to ignore this column in add/update statements?

    I have tried adding canSave="false" to the field definition in the DataSource xml file, but this has no effect.

    #2
    canEdit="false" is what you want.

    Comment


      #3
      Thank you much. I knew it had to be simple.

      Comment


        #4
        looks like I spoke too soon. I tried what you said and the error persists.

        I'm defining the field in the DataSource like this:
        Code:
        <field name="CURRENT_PROVIDER_ID" type="number" canEdit="false" />
        The field is still being included in the SQL update statement and a database exception is thrown:
        Code:
        SQLServer threw exception: com.microsoft.sqlserver.jdbc.SQLServerException: The column "CURRENT_PROVIDER_ID" cannot be modified because it is either a computed column or is the result of a UNION operator. - assuming stale connection and retrying update.
        Am I missing a semi-colon somewhere or something?

        Comment


          #5
          Oops sorry, that setting would be sufficient in 3.x but you are probably on 2.x.

          The quickest way to do it in 2.x: declare the field as "customSQL" true but for the "fetch" operationBinding, set customValueFields="fieldName" to allow it to be returned from fetch. More detail in the QuickStart Guide, Server Framework chapter, SQL Templating sections.

          Comment


            #6
            Sorry, I usually post my version number with every post, but I assumed this being such a simple problem it wouldn't matter. DOH!

            Comment


              #7
              Simple in both versions, just simpler in 3.x :)

              Comment

              Working...
              X