![]() |
![]() |
In the example in Figure 11, a management class query prints out the values of all the fields in the backup and archive copy groups for a particular management class.
Figure 11. An Example of Performing a System Query
+--------------------------------------------------------------------------------+
|dsInt16 rc; |
|qryMCData qMCData; |
|DataBlk qData; |
|qryRespMCDetailData qRespMCData, *mcResp; |
|char *mc, *s; |
|dsBool_t done = bFalse; |
|dsUint32_t qry_item; |
| |
|/* Fill in the qMCData structure with the query criteria we want */ |
|qMCData.stVersion = qryMCDataVersion; /* structure version */ |
|qMCData.mcName = mc; /* management class name */ |
|qMCData.mcDetail = bTrue; /* want full details? */ |
| |
|/* Set parameters of the data block used to get or send data */ |
|qData.stVersion = DataBlkVersion; |
|qData.bufferLen = sizeof(qryRespMCDetailData); |
|qData.bufferPtr = (char *)&qRespMCData; |
| |
|qRespMCData.stVersion = qryRespMCDetailDataVersion; |
| |
+--------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------+
|if ((rc = dsmBeginQuery(dsmHandle,qtMC,(dsmQueryBuff *)&qMCData))) |
|{ |
| printf("*** dsmBeginQuery failed: "); |
| rcApiOut(dsmHandle, rc); |
| rc = (RC_SESSION_FAILED); |
|} |
| |
|else |
|{ |
| done = bFalse; |
| qry_item = 0; |
| while (!done) |
| { |
| rc = dsmGetNextQObj(dsmHandle,&qData); |
| if (( (rc == DSM_RC_MORE_DATA) |
| || (rc == DSM_RC_FINISHED)) |
| && qData.numBytes) |
| { |
| qry_item++; |
| mcResp = (qryRespMCDetailData *)qData.bufferPtr; |
| printf("Mgmt. Class %lu:\n",qry_item); |
| printf(" Name: %s\n",mcResp->mcName); |
| printf(" Backup CG Name: %s\n",mcResp->backupDet.cgName); |
| . |
| . /* other fields of backup and archive copy groups */ |
| . |
| printf(" Copy Destination: %s\n",mcResp->archDet.destName); |
| } |
| else |
| { |
| done = bTrue; |
| if (rc != DSM_RC_FINISHED) |
| { |
| printf("*** dsmGetNextQObj failed: "); |
| rcApiOut(dsmHandle, rc); |
| } |
| } |
| if (rc == DSM_RC_FINISHED) done = bTrue; |
| } |
| rc = dsmEndQuery(dsmHandle); |
|} |
+--------------------------------------------------------------------------------+