Alpha DevCon 2018
Results 1 to 2 of 2

Thread: How to Update Selected Records with SQL, using the checkbox select column?

  1. #1
    Member
    Real Name
    CP Good
    Join Date
    Sep 2009
    Posts
    243

    Default How to Update Selected Records with SQL, using the checkbox select column?

    I have a grid that is based on a MySQL table. I have exposed the "checkbox select column" and I want run an update statement against all of the selected rows. How do I construct a where statement that will only select the items that have been checked?

    For instance if I have a table of customer addresses and I want to updated a logical field called "audited" for all "checkmarked" rows how would I do the following:

    update customer set audited=1 where checkmarked is checked

    Thank you,
    CPGood

  2. #2
    Member
    Real Name
    ferry kurniawan
    Join Date
    Apr 2015
    Location
    Jakarta
    Posts
    96

    Default Re: How to Update Selected Records with SQL, using the checkbox select column?

    function Process as c (e as p)

    dim filter as c
    filter = e.checkboxfilter

    if filter = "" then
    Process = "alert('no data select');"
    exit function

    end if

    dim args as sql::Arguments
    args.xml = e.checkboxFilterArgumentXML

    dim count as n
    count = args.Count
    dim i as n
    dim Vkeys as c

    for i=1 to count
    Vkeys = vKeys + args[i].data + CRLF()

    next i
    debug(1)
    argument_add_array_argument(args,"args_vKeys","C",Vkeys)

    DIM cn as SQL::Connection
    dim flagResult as l
    flagResult = cn.open("::Name::Connection1")
    if flagResult = .f. then
    ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text)
    end
    end if

    'Specify that we are using Portable SQL syntax
    cn.PortableSQLEnabled = .f.

    dim sqlStatement as c
    sqlStatement = <<%sql%
    update YOURTABLE set YOURFIELD = 'YOURVALUE' where id in(:args_vKeys)
    %sql%
    'Execute the Query
    flagResult = cn.Execute(sqlStatement,args)

    if flagResult = .f. then
    ui_msg_box("Error",cn.CallResult.text)
    cn.close()
    end
    end if

    cn.close()
    End Function

Similar Threads

  1. Using checkbox select column to update multiple rows in a grd
    By tcbarker4 in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 04-09-2016, 11:01 PM
  2. Checkbox select column
    By gaby_h in forum Application Server Version 10 - Web/Browser Applications
    Replies: 10
    Last Post: 11-12-2014, 12:29 PM
  3. Checkbox select column and row event
    By Jahnel in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 03-10-2013, 08:33 AM
  4. Using checkbox select column and filtering with email.
    By Atta in forum Application Server Version 10 - Web/Browser Applications
    Replies: 9
    Last Post: 06-04-2011, 07:59 PM
  5. checkbox select column placement
    By christappan in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 10-11-2010, 11:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •