Announcement

Collapse
No announcement yet.

Using ENCODE/DECODE on a field in MySQL on Form Applications

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

  • Using ENCODE/DECODE on a field in MySQL on Form Applications

    Hi All,

    I am looking for a way to tell SC to use MySQL's ENCODE() function on a form field "Credit Card Number" when I insert or update a record. Conversely, I also need to be able to use MySQL's DECODE() function when retrieving a record with the "Credit Card Field."

    Any advice?

    Unlike some of the other application types, Forms in SC seem to be tightly structured and don't allow me to modify the SQL query manually.

    Perhaps there's some other method that I'm missing.

    Thanks

    Jim

  • #2
    Hi, anyone? Thanks

    Comment


    • #3
      If you are forced to use MYSQL functions, a workaround could be:

      onNavigate Event:
      PHP Code:
      $query "
          SELECT 
            DECODE(credit_card_field)
          FROM 
                table
          WHERE 
                id={id}"
      ;
          
      sc_lookup(rs$query);
      {
      credit_card_field} =  {rs[0][0]}; 
      onBeforeInsert and onBeforeUpdate Events:
      PHP Code:
      $query "
          SELECT 
            ENCODE({credit_card_field})
          FROM 
                DUAL"
      ;
          
      sc_lookup(rs$query);
      {
      credit_card_field} =  {rs[0][0]}; 
      /Giuseppe

      Professional Scriptcase Services
      Some Customers opinions

      Comment


      • #4
        Thanks, Giu! That's the workaround I ended up using... I was hoping there was a cleaner way to use MySQL functions ... like on the Edit Fields page allowing the user to "force value" the wrapping of the field in a function.

        Appreciate your help!

        Jim

        Comment

        Working...
        X