Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    Unanswered: Update statement long and complex

    Be gentle with me. I'm far from an expert.

    I have a perl-based application that uses a table with about 50 fields. When I have a user input their information, the insert statement is fairly simple:
    insert into customers values ($name, $address, $city ...

    If I want them to update their information, I give them a similar input screen with the current information filled in from the database. They alter what needs to be changed, and the target perl script must enter a statement something like this:

    update customers set name=$name, address=$address, city=$city ...

    This can get very long. Is there a more streamlined way to do this update, more along the lines of the insert command: values($name, $address, $city ...)

    Thanks in advance for any help.

  2. #2
    Join Date
    Jul 2004
    Dundee, Scotland
    INSERT INTO customers (`name`,`address`) VALUES ('$name', '$address') ;

    ... so if you split the update page into multiple pages, the update command on each page would only need to update the fields that could change on any given page.

    or, a more complex approach would be, when presenting the update form, hold each field from the database twice in the form. One field is editable, the other would be hidden. Then when processing the update stuff, compare each editable field with it's original and dynamically build the update SQL command so that only the database fields that have changed are updated.

Posting Permissions

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