10 Replies Latest reply on Nov 2, 2012 1:34 AM by Vidyaa Natarajan

    SQL query is not working in BlackBerry 7.0

      Hi all,

       

      I have created an application in Rhodes. I have used Sql queries to connect the database. But I am getting an SQL logic error. I have attached the screenshot along with this mail. Please help me to fix this issue.

        • Re: SQL query is not working in BlackBerry 7.0
          Glenn Sayer

          Rhom is a mini database object mapper for Rhodes. It provides a high level interface to make it very powerful and simple to use a local database.  That database is SQLite on all platforms except BlackBerry where it is HSQLDB.

           

          see the below link for more information.

           

          http://docs.rhomobile.com/rhodes/rhom

            • Re: SQL query is not working in BlackBerry 7.0

              Thanks Glenn.

              I have tried using HSQLDB by referring the same rhomobile document. But I am getting the same error.

              Please help me to fix this issue.

                • Re: SQL query is not working in BlackBerry 7.0
                  Glenn Sayer

                  Can you please share the code of where you think it is erroring?  Are you trying to connect to the DB on the device or a backend service?

                    • Re: SQL query is not working in BlackBerry 7.0

                      Thanks Glenn,

                       

                      I am sending you the method where I am facing this error.

                       

                      def menuscreen

                       

                          @mobiles = Mobile.find(:all)

                          puts  "#{@mobiles}"

                          to_day = Date.today

                          @time = Time.now.strftime("%d/%m/%Y")

                          total_summary = Invoice.find_by_sql("SELECT cast(Round(sum(inv_due_amt),0)as int) as PORTFOLIO FROM `invoice`;")

                       

                          total_summary.each do |total|

                            @total_value = (total.PORTFOLIO).to_i

                            @pf_cus_account = ss(@total_value)

                          end

                       

                          total_not_due = Invoice.find_by_sql("SELECT cast(Round(sum(inv_due_amt),0)as int) AS PORTFOLIO,date(invoice.inv_due_date, '+1 days') as invoice_date FROM `invoice` Where invoice_date >= '#{to_day}'")

                       

                          total_not_due.each do |total|

                            if !(total.PORTFOLIO).nil?

                              @total_not_due = (total.PORTFOLIO).to_i

                              @not_due_total = ss(@total_not_due)

                              due_precent = (@total_not_due.to_f/@total_value.to_f)*100

                              @total_not_due_precent = "#{due_precent.round}%"

                            else

                              @not_due_total = "-"

                              @total_not_due_precent = "-"

                            end

                          end

                       

                          total_due_amount = Invoice.find_by_sql("SELECT cast(Round(sum(inv_due_amt),0)as int) AS PORTFOLIO,date(invoice.inv_due_date, '+1 days') as invoice_date FROM `invoice` Where invoice_date < '#{to_day}'")

                       

                          src = Rhom::RhomSource.find(:all).first

                          if (src.last_updated.strftime("%d/%m/%Y") != '01/01/1970')

                            @sync_date = src.last_updated.strftime("%d/%m/%Y, %I:%M%p")

                          else

                            @sync_date = ""

                          end

                       

                          total_due_amount.each do |total|

                            if !(total.PORTFOLIO).nil?

                              @total_due_amount = (total.PORTFOLIO).to_i

                              @past_due_total = ss(@total_due_amount)

                              due_precent = (@total_due_amount.to_f/@total_value.to_f)*100

                              @total_due_amount_precent = "#{due_precent.round}%"

                              if (due_precent.round) <= 5

                                @due_amount_flag = "green"

                              elsif (due_precent.round) >= 6 && (due_precent.round) <= 10

                                @due_amount_flag = "orange"

                              elsif (due_precent.round) >= 11

                                @due_amount_flag = "red"

                              end

                            else

                              @total_due_total = "-"

                              @total_due_amount_precent = "-"

                            end

                          end

                       

                        end

                       

                      In this method, I am fetching the data from the Backend and With the received data I have done calculations. 

                       

                      I have attached the error I am getting in the BlackBerry 7.0 Simulator. I have used use_sqlite: 0 in my Build.yml file.

                       

                      Please help me to fix this issue. After Logging in I am getting this error. I am stuck with this and couldn't able to proceed furthur.

                • Re: SQL query is not working in BlackBerry 7.0
                  charles plasse

                  Hi

                   

                  Same issue. Is there someone from Rhomobile could help ?

                   

                  Thanks

                   

                  Charles

                  • Re: SQL query is not working in BlackBerry 7.0

                    Hi Glenn,

                     

                    I have created a Rhodes application. The application is successfully executed in Blackberry 5.0 and 6.0 devices. But I getting error in Blackberry 7.0. For me, after logging in all the data's are getting synced from the backend database. But the queries which I have used in my controller is not working. The following are the queries which I have used in my application.

                     

                    1) SELECT cast(Round(sum(inv_due_amt),0)as int) as PORTFOLIO FROM Invoice;

                     

                             ---> I am not getting any values from this query.

                     

                    2) SELECT cast(Round(sum(inv_due_amt),0)as int) AS PORTFOLIO,date(invoice.inv_due_date, '+1 days') as invoice_date FROM Invoice Where
                         invoice_date >= '2012-11-02'

                     

                          ----> I am getting Unexpected token: date error

                     

                    I have tried with DATE_ADD() function in the second query by referring to the HSQLDB docs. But I am getting as Undefined token: DATE_ADD error in BB7.

                     

                    1) Is there any files or libraries to be added into my application in order to use HSQLDB?

                     

                    I am stuck with this issue.Please help me to fix this issue.

                     

                    Thanks in advance,

                    Vidyaa.N