1 Reply Latest reply on Jul 21, 2013 6:47 PM by Val Palhories

    find_by_sql not returning all rows ... why????

    Val Palhories

      I have the following model:

       

      class OrderActivity

        include Rhom::FixedSchema

        property :RowID, :long

        property :LastModifiedDateTime, :datetime

        property :LastModifiedUserID, :long

        property :ActivityTypeId, :long

        property :ActivitySubTypeID, :long

        property :ActivityUserId, :long

        property :ActivityDateTime, :datetime

        property :OrderID, :long

        property :ActiveIND, :bool

        property :DiscountId, :long

        property :Subtotal, :float

        property :Invoicetotal, :float

        property :Workedhours, :float

        property :Signature, :blob

        property :NoteID,:long

        property :SignedByName, :string 

        unique_index :by_orderactivityrowid, [:RowID]

        index :by_order_typeid, [:OrderID, :ActivityTypeID]

        set :schema_version, '5.2.3'

       

      I have the following method inside the model:

       

      def self.GetDiscountOrderActivityRecord(orderid, typeid, userid)

            sql = "SELECT RowID, DiscountId"

            sql = sql + " FROM OrderActivity"

            sql = sql + " WHERE ActiveIND = 'true'"

            sql = sql + " AND OrderID = " + orderid

            sql = sql + " AND ActivityTypeId = " + typeid

            if userid != 0

                sql = sql + " AND LastModifiedUserID = " + Settings.GetLoggedInUser().to_s

            end

            sql = sql + " ORDER BY ActivityDateTime"

           

            discountRecords = OrderActivity.find_by_sql(sql)

            return discountRecords

        end

       

      When I execute the GetDiscountOrderActivityRecord discountRecords contains the following:

       

      discountRecords[{:source_id=>40003, :object=>"", :RowID=>"-9007199254587395"}]

       

      Why isn't DiscountID being returned????

       

      Thanks

       

      -- Val