6 Replies Latest reply on Oct 1, 2013 4:18 AM by davehob

    SQL beginner question

    davehob

      Just making my first forays into the world of ExecuteSQL, and I’ve hit a couple of problems, with which I’d appreciate some guidance.

      I’ve started with a couple of really simple examples, such as:

      ExecuteSQL ( "Select NameFirst from People" ; "";"")

      – this was fine.

       

      Then I tried:

      ExecuteSQL ( "Select Date from Sessions" ; "";"")

      – and it returned an error. After a bit of digging, I found that this was because “Date” is a reserved word in SQL, so I had to put ” either side of it, then it was fine.

       

      Next, I tried:

      ExecuteSQL ( "Select __kp_ID from People" ; "";"") (where __kp_ID is the name of the key field)

      – and it returned an error, apparently because “_” is a reserved character, so I had to escape the key field name as well. It was then OK.

       

      But I’m just wondering whether I’m heading for more problems further down the line by having all my key fields prefixed with the underscore? Should I adopt a different naming convention? Although the underscore prefix hasn’t been a problem until now, might I be heading for more issues, e.g. when it comes to abstracting these field names?

       

      Dave.