**** Merged from MCS ****
[mono-project.git] / mcs / class / Mono.Data.DB2Client / Mono.Data.Db2Client / DB2ClientPrototypes.cs
blobaef7164725401ffb0a124ba2c80e85d8d2d39cfb
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #region Licence
23 /// DB2DriverCS - A DB2 driver for .Net
24 /// Copyright 2003 By Christopher Bockner
25 /// Released under the terms of the MIT/X11 Licence
26 /// Please refer to the Licence.txt file that should be distributed with this package
27 /// This software requires that DB2 client software be installed correctly on the machine
28 /// (or instance) on which the driver is running.
29 #endregion
31 using System;
32 using System.Data;
33 using System.Runtime.InteropServices;
34 using System.Text;
36 namespace DB2ClientCS
38 /// <summary>
39 /// DB2CLIPrototypes class is a wrapper for the db2cli.lib, IBM's Call Level Interface to DB2
40 /// </summary>
41 internal class DB2ClientPrototypes
43 [DllImport("db2cli.dll", EntryPoint = "SQLAllocHandle")]
44 internal static extern short SQLAllocHandle(short handleType, IntPtr inputHandle, ref IntPtr outputHandle);
45 [DllImport("db2cli.Dll", EntryPoint = "SQLConnect")]
46 internal static extern short SQLConnect(IntPtr sqlHdbc, string serverName, short serverNameLength, string userName, short userNameLength, string authentication, short authenticationLength);
47 [DllImport("db2cli.Dll", CharSet = CharSet.Auto, EntryPoint = "SQLDisconnect")]
48 internal static extern short SQLDisconnect(IntPtr sqlHdbc);
49 [DllImport("db2cli.dll", EntryPoint = "SQLGetDiagRec")]
50 internal static extern short SQLGetDiagRec( short handleType, IntPtr handle, short recNum, [Out] StringBuilder sqlState, ref IntPtr nativeErrorPtr, [Out] StringBuilder errorMessage, short bufferLength, ref IntPtr shortTextLengthPtr);
51 [DllImport("db2cli.Dll", EntryPoint = "SQLSetConnectAttr")]
52 internal static extern short SQLSetConnectAttr(IntPtr sqlHdbc, long sqlAttr, [In] IntPtr sqlValuePtr, long sqlValueLength);
53 [DllImport("db2cli.Dll", EntryPoint = "SQLEndTran")]
54 internal static extern short SQLEndTran (short handleType, IntPtr handle, short fType);
55 [DllImport("db2cli.Dll", EntryPoint = "SQLCancel")]
56 internal static extern short SQLCancel(IntPtr handle);
57 [DllImport("db2cli.dll", EntryPoint = "SQLNumResultCols")]
58 internal static extern short SQLNumResultCols(IntPtr handle, ref int numCols);
59 [DllImport("db2cli.Dll", EntryPoint = "SQLFetch")]
60 internal static extern short SQLFetch(IntPtr handle);
61 [DllImport("db2cli.dll", EntryPoint = "SQLRowCount")]
62 internal static extern short SQLRowCount(IntPtr stmtHandle, ref int numRows);
63 [DllImport("db2cli.dll", EntryPoint = "SQLExecute")]
64 internal static extern short SQLExecute(IntPtr handle);
65 [DllImport ("db2cli.dll", EntryPoint = "SQLExecDirect")]
66 internal static extern short SQLExecDirect(IntPtr stmtHandle, string stmt, int length);
67 [DllImport("db2cli.Dll", EntryPoint = "SQLDescribeCol")]
68 internal static extern short SQLDescribeCol(IntPtr stmtHandle, ushort colNum, [Out] StringBuilder colName, short colNameMaxLength, IntPtr colNameLength, ref IntPtr dataType, ref IntPtr colSizePtr, ref IntPtr scalePtr, ref IntPtr nullablePtr );
69 [DllImport("db2cli.dll", EntryPoint = "SQLBindCol")]
70 internal static extern short SQLBindCol(IntPtr stmtHandle, ushort colNum, int dataType, [Out] byte[] dataBufferPtr, int dataBufferLength, int StrLen_or_IndPtr);
71 [DllImport("db2cli.dll", EntryPoint = "SQLDriverConnect")]
72 internal static extern short SQLDriverConnect(IntPtr hdbc, int centered, [In] string inConnectStr, [In] int inStrLength, [Out] StringBuilder outConnectStr, [Out] int outStrCapacity, [Out] IntPtr outStrLengthReturned, [In] int completion);
73 [DllImport("db2cli.dll", EntryPoint = "SQLPrepare")]
74 internal static extern short SQLPrepare(IntPtr stmtHandle, string stmt, int length);
75 [DllImport("db2cli.dll", EntryPoint = "SQLDescribeParam")]
76 internal static extern short SQLDescribeParam(IntPtr stmtHandle, short paramNumber,ref IntPtr dataType, ref IntPtr paramSize, ref IntPtr decimalDigits, ref IntPtr nullable);
77 [DllImport("db2cli.dll", EntryPoint = "SQLNumParams")]
78 internal static extern short SQLNumParams(IntPtr stmtHandle, ref IntPtr numParams);
79 [DllImport("db2cli.dll")]
80 internal static extern short SQLBindParameter(IntPtr stmtHandle, ushort paramNumber,
81 short dataType, short valueType, short paramType, uint colSize, short decDigits,
82 byte[] dataBufferPtr, int dataBufferLength, int StrLen_or_IndPtr);
83 [DllImport("db2cli.dll", EntryPoint = "SQLBindParameter")]
84 internal static extern short SQLBindParameter(IntPtr stmtHandle, ushort paramNumber,
85 short dataType, short valueType, short paramType, uint colSize, short decDigits,
86 ref int dataBufferPtr, int dataBufferLength, int StrLen_or_IndPtr);
87 [DllImport("db2cli.dll", EntryPoint = "SQLGetLength")]
88 internal static extern short SQLGetLength( IntPtr stmtHandle, short locatorCType, int Locator,
89 IntPtr stringLength, IntPtr indicatorValue);
90 [DllImport("db2cli.dll", EntryPoint = "SQLGetPosition")]
91 internal static extern short SQLGetPosition(IntPtr stmtHandle, short locatorCType, int sourceLocator, int searchLocator,
92 string searchLiteral, int searchLiteralLength, uint fromPosition, IntPtr locatedAt, IntPtr indicatorValue);
93 [DllImport("db2cli.dll", EntryPoint = "SQLGetPosition")]
94 internal static extern short SQLBindFileToCol (IntPtr stmtHandle, ushort colNum, string fileName, IntPtr fileNameLength,
95 IntPtr fileOptions, short maxFileNameLength, IntPtr stringLength, IntPtr indicatorValue);
96 [DllImport("db2cli.dll", EntryPoint = "SQLGetPosition")]
97 internal static extern short SQLBindFileToParam (IntPtr stmtHandle, ushort targetType, short dataType, string fileName,
98 IntPtr fileNameLength, short maxFileNameLength, IntPtr indicatorValue);