SQL Delete

Deleting table rows

The example below is an SQL function in Net.Data showing a simple form of a delete. Pay attention to the WHERE clause--this is what determines what rows will be deleted from the table. Omitting the WHERE clause will remove all rows from the table.

SQL Delete


%{ ***************************************************** %}
%{ ************ Delete record ************************** %}
%{ ***************************************************** %}

%FUNCTION(DTW_SQL) DltRecord(IN pCOD) {
 DELETE FROM $(tableName)
 WHERE STDSTS = $(pCOD) 
        %message{
                100: "Record not found." : continue
                  0: "Record deleted." : continue
        %}
 %report {
  %row {
  %}
 %}
%}