JDB_OpenViewExtended

jolly

VIP Member
This is defined in the include files, and used in some standard code (on an 8.12 site), but I can't find any documentation for it. Even the KG doesn't seem to get a hit.

Does anyone have a full explanation of the parameters? I need it to make use of the lpColSelect array, specifically so I can use the SQL aggregate functions (Select SUM()).

Cheers
JohnO
 
Hmm, I can only see the JDB_OpenView

Have you done a find in files in C++ for the source folder?


Do you need to use that API as I have done somthing similar before but on the DB itself by dropping the BSVW from the DB and amending the view on the DB to be a select SUM.
Each time E1 does a fetch single, it then does the donkey work for you (attached file)

Here's what I have:

JDB_OpenView opens the business view identified by the given business view NID and prepares it for input/output processing. After successfully preparing the business view for input/output, JDB associates the business view with the passed user handle. The user is returned a request handle. This request handle must be used on every subsequent data manipulation call to JDB on this specific business view. The request handle must be used only on the specified business view until a JDB_CloseView is called which will free the request handle. This API must be called prior to any other JDB operations on the business view identified by the given business view NID and must be used in conjunction with JDB_CloseView.

Syntax

JDEDB_RESULT JDB_OpenView(HUSER hUser, NID szBOB, JCHAR * szOverrideDS, HREQUEST * hRequest);


Parameters

Parameter
Notes
Usage

hUser
Valid user handle.
From JDB_InitUser

szBOB
Valid Business View NID to process.


szOverrideDS
Valid null terminated string pointer

This will override the location of table with the corresponding business view NID indicated by the Object Map. This means if the table you wish to work with is in AS/400 database and the Object Map states the default location of the table to be the Oracle database, you may explicitly enter the data source name for the AS/400 database here so that a call to this API will always open the table in AS/400 database. The name passed here should be the data source name, not the database name because the names of the datasource do not necessarily match the names of the databases. Use the Object Configuration Manager to identify the data source that you need.
NULL for the default datasource based on the environment.

hRequest
NULL or request handle.
The output


Return Value

Return Value
Description

JDEDB_PASSED
Return value if this succeeds

JDEDB_FAILED
Return value if this fails


Example

/* Declaration of variables associated with JDB_OpenView */

HREQUEST hRequest = NULL;

HUSER hUser = NULL;

JDEDB_RESULT rcode;

NID szBob = NID_V0101B;

/*Open a business view with NID_V0101B using the Access32 data source */

rcode = JDB_OpenView(hUser, idTable, szBOB ,"ORACLE" ,&hRequest);

if (rcode != JDEDB_PASSED)

{

jdePrintf(_J("JDB_OpenView failed\n"));

} /* END IF */


See Also

JDB_CloseView

JDB_DeleteView

JDB_InsertView

JDB_UpdateView
 
Hi John,

That can be used to specify a list of columns like JDE_OpenTable. You pass an array of DBREF structures to parm 5 and the number of columns to parm 6.

Parm 3 or 4 can be used to override the data source, I'm not sure what the other JCHAR* is for ... they are NULL in all examples I've seen.

So it's:
Parm 1: HUSER
Parm 2: View NID
Parm 3: Override DS? (NULL for OCM)
Parm 4: Override DS? (NULL for OCM)
Parm 5: Array of DBREF columns
Parm 6: number of columns
Parm 7: Address of Request handle

Craig
 
Thanks John and Craig,

John - yes there is a function declaration in the system/include folder but the columns are not named so not helpful. I can find a couple of uses of the function in the source code but without helpful comments.

Craig - that's what I was sort of expecting. I suspect the ColumnList is necessary when using the Aggregate functions they need to match up to the list of aggregates provided - rather than the usual behaviour of defaulting to a SELECT * when there is no ColumnList. Hence JDB_OpenViewExtended is necessary with Aggregates.

I will try this.

Cheers
John
 
Hello John

Here is how I used it. The parameters for 3 and 4, I used NULL. I needed JDB_OpenViewExtended because I needed to use Aggregates. I had to use SUM on 20 fields. SelectCol is an array of DBREF and please see the below for more details on how to load the DS. nNumColFetch is the number of columns you select.

JDB_OpenViewExtended( lpdsEnvironment->hUser, szViewID, NULL , NULL, SelectCol, nNumColFetch, &lpdsEnvironment->hRequest ) ;

Here is how I loaded columns information. This is an array of DBREF.


/* Select RP29 from F0006 */
jdeNIDcpy(lpSelectCol[0].szDict, NID_RP29);
jdeNIDcpy(lpSelectCol[0].szTable, NID_F0006);
lpSelectCol[0].idInstance = 0;

/* Select LT from F0902 */
jdeNIDcpy(lpSelectCol[1].szDict, NID_LT);
jdeNIDcpy(lpSelectCol[1].szTable, NID_F0902);
lpSelectCol[1].idInstance = 0;
 
Back
Top