#set TITLE = "INSERT"
#include top

#include space
.LP
This manual page descibes the INSERT,
#set FILE = "#update"
#set TAG = "UPDATE,"
#include link
and
#set FILE = "#delete"
#set TAG = "DELETE"
#include link
commands.

#include space

.SH INSERT 
\fCINSERT\fR writes one new row to a database table.  

.IP
\fCINSERT INTO \fItable\fC  [ ( \fIfieldname1 .., fieldnameN \fC ) ]
.br
VALUES ( \fIvalue1 ..,valueN\fC )
.LP
If fieldnames are not specified then table fields will be taken in 
natural order, which is probably a risky coding practice (use
#set FILE = "tabdef.1.html"
#set TAG = "tabdef(1)"
#include link
to list the table's fields).
Each \fIvalue\fR must be a constant.
Any fields not mentioned will be initialized to \fCnull\fR.  
Zero-length constants will be converted to \fCnull\fR.
\fCINSERT\fR cannot be used on
#set FILE = "temptables.html"
#set TAG = "temporary tables"
#include link
or
#set FILE = "ordfiles.html"
#set TAG = "ordinary files."
#include link
.LP
Examples:
.IP
.nf
insert into songs (id, artist, title, writer, length, album)
	values (1, "Pink Floyd", "Speak to me", 
		null, null, "Dark side of the moon")

insert into songs
	values (2, "Count Basie", "It's Oh So Nice", "", "", 
		"Basie, Straight Ahead")

insert into properties
	(id, mls, neighborhood, street, city, 
	 county, zip, school, listprice, style, 
	 bedrooms, bathrooms, lotsize, yearbuilt, 
	 heat, basement, features )

    	values ( 1, BA2804, "Rockdale", "", "Liddleford",
	"Westbrook", "01234", null, "234000", "rancher",
	3, 2, 0.34, 1984, "forced air", full, null )

.fi

.ig >>
<a name=update></a>
.>>
#include space

.SH UPDATE
\fCUPDATE\fR modifies one or more existing rows in a table, or can add a new row if \fCORINSERT\fR is used.
.IP
\fCUPDATE \fItable\fC  [ ORINSERT ]
.br
SET
.br
\fIfieldname1\fC  =  \fIvalue1\fC ,
.br
\0.\0.
.br
\fIfieldnameN\fC  =  \fIvalueN\fC
.br
WHERE  \fIconditional-expression\fC
.br
[MAXROWS \fImaxrows\fR]

.LP
A
#set FILE = "whereclause.html"
#set TAG = "WHERE clause
#include link
is always required.
It is not considered an error if no rows are found that meet the where clause
(the row count may be checked to determine this).  
Each \fIvalue\fR must be a constant.
Zero-length constants will be converted to \fCnull\fR.
.LP
\fBshsql\fR extends standard SQL with the keywords \fCORINSERT\fR and \fCMAXROWS\fR.
If \fCORINSERT\fR is specified, record(s) will be updated normally if found, 
but if not found a new record will be inserted (fields not \fCSET\fR will be \fCnull\fR).
\fCMAXROWS\fR may be used to raise the 
#set FILE = "config.html#dbmaxrows"
#set TAG = "default row limit"
#include link
of 2000 rows 
or be set to a low number (typically 1)
to ensure that an update will only affect an anticipated number of rows.
If \fCMAXROWS\fR is exceeded the entire update is cancelled.
.LP
\fCUPDATE\fR cannot be used on
#set FILE = "temptables.html"
#set TAG = "temporary tables"
#include link
or
#set FILE = "ordfiles.html"
#set TAG = "ordinary files."
#include link
.LP
Example:
.IP
.nf
update people set lastname = "Sherman",
    	firstname = "Bobby", email = "bobby@bibbet.net"
  	where people_id = 245


update bugtracking orinsert set id = 2480, owner = "steve",
    status = "open" where id = 2480 

.fi


.ig >>
<a name=delete></a>
.>>
#include space

.SH DELETE
\fBDELETE\fR deletes one or more existing rows.
.IP
\fCDELETE FROM  \fItable\fC  
.br
WHERE \fIconditional-expression\fC
.br
[MAXROWS \fImaxrows\fC]
.LP
A
#set FILE = "whereclause.html"
#set TAG = "WHERE clause
#include link
is always required.
It is not considered an error if no rows are found that meet the where clause
(the row count may be checked to determine this).  
\fCMAXROWS\fR is a \fBshsql\fR extension and has similar function as with \fCUPDATE\fR,
described above.

#include space

.LP
Example:
.IP
.nf
delete from people where people_id = 279
.fi

#include bottom
