Progress
DataServer for
Microsoft SQL Server
Guide


Record Creation

Record creation is handled differently for Progress databases and MSS data sources accessed through the DataServer. The difference occurs because Progress code run against a Progress database follows different record-scoping rules than Progress code run against an MSS data source. The code fragments in this section illustrate these differences.

Suppose that you have a table called cust with a field called cust-num that is defined as an indexed field, and you write the following procedure:

DO TRANSACTION:
		CREATE customer.
		name = "SMITH". 
		cust-num = 10. 
		address = "1 Main St".
END. 

When you run this procedure:

The following procedure, which uses multiple buffers for the same record, illustrates the differences between Progress and DataServer record creation:

DEFINE BUFFER xcust FOR customer.
CREATE customer.
cust-num = 111.
FIND xcust WHERE xcust.cust-num = 111.
DISPLAY xcust.  

In this procedure, the code creates a customer, sets cust-num equal to 111, then finds and displays the customer record using cust-num (the unique index). In this case:

To get a consistent response from the DataServer, use this procedure instead:

DEFINE BUFFER xcust FOR customer.
CREATE customer. 
cust-num = 111. 
VALIDATE customer. /* or RELEASE customer. */
FIND xcust WHERE xcust.cust-num = 111.
DISPLAY xcust.  

The VALIDATE or RELEASE statement causes the DataServer to write the customer 111 record to the database before the FIND statement occurs.

NOTE: If you set the default value when creating a record, you must change the value before you create another record with the default value if the field is part of a unique key. Otherwise, the second record will cause a duplicate key error.

Record updates are handled similarly to record creation. A record is updated in an MSS data source at the end of record scope or at the end of a transaction, whichever comes first. For example, when you run the following procedure, the newly updated record is not found:

FIND customer WHERE cust-num = 12.
DO TRANSACTION.
  ASSIGN address = "14 Oak Park".
  FIND customer WHERE address = "14 Oak Park".
END.  

To send the record to the data source sooner, use the VALIDATE statement, as follows:

FIND customer WHERE cust-num = 12.
DO TRANSACTION:
		ASSIGN address = "14 Oak Park".
		VALIDATE customer.
		FIND customer WHERE address = "14 Oak Park".
END. 

For more information about record scoping and transaction behavior, see the Progress Programming Handbook.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095