Contact | Privacy | Datenschutzerklärung | Impressum

Updating SQL Tables

Here we'll demonstrate how to use the SQL INSERT, DELETE and UPDATE commands. Although these commands can be used to insert new records, delete old records, and update the data within existing records, you should note that the method demonstrated here is a very low-level approach. The Database Application Components of RADpage contain a much more efficient method of performing these tasks.

First we demonstrate how to insert a new record into a sample Guestbook Table:

<dbupdate>
  INSERT INTO guestbook
   (Guest_Name, Email, Address, Country, Guest_Comment)
  VALUES
   (<? ff.Guest_Name "Q">,
    <? ff.Email "Q">,
    <? ff.Address "Q">,
    <? ff.Country "Q">,
    <? ff.Guest_Comment "Q">)
</dbupdate>

As you can see, we've used the heitml ? Tag above to evaluate the contents of the ff.fieldname expressions and pass the result along to SQL for insertion into the database. Additionally, we specified the "Q" argument to ensure that the result was treated as a quoted string. The effect is the same as if we had done the following:

<dbupdate>
 INSERT INTO guestbook
  (Guest_Name, Email, Address, Country, Guest_Comment)
 VALUES
  ('Testname',
   'nonexisting@h-e-i.de',
   'Wimpfenerstrasse 23, 68259 Mannheim',
   'Germany',
   'I like  heitml.')
</dbupdate>

Experienced programmers know, however, that this literal method of INSERT-ing records into a file is too specific to be useful in real-world applications, but as stated above, there are times when it can be expedient for a programmer to perform operations directly on a Table using little code fragments.

To DELETE a record from an SQL TABLE we could, again, do it by referencing the contents of a variable, or by matching a literal as follows:

By referencing a variable:

<dbupdate>
  DELETE FROM guestbook
   WHERE
     Guest_Name = <? ff.Guest_Name "Q">
</dbupdate>

By matching a literal:

<dbupdate>
  DELETE FROM guestbook
   WHERE
     Guest_Name = 'John Smith'
</dbupdate>

Finally, the syntax of the SQL UPDATE command could be illustrated as follows:

<dbupdate>
  UPDATE guestbook
    SET  Guest_Name = <? ff.Guest_Name "Q">,
              Email = <? ff.Email "Q">,
            Address = <? ff.Address "Q">
   WHERE Guest_Name = <? Old_Guest_Name "Q">
</dbupdate>


This page was dynamically generated by the web application development tool RADpage of H.E.I. H.E.I. provides support, tools, and services like Webdesign in Mannheimm, the HTML/CSS 3D WebGL Animation Library taccgl, 3D Webdesign, and 3D Product Configurator (3D Produkt Konfigurator in German).

Selected blog articles : 3D Objects on HTML pages, CSS Transition Visibility, and CSS Transition Display.


© 1996-2024 H.E.I. All Rights Reserved.



Homepage
Intro/Features
Component Guide
Programming
  Language Guide
    Modular Pages
    Dynamic Pages
    Interactive Pages
      Creating FORMs
      Session Mode
      Search FORMs
      Scrolling Pages
      Email FORMs
      SQL Intro
        Defining Tables
        Updating Tables
          Insert
          Update
          Delete
        Querying Tables
  Language Ref.
  Component Ref.
  Class Library
  User Components
  Tutorial
  New Features
  heitml 1
User Guide
Services
Privacy
Datenschutz
 
Contact / Impressum