UPDATE [SET] [WHERE]

<< Click to Display Table of Contents >>

Navigation:  Apollo SQL > DDL & DML Statements >

UPDATE [SET] [WHERE]

 

The UPDATE statement is used to update, modify or change data in tables.

image\tip.gif Use ExecSQL from within in each Apollo interface to execute this statement.

UPDATE table_reference SET column_reference = expression

[, column_reference = expression...] [WHERE predicate]

 

Use a table reference in the UPDATE clause to specify the table to receive the data changes.

The SET clause is a comma-separated list of update expressions. Each expression is composed of the name of a column in 'table_reference', the assignment operator '=' and the update expression for that column.

image\tip.gif Use ExecSQL from within in each Apollo interface to execute this statement.

Example:

For Apollo VCL users, in the Delphi example ButtonClick event code below, the UPDATE syntax the user enters into the memo window (Memo1) might look something like this:

 

UPDATE test SET First = 'Joe' WHERE (Last = 'Smith') and (Age = 35)

 

procedure TForm1.Button1Click(Sender: TObject);

begin

try

Screen.Cursor := crSQLWait;

ApolloQuery1.SQL.Clear;

ApolloQuery.SQL.Add( Memo1.Text );

ApolloQuery.ExecSQL;

finally

Screen.Cursor := crDefault;

end;

end;

 

image\tip.gif After issuing an INSERT command with ExecSQL, the result will not be immediately reflected in any previous result set. Re-issue a SELECT statement to retrieve the new result set.

Note that after issuing an UPDATE command with ExecSQL, the result will not be immediately reflected in any previous result set SELECT issued. So, you would need to reissue a SELECT statement to pull down a fresh 'snapshot' of the server-side data to see the results of this UPDATE operation.