13.01.2013 Views

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Record creation<br />

Suppose that you have a table called customer with a field called custnum that is<br />

defined as an indexed field, and you write the following procedure:<br />

DO TRANSACTION:<br />

CREATE customer.<br />

ASSIGN<br />

customer.name = "SMITH"<br />

customer.custnum = 10<br />

customer.address = "1 Main St".<br />

END.<br />

When you run this procedure:<br />

• The <strong>OpenEdge</strong> database does not create the record at the CREATE statement.<br />

Instead, it writes it to the database at the end of the record scope or when the<br />

index in<strong>for</strong>mation is supplied, whichever occurs first. In this example, the<br />

<strong>OpenEdge</strong> database writes the record after executing the statement custnum =<br />

10.<br />

• The <strong>Data</strong><strong>Server</strong> writes the record later, at the end of the record scope. In this<br />

example, it writes the record after executing the statement END.<br />

The following procedure, which uses multiple buffers <strong>for</strong> the same record, illustrates the<br />

differences between the <strong>OpenEdge</strong> database and <strong>Data</strong><strong>Server</strong> record creation:<br />

DEFINE BUFFER xcust FOR customer.<br />

CREATE customer.<br />

customer.custnum = 111.<br />

FIND xcust WHERE xcust.custnum EQ 111.<br />

DISPLAY xcust.<br />

In this procedure, the code creates a customer, sets custnum equal to 111, then finds<br />

and displays the customer record using custnum (the unique index). In this case:<br />

• The <strong>OpenEdge</strong> database displays the customer 111 record.<br />

• The <strong>Data</strong><strong>Server</strong> fails to find customer 111 because it has not yet written the record<br />

<strong>for</strong> customer 111 to the data source.<br />

To get a consistent response from the <strong>Data</strong><strong>Server</strong>, use this procedure instead:<br />

DEFINE BUFFER xcust FOR customer.<br />

CREATE customer.<br />

customer.custnum = 111.<br />

VALIDATE customer. /* or RELEASE customer. */<br />

FIND xcust WHERE xcust.custnum EQ 111.<br />

DISPLAY xcust.<br />

<strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong> 91

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!