Programming Guide



UNIQUE

Suppresses repeating values in selected columns

Synopsis

DBMS [WITH CURSOR cursor] UNIQUE column [, column ...]

Arguments

WITH CURSOR cursor
Name of declared SELECT cursor. If the clause is not used, Panther uses the default SELECT cursor.

column
Column name in the SELECT statement.

Description

DBMS UNIQUE suppresses repeating values in each named column of a select set when the values are in adjacent rows. Typically, this feature is set for a column named in an ORDER BY clause.

If the destination variable has a null edit, an occurrence containing a suppressed value is blank, not null.

The setting is turned off by executing the DBMS UNIQUE command with no arguments. Closing a cursor also turns off the setting. If a cursor is redeclared without being closed, the cursor continues to use to the setting for SELECT statements and CONTINUE commands.

Example

// Since several titles can be rented to the same customer,
// suppress repeating customer numbers when listing
// outstanding rentals.
proc rent_list
DBMS DECLARE rent_cursor CURSOR FOR \
SELECT cust_id, title_id, copy_num, due_back FROM rentals \
WHERE due_back < today \
ORDER BY cust_id
DBMS WITH CURSOR rent_cursor UNIQUE cust_id
DBMS WITH CURSOR rent_cursor EXECUTE
DBMS WITH CURSOR rent_cursor UNIQUE
return