📄 coci.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ClassLibraryOci
{
public class Coci
{
protected static Int32 count_ref = 0;
protected const UInt32 mode_env = OCI_THREADED | OCI_OBJECT | OCI_UTF16;
[System.Runtime.InteropServices.DllImport(@"ntdll.dll", EntryPoint = "memset", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] // dll在磁盘中的存放位置
public static extern IntPtr memset(ref byte b, Int32 value, UInt32 count);
[System.Runtime.InteropServices.DllImport(@"ntdll.dll", EntryPoint = "memset", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] // dll在磁盘中的存放位置
public static extern IntPtr memset(ref char c, Int32 value, UInt32 count);
[DllImport(@"oci.dll", EntryPoint = "OCIEnvCreate", CharSet = CharSet.Unicode)]
public static extern int OCIEnvCreate(out IntPtr envp, UInt32 mode, IntPtr ctxp, IntPtr malocfp, IntPtr ralocfp, IntPtr mfreefp, UInt32 xtramem_sz, IntPtr usrmempp);
[DllImport(@"oci.dll", EntryPoint = "OCIServerDetach", CharSet = CharSet.Unicode)]
public static extern int OCIServerDetach(IntPtr srvhp, IntPtr errhp, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIHandleAlloc", CharSet = CharSet.Unicode)]
public static extern int OCIHandleAlloc(IntPtr parenth, out IntPtr hndlpp, UInt32 type, UInt32 xtramem_sz, IntPtr usrmempp);
[DllImport(@"oci.dll", EntryPoint = "OCIHandleFree", CharSet = CharSet.Unicode)]
public static extern int OCIHandleFree(IntPtr hndlp, UInt32 type);
[DllImport(@"oci.dll", EntryPoint = "OCIServerAttach", CharSet = CharSet.Unicode)]
public static extern int OCIServerAttach(IntPtr srvhp, IntPtr errhp, String dblink, Int32 dblink_len, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIAttrSet", CharSet = CharSet.Unicode)]
public static extern int OCIAttrSet(IntPtr trgthndlp, UInt32 trghndltyp, IntPtr attributep, UInt32 size, UInt32 attrtype, IntPtr errhp);
[DllImport(@"oci.dll", EntryPoint = "OCIAttrSet", CharSet = CharSet.Unicode)]
public static extern int OCIAttrSet(IntPtr trgthndlp, UInt32 trghndltyp, String attributep, UInt32 size, UInt32 attrtype, IntPtr errhp);
[DllImport(@"oci.dll", EntryPoint = "OCIAttrGet", CharSet = CharSet.Unicode)]
public static extern int OCIAttrGet(IntPtr trgthndlp, UInt32 trghndltyp, out String attributep, out UInt32 sizep, UInt32 attrtype, IntPtr errhp);
[DllImport(@"oci.dll", EntryPoint = "OCIAttrGet", CharSet = CharSet.Unicode)]
public static extern int OCIAttrGet(IntPtr trgthndlp, UInt32 trghndltyp, out String attributep, IntPtr sizep, UInt32 attrtype, IntPtr errhp);
[DllImport(@"oci.dll", EntryPoint = "OCIAttrGet", CharSet = CharSet.Unicode)]
public static extern int OCIAttrGet(IntPtr trgthndlp, UInt32 trghndltyp, out UInt32 attributep, out UInt32 sizep, UInt32 attrtype, IntPtr errhp);
[DllImport(@"oci.dll", EntryPoint = "OCIAttrGet", CharSet = CharSet.Unicode)]
public static extern int OCIAttrGet(IntPtr trgthndlp, UInt32 trghndltyp, out UInt32 attributep, IntPtr sizep, UInt32 attrtype, IntPtr errhp);
[DllImport(@"oci.dll", EntryPoint = "OCIStmtPrepare", CharSet = CharSet.Unicode)]
public static extern int OCIStmtPrepare(IntPtr stmtp, IntPtr errhp, String stmt, Int32 stmt_len, UInt32 language, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCISessionBegin", CharSet = CharSet.Unicode)]
public static extern int OCISessionBegin(IntPtr srvhp, IntPtr errhp, IntPtr usrhp, UInt32 credt, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCISessionEnd", CharSet = CharSet.Unicode)]
public static extern int OCISessionEnd(IntPtr srvhp, IntPtr errhp, IntPtr usrhp, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIStmtExecute", CharSet = CharSet.Unicode)]
public static extern int OCIStmtExecute(IntPtr svchp, IntPtr stmtp, IntPtr errhp, UInt32 iters, UInt32 rowoff, IntPtr snap_in, IntPtr snap_out, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIDefineByPos", CharSet = CharSet.Unicode)]
public static extern int OCIDefineByPos(IntPtr stmtp, out IntPtr defnp, IntPtr errhp, UInt32 position, ref IntPtr value, Int32 value_sz, UInt16 dty, IntPtr indp, IntPtr rlenp, IntPtr rcodep, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIDefineByPos", CharSet = CharSet.Unicode)]
public static extern int OCIDefineByPos(IntPtr stmtp, out IntPtr defnp, IntPtr errhp, UInt32 position, ref Int32 valuep, Int32 value_sz, UInt16 dty, ref char indp, ref char rlenp, IntPtr rcodep, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIDefineByPos", CharSet = CharSet.Unicode)]
public static extern int OCIDefineByPos(IntPtr stmtp, out IntPtr defnp, IntPtr errhp, UInt32 position, ref byte valuep, Int32 value_sz, UInt16 dty, ref char indp, IntPtr rlenp, IntPtr rcodep, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIDefineByPos", CharSet = CharSet.Unicode)]
public static extern int OCIDefineByPos(IntPtr stmtp, out IntPtr defnp, IntPtr errhp, UInt32 position, ref byte valuep, Int32 value_sz, UInt16 dty, IntPtr indp, IntPtr rlenp, IntPtr rcodep, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIDefineArrayOfStruct", CharSet = CharSet.Unicode)]
public static extern int OCIDefineArrayOfStruct(IntPtr defnp, IntPtr errhp, UInt32 pvskip, UInt32 indskip, UInt32 rlskip, UInt32 rcskip);
[DllImport(@"oci.dll", EntryPoint = "OCIStmtFetch", CharSet = CharSet.Unicode)]
public static extern int OCIStmtFetch(IntPtr stmtp, IntPtr errhp, UInt32 nrows, UInt16 orientation, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIParamGet", CharSet = CharSet.Unicode)]
public static extern int OCIParamGet(IntPtr hndlp, UInt32 htype, IntPtr errhp, out IntPtr parmdpp, UInt32 pos);
[DllImport(@"oci.dll", EntryPoint = "OCIParamSet", CharSet = CharSet.Unicode)]
public static extern int OCIParamSet(IntPtr hdlp, UInt32 htyp, IntPtr errhp, IntPtr dscp, UInt32 dtyp, UInt32 pos);
[DllImport(@"oci.dll", EntryPoint = "OCIDescriptorAlloc", CharSet = CharSet.Unicode)]
public static extern int OCIDescriptorAlloc(IntPtr parenth, out IntPtr descpp, UInt32 type, UInt32 xtramem_sz, IntPtr usrmempp);
[DllImport(@"oci.dll", EntryPoint = "OCIDescriptorFree", CharSet = CharSet.Unicode)]
public static extern int OCIDescriptorFree(IntPtr descp, UInt32 type);
[DllImport(@"oci.dll", EntryPoint = "OCIBindByPos", CharSet = CharSet.Unicode)]
public static extern int OCIBindByPos(IntPtr stmtp, ref IntPtr bindp, IntPtr errhp, UInt32 position, ref byte valuep, Int32 value_sz, UInt16 dty, IntPtr indp, ref char alenp, ref char rcodep, UInt32 maxarr_len, ref UInt32 curelep, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIBindByName", CharSet = CharSet.Unicode)]
public static extern int OCIBindByName(IntPtr stmtp, ref IntPtr bindp, IntPtr errhp, ref byte placeholder, Int32 placeh_len, ref byte valuep, Int32 value_sz, UInt16 dty, IntPtr indp, ref char alenp, ref char rcodep, UInt32 maxarr_len, ref UInt32 curelep, UInt32 mode);
[DllImport(@"oci.dll", EntryPoint = "OCIBindArrayOfStruct", CharSet = CharSet.Unicode)]
public static extern int OCIBindArrayOfStruct(IntPtr bindp, IntPtr errhp, UInt32 pvskip, UInt32 indskip, UInt32 alskip, UInt32 rcskip);
[DllImport(@"oci.dll", EntryPoint = "OCITransCommit", CharSet = CharSet.Unicode)]
public static extern int OCITransCommit(IntPtr svchp, IntPtr errhp, UInt32 flags);
[DllImport(@"oci.dll", EntryPoint = "OCITransRollback", CharSet = CharSet.Unicode)]
public static extern int OCITransRollback(IntPtr svchp, IntPtr errhp, UInt32 flags);
[DllImport(@"oci.dll", EntryPoint = "OCIErrorGet", CharSet = CharSet.Unicode)]
public static extern int OCIErrorGet(IntPtr hndlp, UInt32 recordno, IntPtr sqlstate, out Int32 errcodep, char[] bufp, UInt32 bufsiz, UInt32 type);
[DllImport(@"oci.dll", EntryPoint = "OCILobOpen", CharSet = CharSet.Unicode)]
public static extern int OCILobOpen(IntPtr svchp, IntPtr errhp, IntPtr locp, byte mode);
[DllImport(@"oci.dll", EntryPoint = "OCILobGetLength", CharSet = CharSet.Unicode)]
public static extern int OCILobGetLength(IntPtr svchp, IntPtr errhp, IntPtr locp, out UInt32 lenp);
[DllImport(@"oci.dll", EntryPoint = "OCILobClose", CharSet = CharSet.Unicode)]
public static extern int OCILobClose(IntPtr svchp, IntPtr errhp, IntPtr locp);
[DllImport(@"oci.dll", EntryPoint = "OCILobRead", CharSet = CharSet.Unicode)]
public static extern int OCILobRead(IntPtr svchp, IntPtr errhp, IntPtr locp, ref UInt32 amtp, UInt32 offset, ref byte bufp, UInt32 buflen, IntPtr ctxp, IntPtr cbfp, UInt16 csid, byte csfrm);
[DllImport(@"oci.dll", EntryPoint = "OCILobWrite", CharSet = CharSet.Unicode)]
public static extern int OCILobWrite(IntPtr svchp, IntPtr errhp, IntPtr locp, ref UInt32 amtp, UInt32 offset, ref byte bufp, UInt32 buflen, byte piece, IntPtr ctxp, IntPtr cbfp, UInt16 csid, byte csfrm);
[DllImport(@"oci.dll", EntryPoint = "OCILobWriteAppend", CharSet = CharSet.Unicode)]
public static extern int OCILobWriteAppend(IntPtr svchp, IntPtr errhp, IntPtr lobp, ref UInt32 amtp, ref byte bufp, UInt32 bufl, byte piece, IntPtr ctxp, IntPtr cbfp, UInt16 csid, byte csfrm);
public const UInt32 OCI_DTYPE_LOB = 50; /* lob locator */
public const Int32 OCI_SUCCESS = 0; /* maps to SQL_SUCCESS of SAG CLI */
public const Int32 OCI_SUCCESS_WITH_INFO = 1; /* maps to SQL_SUCCESS_WITH_INFO */
public const Int32 OCI_NO_DATA = 100; /* maps to SQL_NO_DATA */
public const Int32 OCI_ERROR = -1; /* maps to SQL_ERROR */
public const Int32 OCI_INVALID_HANDLE = -2; /* maps to SQL_INVALID_HANDLE */
/*----------------------------- Various Modes ------------------------------*/
public const UInt32 OCI_DEFAULT = 0x00000000;
/* the default value for parameters and attributes */
/*-------------OCIInitialize Modes / OCICreateEnvironment Modes -------------*/
public const UInt32 OCI_THREADED = 0x00000001; /* appl. in threaded environment */
public const UInt32 OCI_OBJECT = 0x00000002; /* application in object environment */
public const UInt32 OCI_UTF16 = 0x00004000; /* mode for all UTF16 metadata */
//public const UInt32 OCI_ATTR_SERVER = 6; /* the server handle */
//public const UInt32 OCI_HTYPE_SESSION = 9; /* authentication handle */
public const UInt32 OCI_ATTR_USERNAME = 22; /* username attribute */
public const UInt32 OCI_ATTR_PASSWORD = 23; /* password attribute */
public const UInt32 OCI_ATTR_STMT_TYPE = 24; /* statement type */
public const UInt32 OCI_CRED_RDBMS = 1; /* database username/password */
public const UInt32 OCI_HTYPE_ENV = 1; /* environment handle */
public const UInt32 OCI_HTYPE_ERROR = 2; /* error handle */
public const UInt32 OCI_HTYPE_SVCCTX = 3; /* service handle */
public const UInt32 OCI_HTYPE_STMT = 4; /* statement handle */
public const UInt32 OCI_HTYPE_BIND = 5; /* bind handle */
public const UInt32 OCI_HTYPE_DEFINE = 6; /* define handle */
public const UInt32 OCI_HTYPE_DESCRIBE = 7; /* describe handle */
public const UInt32 OCI_HTYPE_SERVER = 8; /* server handle */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -