CreateResultSet

PowerBuilder Native Interface

IPB_Session interface:

CreateResultSet method

Description

Syntax

CreateResultSet (IPB_ResultSetAccessor* rs)

Return Values

Examples

#include "stdafx.h"
#include "windows.h"
#include "pbni.h"
#include "vector"
using std::vector;

void main(int argc, char* argv[])
{
   HINSTANCE hinst = LoadLibrary("pbvm170.dll");

   typedef PBXRESULT (*P_PB_GetVM)(IPB_VM** vm);

   P_PB_GetVM getvm = (P_PB_GetVM)GetProcAddress(hinst,
      "PB_GetVM");
   IPB_VM*   pbvm;

   getvm(&pbvm);

   IPB_Session* session = NULL;
   vector<LPCSTR> ll(1);

   ll[0] = "pbrs.pbl";
   
   pbvm->CreateSession("pbrs", &ll[0], 1, &session);

   pbgroup group = session->FindGroup("n_rs",
      pbgroup_userobject);
   if (group == NULL) return;
   
   pbclass cls = session->FindClass(group, "n_rs");
   if (cls == NULL) return;
      
   pbobject obj = session->NewObject(cls);
   if (obj == NULL) return;

   pbmethodID mid = session->GetMethodID(cls, "f_ret",
      PBRT_FUNCTION, "Cresultset.");
   PBCallInfo ci;
   session->InitCallInfo(cls, mid, &ci);
   session->InvokeObjectFunction(obj, mid, &ci);   
  
// Use the result set returned from f_ret to
   // create an IPB_ResultSetAccessor rsa
   pbobject rs = ci.returnValue->GetObject();
   IPB_ResultSetAccessor* rsa =
      session->GetResultSetAccessor(rs);

   // Create a result set object from rsa
   pbobject rsobj = session->CreateResultSet(rsa);
   

   // Call the f_in method
   mid = session->GetMethodID(cls, "f_in",
      PBRT_FUNCTION, "IRCresultset.");
   PBCallInfo ci1;
   session->InitCallInfo(cls, mid, &ci1);
   // Set the result set object rsobj as the
   // argument for f_in
   ci1.pArgs->GetAt(0)->SetObject(rsobj);
   session->InvokeObjectFunction(obj, mid, &ci1);


   session->FreeCallInfo(&ci);
   session->FreeCallInfo(&ci1);
}
ResultSet rs
DataStore ds

Long sts
Integer li_ret

// Profile PB Demo DB V170
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = &
   "ConnectString='DSN=PB Demo DB V170;UID=dba;PWD=sql'"
connect using sqlca;

ds = Create DataStore
ds.DataObject = ""
ds.DataObject = "d_rs"
ds.SetTransObject(sqlca)
w_main.dw_1.SetTransObject(sqlca)

long ll_ret, rows, rows2
ll_ret = ds.Retrieve()
ll_ret = w_main.dw_1.Retrieve()
//ds.sharedata(w_main.dw_1)
rows = ds.RowCount()
rows2 = w_main.dw_1.RowCount()
messagebox("info from f_ret", " row count is " &
   + string(rows) + " or " + string(rows2))
sts = ds.GenerateResultSet(rs)

Return rs
DataStore ds
Int cnt, li_ret

ds = Create DataStore
ds.CreateFrom(rs)
cnt = ds.RowCount()
messagebox("info from f_in", "row count is " + string(cnt))
Return cnt

Usage

See Also