.ig >>
<STYLE TYPE="text/css">
<!--
        A:link{text-decoration:none}
        A:visited{text-decoration:none}
        A:active{text-decoration:none}
        OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; }

        H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; }
        H2 { font-size: large; font-family: arial,helvetica,sans-serif; }
        H3 { font-size: medium; font-family: arial,helvetica,sans-serif; }
        H4 { font-size: small; font-family: arial,helvetica,sans-serif; }
-->
</STYLE>
<title>shsql: insert</title>
<body bgcolor=99cc99 vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550 ><tr>
<td align=right><a href="shsql_home.html">
<img src="img/shsql.gif" border=0><br><small>SQL database system</a> &nbsp; </td></tr>
<td>
.>>

.TH INSERT TDH "18-MAR-2004   TDH scg@jax.org" 

.ig >>
<br><br><br>
.>>
.LP
This manual page descibes the INSERT,
.ig >>
<a href="#update">
.>>
\0UPDATE,
.ig >>
</a>
.>>
and
.ig >>
<a href="#delete">
.>>
\0DELETE
.ig >>
</a>
.>>
commands.

.ig >>
<br><br><br>
.>>

.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
.ig >>
<a href="tabdef.1.html">
.>>
\0tabdef(1)
.ig >>
</a>
.>>
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
.ig >>
<a href="temptables.html">
.>>
\0temporary tables
.ig >>
</a>
.>>
or
.ig >>
<a href="ordfiles.html">
.>>
\0ordinary files.
.ig >>
</a>
.>>
.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>
.>>
.ig >>
<br><br><br>
.>>

.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
.ig >>
<a href="whereclause.html">
.>>
\0WHERE clause
.ig >>
</a>
.>>
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 
.ig >>
<a href="config.html#dbmaxrows">
.>>
\0default row limit
.ig >>
</a>
.>>
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
.ig >>
<a href="temptables.html">
.>>
\0temporary tables
.ig >>
</a>
.>>
or
.ig >>
<a href="ordfiles.html">
.>>
\0ordinary files.
.ig >>
</a>
.>>
.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>
.>>
.ig >>
<br><br><br>
.>>

.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
.ig >>
<a href="whereclause.html">
.>>
\0WHERE clause
.ig >>
</a>
.>>
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.

.ig >>
<br><br><br>
.>>

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

.ig >>
<br>
<br>
</td></tr>
<td align=right>
<a href="shsql_home.html">
<img src="img/shsql.gif" border=0></a><br>
<a href="Copyright.html">Copyright Steve Grubb</a> &nbsp;
</td></tr>
</table>
.>>
