Try OpenEdge Now
skip to main content
DataServer for Microsoft SQL Server
RDBMS Stored Procedure Details : ROWID Support : Additional ProDataSet support
 

Additional ProDataSet support

As previously demonstrated in the example, Usingthe LOAD-RESULT-INTO technique to populate the underlying Temp-Tableof a ProDataSet , the LOAD-RESULT-INTO functionality provides a very fast and efficient way to populate the temp-table(s) of a ProDataSet Object. The example that follows is a two-part example that builds on the techniques demonstrated in the previous example.

Use the LOAD-RESULT-INTO technique with BEFORE-FILL method to fill the temp-table(s) of a ProDataSet

The example that follows shows the ProDataSet object BEFORE-FILL procedure can be modified to provide a single ProDataSet data access object that can be used against native OpenEdge or against MS SQL Server and other DataServer data sources.
DEFINE VARIABLE hSendSQL  AS HANDLE NO-UNDO EXTENT 1.
DEFINE VARIABLE phDataSet AS HANDLE NO-UNDO.
DEFINE VARIABLE rid-1     AS ROWID  NO-UNDO.
DEFINE VARIABLE rdi-2     AS ROWID  NO-UNDO.

DEFINE TEMP-TABLE ttCustomer LIKE Sports.Customer
  FIELD tRecid       AS ROWID
  FIELD tRECID_ident AS INTEGER.

hSendSQL[1] = TEMP-TABLE ttCustomer:HANDLE.

DEFINE DATASET dsCustomer FOR ttCustomer.
DEFINE QUERY qCustomer FOR Customer.

phDataSet = DATASET dsCustomer:HANDLE.
phDataSet:SET-CALLBACK-PROCEDURE
  ("BEFORE-FILL", "preDataSetFill", THIS-PROCEDURE).

DEFINE DATA-SOURCE srcCustomer FOR QUERY qCustomer.
BUFFER ttCustomer:HANDLE:ATTACH-DATA-SOURCE
  (DATA-SOURCE srcCustomer:HANDLE,?,?,?).
DATASET dsCustomer:FILL().

FIND FIRST Customer WHERE Customer.CustNum = 1 NO-LOCK.
rid-1 = ROWID(Customer).

FIND FIRST ttCustomer WHERE ttCustomer.CustNum = 1 NO-LOCK.
rid-2 = ttCustomer.tRecid.

IF rid-1 NE rid-2 THEN
  MESSAGE "The same record but different ROWID's".
IF rid-1 EQ rid-2 THEN
  MESSAGE "Congratulations - we have the same ROWID's".

MESSAGE STRING(ttCustomer.tRecid) VIEW-AS ALERT-BOX.

PROCEDURE preDataSetFill:
  DEFINE INPUT PARAMETER DATASET FOR dsCustomer.
  DEFINE VARIABLE handle1  AS INTEGER NO-UNDO.
  DEFINE VARIABLE hSendSQL AS HANDLE  NO-UNDO EXTENT 1.

  hSendSQL[1] = TEMP-TABLE ttCustomer:HANDLE.

  IF DBTYPE(NUM-DBS) NE "PROGRESS" THEN DO:
    DISPLAY "DataServer FILL using SEND-SQL".
    BUFFER ttCustomer:HANDLE:FILL-MODE = "NO-FILL".
    RUN STORED-PROC send-sql-statement LOAD-RESULT-INTO hSendSQL
      ("select * from customer").
  END.
  ELSE DO: /* normal OpenEddge FILL procedure */
    DISPLAY "Native Progress FILL".
    QUERY qCustomer:QUERY-PREPARE("FOR EACH Customer").
  END.
END PROCEDURE. /* preDataSetFill */