Announcement

Collapse
No announcement yet.

Errors, EOFs, and a successful query

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Errors, EOFs, and a successful query

    In a system module, during an system_update function, I am trying to avoid the "fatal error" scenario when I try to update a row and values already exist. In my query, I am trying to set an error or flag so I can report the reason an update didn't execute to the content screen so the user knows there was an input error and why.

    In theory, I am testing the myview.d.eof value. If there is EOF, the query didn't find a record. If not myview.d.eof, then a record already exists and I need to report the entry error.

    Code:
        <MvIF EXPR = "{ myview.d.EOF }">
            <MvCOMMENT>-SDS--no duplicate found </MvCOMMENT>
            <MvCLOSEVIEW NAME = "Merchant" VIEW = "myview">
            <MvFUNCTIONRETURN VALUE = "0">
        <MvELSE>
            <MvCOMMENT>-SDS--at least one record was found </MvCOMMENT>
            <MvCLOSEVIEW NAME = "Merchant" VIEW = "myview">
            <MvFUNCTIONRETURN VALUE = 1>
        </MvIF>
    Doing the query with known values, all scenarios have the result that myview.d.EOF always fails and at least one record is found.

    Why might myview.d.EOF not be true when no records are found in the query? is there another status I should be checking instead or a better way to accomplish this?

    Note: I've have an Unique Index on the two fields in question, which I assume are the reason for the Fatal Error. Should I consider not having these fields as Unique Indexes?

    Thanks,

    Scott
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    #2
    If functions such as Module_System_Update return a zero, that will always trigger a fatal error for Merchant. I've written lots of system-ex modules, and they always return 1. If some type of user error occurs during Module_System_Update, my code will set a global variable to indicate the error. That variable will still exist when the store calls Module_System_Content; so I'll put some code in there to check the variable and display an error message.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Thanks, Kent.

      I was in a hurry to get out to the office earlier and neglected to specify the query. The query I'm executing is a function executed in the system_update. The return value of 1 or 0 is strictly based on the EOF flag in that function when I do the query -- which asks, does a record already exist?

      I have a couple of other ideas about how to tackle this but this:

      Code:
      <MvIF EXPR = "{ myview.d.EOF }">
         <MvCOMMENT>-SDS--no duplicate found </MvCOMMENT>
         <MvCLOSEVIEW NAME = "Merchant" VIEW = "myview">
         <MvFUNCTIONRETURN VALUE = "0">
      <MvELSE>
         <MvCOMMENT>-SDS--at least one record was found </MvCOMMENT>
         <MvCLOSEVIEW NAME = "Merchant" VIEW = "myview">
         <MvFUNCTIONRETURN VALUE = 1>  
      </MvIF>
      Isn't written to find an error, it's written to gain the status. When I know the status, I can report the status but it also can trigger the table update function running in the system_update.

      My basic question, why would it be that myview.d.EOF is failing to be true?

      Scott
      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment


        #4
        Sorry I was off-target there. I can't tell more without seeing the rest of the code; but I can tell you that I've never found the d.eof flag to be inaccurate. I would put in some debugging messages, and/or test my SQL query using phpMyAdmin, in search of some other cause for the problem.
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          I've also not ever experienced the EOF to be inaccurate either. Hence, baffled.

          Scott
          Need to offer Shipping Insurance?
          Interactive Design Solutions https://www.myids.net
          MivaMerchant Business Partner | Certified MivaMerchant Web Developer
          Competitive Rates, Custom Modules and Integrations, Store Integration
          AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
          My T-shirt Collection is mostly MivaCon T-shirts!!

          Comment


            #6
            Scott, I also have used .EOF for years and never has it failed me. If you misspelled the view, though - wouldn't .EOF on a nonexistent view always be false?

            I can't readily think of anything else that would 'switch off' your experience of using .EOF.
            Gordon Currie
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment

            Working...
            X