DocBook|Search
Class Reference
%ZEN.Auxiliary.jsonSQLProvider
   
Server:basexml
Instance:SOAXML
User:UnknownUser
 
-
  [BASEXML] >  [%ZEN] >  [Auxiliary] >  [jsonSQLProvider]
Private  Storage  

class %ZEN.Auxiliary.jsonSQLProvider extends %ZEN.Auxiliary.jsonProvider, %ZEN.Component.querySource

A version of the JSON provider that can use an SQL statement to supply data that is served to the client in JSON format. This can be used in the same manner as the jsonProvider component.
For example, placing this within your page definition:

	<jsonSQLProvider id="json" sql="SELECT TOP 1000 ID,Name FROM Sample.Person" />
would cause the given SQL statement to execute when the page is requested and the results of the query to be written to the page in JSON format:
o.content = {
"children":[
{"ID":1,"Name":"Schaefer,Thelma W."}
The JSON content object will contain a children property which is an array of objects that correspond to the rows returned by the SQL statement. The property names match the column names within the query.
If you need more control over the SQL query, you can use the OnGetSQL callback method.
This component ignores all of the data source callback methods inherited from the jsonProvider class.

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
4 8


Summary

Properties
%condition %import %includeFiles %page
%resource OnCreateResultSet OnExecuteResultSet OnGetArray
OnGetSQL OnGetTargetObject OnRenderJSON OnSubmitContent
alertOnError align autoRefresh aux
columnName composite containerStyle countRows
currPage defaultSeries dragEnabled dropEnabled
enclosingClass enclosingStyle error groupByClause
height hidden hint hintClass
hintStyle id index label
labelClass labelDisabledClass labelStyle maxRows
modelError modelId name onafterdrag
onbeforedrag oncreate ondelete ondrag
ondrop onerror onhide onnotifyController
onrefresh onsave onshow onupdate
orderByClause pageSize parameters parent
propertyList queryClass queryName readOnly
recordCount seriesNameProperty showLabel slice
sql tableName targetClass title
tuple valign visible whereClause
width window

Methods
%%OIDGet %AddToSaveSet %Attr %BindExport
%ClassIsLatestVersion %ClassName %ConstructClone %ConvertJSONToObject
%CreateResultSet %DeleteModelInstance %DispatchClassMethod %DispatchGetModified
%DispatchGetProperty %DispatchMethod %DispatchSetModified %DispatchSetMultidimProperty
%DispatchSetProperty %DrawComponentHTML %DrawHTML %DrawJSStrings
%EnclosingDivId %Eval %Extends %ForceClientRender
%GetDataByName %GetEventHandlers %GetModelPropertyList %GetParameter
%GetTypeByName %GetXMLName %IsA %IsModified
%MakeId %New %NormalizeObject %ObjectModified
%OnAddToPageAfter %OnAddToPageBefore %OnCreateResultSet %OnDrawEnclosingDiv
%OnExecuteResultSet %OnZENDeserialize %OriginalNamespace %PackageName
%QuoteValue %QuoteValueL10N %RemoveFromSaveSet %Self
%SerializeObject %SetDataByName %SetModified %SetTargetObject
%ValidateObject %WriteJSONFromArray %WriteJSONFromObject %WriteJSONFromSQL
XMLDTD XMLExport XMLExportToStream XMLExportToString
XMLNew XMLSchema XMLSchemaNamespace XMLSchemaType
createNewObject deleteId dragFinishHandler dragHandler
dragNotifyHandler dragStartHandler dropHandler dropStartHandler
exposeComponent findElement fireOnUpdateEvent getContentObject
getContentType getCurrPage getData getDataAsArrays
getDataAsObject getDataSourceCaption getDimSize getEnclosingDiv
getError getHidden getHintElement getLabel
getLabelElement getModelId getPageSize getProperty
getPropertyName getRecordCount getSettings getType
getTypeByName hasData invokeAction invokeSuper
isModelReadOnly isOfType isPropertyValid makeId
onCreate onDelete onDisplayHandler onEndModalHandler
onPopupAction onRefreshContents onSerialize onStartModalHandler
onloadHandler onunloadHandler onupdateHandler raiseDataChange
refreshContent refreshContents reloadContents render
renderContents renderSVG save sendEventToViews
setContentObject setContentText setContentType setCurrPage
setHidden setModelId setOverlayMode startProgressBar
stopProgressBar submitContent update


Properties

• property OnGetSQL as %ZEN.Datatype.delegator(FORMALSPEC="&pParameters:%String,&pSQL:%String,pCriteria:%ZEN.proxyObject,&pPagingInfo:%String",RETURNTYPE="%Status");
This specifies a callback method that returns an SQL query (string) that will drive this provider. This is identical in behavior to (and replaces) the sql property. The method can make it easier to create queries based parameter value or search criteria passed via the criteria property.
• property currPage as %ZEN.Datatype.integer [ InitialExpression = 1 ];
If the provider is using server-side data paging, this is the number (1-based) of the current page.
• property pageSize as %ZEN.Datatype.integer [ InitialExpression = 25 ];
If the provider is using server-side data paging, this is the number of records in each page.
• property recordCount as %ZEN.Datatype.integer;
If the provider is using server-side data paging, this is the total number of records.

Methods

• classmethod %WriteJSONFromSQL(pVar As %String = "", pSQL As %String) as %String
Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page).
The JSON notation is written out the current device. pVar is the optional name of the client-side javascript variable that refers to the JSON notation.
pSQL is the sql statement that is executed and provides the JSON content.
For example:
#(##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONFromSQL("json","SELECT Name FROM Sample.Person"))#
• method getCurrPage() [ Language = javascript ]
If this provider is using server-side paging, this is the current page number (1-based).
• method getPageSize() [ Language = javascript ]
If this provider is using server-side paging, this is the number of records in one page.
• method getRecordCount() [ Language = javascript ]
If this provider is using server-side paging, this is the total number of records in the current query.
• method setCurrPage(page) [ Language = javascript ]
If this provider is using server-side paging, set the current page number (1-based).