Using SQL Adapters with Ensemble - InterSystems Documentation
Using SQL Adapters with Ensemble - InterSystems Documentation
Using SQL Adapters with Ensemble - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Creating Adapter Methods for <strong>SQL</strong>Method GetPhone(pRequest As E<strong>SQL</strong>.GetPhoneNumberRequest,Output pResponse As E<strong>SQL</strong>.GetPhoneNumberResponse) As %Status{Set pResponse = ##class(E<strong>SQL</strong>.GetPhoneNumberResponse).%New()//need to pass tResult by reference explicitly in ObjectScript//Use an adapter to run a query in the Employee database.Set tSC = ..Adapter.ExecuteQuery(.tResult,"Select "_pRequest.Type_" from Employee where EmployeeID="_pRequest.ID)//Get the resultdo tResult.Next()set pResponse.PhoneNumber = tResult.GetData(1)}Quit $$$OK5.4 Performing Updates, Inserts, and DeletesTo perform a database update, insert, or delete, use one of the following methods:ExecuteUpdateMethod ExecuteUpdate(Output pNumRowsAffected As %Integer,pUpdateStatement As %String,pParms...) As %StatusExecutes an INSERT, UPDATE, or DELETE statement. You can pass any number ofparameters for use in the statement. Notes:• The number of rows affected is returned as output in the first argument.• The second argument is the INSERT, UPDATE, or DELETE statement to execute. Thisstatement can include the standard <strong>SQL</strong> ? to represent replaceable parameters.ExecuteUpdateParmArrayMethod ExecuteUpdateParmArray(Output pNumRowsAffected As %Integer,pUpdateStatement As %String,ByRef pParms) As %StatusExecutes an INSERT, UPDATE, or DELETE statement. This method is similar to the precedingmethod <strong>with</strong> the exception of how parameters are specified. This method is similar to thepreceding method <strong>with</strong> the exception of how parameters are specified. For this method, youspecify the parameters in a Caché multidimensional array (pParms), as described in “SpecifyingParameters in a Caché Multidimensional Array,” earlier in this chapter.You use the ExecuteUpdateParmArray method if you need to specify parameters and ifthe ODBC driver that you are using does not support the ODBC <strong>SQL</strong>DescribeParam function.40 <strong>Using</strong> <strong>SQL</strong> <strong>Adapters</strong> <strong>with</strong> <strong>Ensemble</strong>