13.07.2015 Views

Using SQL Adapters with Ensemble - InterSystems Documentation

Using SQL Adapters with Ensemble - InterSystems Documentation

Using SQL Adapters with Ensemble - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating Adapter Methods for <strong>SQL</strong>To perform such tasks, your custom methods will use the methods of the <strong>SQL</strong> inbound and outboundadapters, both of which inherit a core set of methods from the EnsLib.Common class. These methodscan execute queries, run stored procedures, insert records, and so on.5.2 <strong>Using</strong> ParametersIf you use parameters when you run queries, perform updates, or execute procedures, you should obtaininformation on the ODBC driver you are using. You should look for information on the following:• Whether this driver supports the ODBC <strong>SQL</strong>DescribeParam function.- If so, you can use the <strong>SQL</strong> adapter methods ExecuteQuery, ExecuteUpdate, andExecuteProcedure. Each of these methods accepts any number of parameter names, calls<strong>SQL</strong>DescribeParam, and uses the resulting information to automatically bind those parametersappropriately.- If not, you must use the alternative methods ExecuteQueryParmArray,ExecuteUpdateParmArray, and ExecuteProcedureParmArray. In this case, you mustcreate and pass a multidimensional array that contains the parameters and all their attributes.• Whether the driver supports input, output, and input/output type parameters. When you includeparameters in an <strong>SQL</strong> statement, you specify these types, not all of which are supported by alldrivers.5.2.1 Parameter AttributesTo use parameters in your <strong>SQL</strong> statements, if the ODBC driver does not support the<strong>SQL</strong>DescribeParam function, you will have to create a Caché multidimensional array that containsthe parameters and all their appropriate attributes. This information is passed to the ODBC driver, sostart by finding out how the driver represents the following parameter attributes:• <strong>SQL</strong> data types — These are generally represented by integers (C types), and the driver includefile contains a table that defines them.A typical subset is as follows:- 1 represents <strong>SQL</strong>_CHAR- 4 represents <strong>SQL</strong>_INTEGER- 6 represents <strong>SQL</strong>_FLOAT- 8 represents <strong>SQL</strong>_DOUBLE- 12 represents <strong>SQL</strong>_VARCHAR36 <strong>Using</strong> <strong>SQL</strong> <strong>Adapters</strong> <strong>with</strong> <strong>Ensemble</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!