?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/ProgrammerManual.zip
???????
PK �e(\h�� � index.htmlnu ȯ�� <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Author" content="Peter Harvey"> <meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD Caldera Systems OpenLinux [en] (X11; U; Linux 2.4.2 i686) [Netscape]"> </head> <body text="#000000" bgcolor="#FFFFFF" link="#0000EF" vlink="#51188E" alink="#FF0000"> <img SRC="unixODBC.gif" height=32 width=32><font face="Arial,Helvetica"><font size=+4>unixODBC</font></font> <br> <hr WIDTH="100%"> <center><b><font face="Arial,Helvetica"><font size=+3>PROGRAMMER MANUAL</font></font></b> <br><b><font face="Arial,Helvetica">Peter Harvey</font></b> <br><b><font face="Arial,Helvetica">19.DEC.01</font></b></center> <p><b><font face="Arial,Helvetica">Introduction</font></b><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">Welcome to the unixODBC Programmer Manual. This manual is a starting point for a programmer who is interested in developing an application which *uses* ODBC. This manual does not address Driver development or any other development which is internal to the ODBC sub-system.</font><font face="Arial,Helvetica"></font> <p><b><font face="Arial,Helvetica">Why Use ODBC?</font></b><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">ODBC provides a portable Application Programmers Interface (API) with which to access data. This means that your data access code will recompile without changes on all popular platforms. In practice; portability is sometimes hampered by incomplete drivers. However; the core ODBC functionality (the most used functionality) is always supported any working driver. Other advantages to developing with ODBC include;</font> <ul> <li> <font face="Arial,Helvetica">most popular API of its kind</font></li> <li> <font face="Arial,Helvetica">most mature API of its kind</font></li> <li> <font face="Arial,Helvetica">skills more reusable/easily found</font></li> <li> <font face="Arial,Helvetica">hundreds, if not thousands, of applications use it</font></li> <li> <font face="Arial,Helvetica">availible on all majour platforms</font></li> <li> <font face="Arial,Helvetica">easy to change data storage solution/vendor (ah; freedom)</font></li> <li> <font face="Arial,Helvetica">easy to upscale data storage (developer and end-user)</font></li> <li> <font face="Arial,Helvetica">arguably the most complete API of its kind</font></li> <li> <font face="Arial,Helvetica">many books on the subject</font></li> <li> <font face="Arial,Helvetica">greater support base</font></li> </ul> <b><font face="Arial,Helvetica">Languages Supported</font></b><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">ODBC is based upon a C API. C++ programmers will find a number of C++ class libraries for using the ODBC API. These are wrappers - using the C API internally but can provide a much nicer way to use ODBC for C++ programmers.</font><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">Any language which can call a C API should be able to use the ODBC API and most languages, such as PHP and Perl, provide an interface to work with ODBC but these are not covered in this manual.</font><font face="Arial,Helvetica"></font> <p><b><font face="Arial,Helvetica">Architecture</font></b><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">Client Libraries</font><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">These are client libraries which are specific to the particular database being used. These, often, provide a C API of their own which is used by Driver developers. In some cases these exist inside of the Driver itself or are staticly linked into the Driver. Any Client Libraries required by a Driver will be a part of the installation of your Driver or will simply be a requirement for the installation of your Driver. Sometimes Client Libraries must be configured before any ODBC configuration.</font><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">Driver</font><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">Driver Manager</font><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">The Driver Manager acts as a gateway to the ODBC drivers. The main advantage to having a Driver Manager is that the end-user can configure the Driver Manager to use a different Driver than the one original conceived of by the programmer.</font><font face="Arial,Helvetica"></font> <p><font face="Arial,Helvetica">It as virtualy identical functions declarations as a Driver which means that one *could* create an application</font> <br><font face="Arial,Helvetica"></font> <p> <hr WIDTH="100%"> <br> <br> </body> </html> PK �e(\J�� Tutorial/index.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Dokumenttitel </TITLE> </HEAD> <frameset Cols="25%,75%" noresize frameborder="0" > <frame Name="navi" src="navi.html"> <frame Name="inha" src="intro.html"> </FRAMESET> </HTML> PK �e(\l÷�� � Tutorial/odbc.cssnu ȯ�� /* Style Sheet for odbc documentation =20 M.Rathmann */ BODY {background-color: white; color: black; font-family: Arial; font-style: normal; font-size: medium; background-attachment: fixed; } /*=20 2. Die Verweise: Standard: Text unterstrichen link: #008080=20 vlink=3D"#800000" alink=3D"#008080" */ a:link {color: #2222ff; text-decoration: none; } a:visited {color: #3333ee; text-decoration: none; } a:active {color: #4444dd; text-decoration: none; } TH {border-style: none; background-color: #dddddd; font-family: Arial; font-size: normal; color: white; vertical-align: top; text-align: center; } TD {border-style: none; background-color: white; font-family: Arial; font-size: normal; color: black; border-width: 3px; border-color: white; vertical-align: top; text-align: justify; } TD.center {border-style: none; background-color: #ddddff; text-align: center; font-family: Arial; font-size: medium; color: black; border-width: 3px; border-color: white; vertical-align: top; } TD.head {border-style: none; background-color: #ddddff; text-align: left; font-family: Arial; font-size: medium; color: black; font-weight: bold; vertical-align: top; } Th.head {border-style: none; background-color: #dddddd;=09 text-align: center; font-family: Arial; font-size: medium; color: black; font-weight: bold; vertical-align: top; } TD.big { font-family: Arial; font-size: x-large; } TD.small { font-family: Arial; font-size: x-small; } /* 5. =DCberschriften immer in Rot, Zeichensatz Arial */ H4 { color: black; font-family: Arial; font-size: small; font-weight: bold; } H5 { color: black; font-size: x-small; font-family: courier; } /* 6. Blockquote St=E4rkere Einr=FCckung=20 */ Blockquote {margin-left: 10pt; } CODE.list {margin-left: 10 pt; font-size: xx-small; } } /* 7. Listen */ UL {color: black; font-family: Arial } OL {color: black; list-style-type: decimal} LI {color: black} P {font-family: Arial; font-size: normal; } TD P {font-family: Arial; font-size: normal; } small {font-family: Arial; font-size: x-small } From - Sun Jun 6 14:11:04 1999 Return-path: <M.Rathmann@ping.de> Envelope-to: pharvey@interlog.com Delivery-date: Sun, 6 Jun 1999 03:55:51 -0400 Received: from plus.interlog.com ([207.34.202.21] ident=root) by mailhub4.interlog.com with esmtp (Exim 2.05 #1) id 10qXmY-0002kw-00 for pharvey@interlog.com; Sun, 6 Jun 1999 03:55:50 -0400 Received: from lilly.ping.de (qmailr@lilly.ping.de [195.37.120.2]) by plus.interlog.com (8.9.3/8.9.3) with SMTP id DAA23367 for <pharvey@codebydesign.com>; Sun, 6 Jun 1999 03:55:48 -0400 (EDT) Received: (qmail 26070 invoked by alias); 6 Jun 1999 07:55:45 -0000 Received: (qmail 26063 invoked from network); 6 Jun 1999 07:55:37 -0000 Received: from suprimo-54.ping.de (HELO koala) (195.37.122.54) by lilly.ping.de with SMTP; 6 Jun 1999 07:55:37 -0000 Message-ID: <001a01beaff2$66b90320$030aa8c0@koala> From: "Markus Rathmann" <M.Rathmann@ping.de> To: "Peter Harvey" <pharvey@codebydesign.com> Subject: The newest docu, to be sure :) Date: Sun, 6 Jun 1999 09:58:43 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0017_01BEB003.29819060" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Mozilla-Status: 8001 X-Mozilla-Status2: 00000000 X-UIDL: ea3859ca9b1d73dac919ee5e69391b0b This is a multi-part message in MIME format. ------=_NextPart_000_0017_01BEB003.29819060 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi Peter, I'm sorry, but I think that you haven't got the newest version. Therefore I'm sending it to you again. It has one more page (Obtaining Datasource names) and a few display glitches (mainly Netscape) solved. Furthermore I've added a link to the unixODBC Homepage, so that you may use the complete browser window (if you like). Bye Markus ------=_NextPart_000_0017_01BEB003.29819060 Content-Type: text/css; name="ODBC.CSS" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ODBC.CSS" /* Style Sheet for odbc documentation =20 M.Rathmann */ BODY {background-color: white; color: black; font-family: Arial; font-style: normal; font-size: medium; background-attachment: fixed; } /*=20 2. Die Verweise: Standard: Text unterstrichen link: #008080=20 vlink=3D"#800000" alink=3D"#008080" */ a:link {color: #2222ff; text-decoration: none; } a:visited {color: #3333ee; text-decoration: none; } a:active {color: #4444dd; text-decoration: none; } TH {border-style: none; background-color: #dddddd; font-family: Arial; font-size: normal; color: white; vertical-align: top; text-align: center; } TD {border-style: none; background-color: white; font-family: Arial; font-size: normal; color: black; border-width: 3px; border-color: white; vertical-align: top; text-align: justify; } TD.center {border-style: none; background-color: #ddddff; text-align: center; font-family: Arial; font-size: medium; color: black; border-width: 3px; border-color: white; vertical-align: top; } TD.head {border-style: none; background-color: #ddddff; text-align: left; font-family: Arial; font-size: medium; color: black; font-weight: bold; vertical-align: top; } Th.head {border-style: none; background-color: #dddddd;=09 text-align: center; font-family: Arial; font-size: medium; color: black; font-weight: bold; vertical-align: top; } TD.big { font-family: Arial; font-size: x-large; } TD.small { font-family: Arial; font-size: x-small; } /* 5. =DCberschriften immer in Rot, Zeichensatz Arial */ H4 { color: black; font-family: Arial; font-size: small; font-weight: bold; } H5 { color: black; font-size: x-small; font-family: courier; } /* 6. Blockquote St=E4rkere Einr=FCckung=20 */ Blockquote {margin-left: 10pt; } CODE.list {margin-left: 10 pt; font-size: xx-small; } } /* 7. Listen */ UL {color: black; font-family: Arial } OL {color: black; list-style-type: decimal} LI {color: black} P {font-family: Arial; font-size: normal; } TD P {font-family: Arial; font-size: normal; } small {font-family: Arial; font-size: x-small } PK �e(\��Q� Tutorial/query.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>executing a query</TITLE> <link rel="stylesheet" Href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0"> <TR> <TD colspan="3" class="big">Executing a query</TD> </TR> <TR> <TD colspan="3"><P>If you want to execute a query you will need to specify a handle (<CODE>SQL_HANDLE_STMT</CODE>) for a SQL-statement. In order to get one you have to allocate one with <CODE><A HREF="gloss.html#alloc">SQLAllocHandle</A></CODE>. </P> Then you have to think about the SQL statement you want to execute. As I mentioned in the introduction I assume that we have a table <CODE><A HREF="intro.html#tab">tkeyuser</A></CODE> which contains the following data:</P> <TABLE COLS=3 cellspacing="1" border="0" bgcolor="#eeeeee" cellpadding=2 width="50%"> <TR> <TH class="head">iduser</TH> <TH class="head">dtname</TH> <TH class="head">dtmaxSize</TH> </TR> <TR> <TD>1</TD> <TD>Christa</TD> <TD>10000</TD> </TR> <TR> <TD>2</TD> <TD>Nicole</TD> <TD>9000</TD> </TR> </TABLE> <P> In this example, we want to execute a query which returns all the rows for the fields <CODE>iduser</CODE> and <CODE>dtname</CODE> in this table ordered by <code>iduser</CODE>. So the SQL statement would be:</P> <CODE> SELECT iduser,dtname FROM tkeydata ORDER BY iduser </CODE> <P> If you execute this statement you would get two rows each with two <A HREF="gloss.html#col">columns</A> of data. This data has to be stored somewhere so that your programm can actually use it, so you need to define a variable for each of the columns. So you need to bind a column to variable in your program. Binding a variable automatically stores the data of the column in the variable when you retrieve a result <A HREF="gloss.html#row">row</A> from the connection. It is important that your variables match the <A HREF="gloss.html#dtyp">type</A> of the column in the table within the database.</P> <P> So we need to bin column #1 to a variable of type <CODE>SQLINTEGER</CODE> and the second column to a variable of type <CODE>char</CODE>. This is done by <CODE><A HREF="gloss.html#bind">SQLBindCol</A></CODE>. Therefore we add the variables:</P> <CODE class="list"> SQLHSTMT V_OD_hstmt; <FONT COLOR="blue">// Handle for a statement</FONT><BR> SQLINTEGER V_OD_err,V_OD_id;<BR> char V_OD_buffer[200]; </CODE> <P> Now we can bind the variables:</P> <CODE class="list"><PRE> SQLBindCol(V_OD_hstmt,1,SQL_C_CHAR, &V_OD_buffer,200,&V_OD_err); SQLBindCol(V_OD_hstmt,2,SQL_C_ULONG,&V_OD_id,sizeof(V_OD_id),&V_OD_err); </PRE> </CODE> <P> Yes you should check for the return code of the function call. I'm to lazy to code it here once again :( </P> Now we can execute the query by calling <A HREF="gloss.html#exec"><CODE>SQLExecDirect</CODE></A>: </P> <CODE class="list"><PRE> V_OD_erg=SQLExecDirect(V_OD_hstmt, "SELECT dtname,iduser FROM tkeyuser order by iduser",SQL_NTS); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error Select %d\n",V_OD_erg); SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, V_OD_stat, &V_OD_err, V_OD_msg,100,&V_OD_mlen); printf("%s (%d)\n",V_OD_msg,V_OD_err); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_STMT,V_OD_hstmt); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } </PRE> </CODE> </TD> </TR> </TABLE> </BODY> </HTML> PK �e(\���� � Tutorial/conne.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Connecting </TITLE> <LINK REL="StyleSheet" Href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0"> <TR> <TD colspan="3" class="big">Connecting to a Datasource</TD> </TR> <TR> <TD colspan="3"><P>First thing you will need is a variable of type <CODE>SQLHENV</CODE>. This is a handle (pointer) to an internal ODBC structure which holds all informationen about the ODBC environment. Without a handle of that kind you won't be able do to very much. To get this handle you call <CODE><A HREF="gloss.html#alloc">SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &V_OD_Env)</A></CODE>. <CODE>V_OD_Erg</CODE> is a variable of type <CODE>SQLHENV</CODE> which holds the allocated environment handle.</P> <P> If you have allocated the handle you need to define which version of ODBC to use. Therefore you should call <CODE><A HREF="gloss.html#envattr">SQLSetEnvAttr(V_OD_Env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0)</A></CODE>. The constant <CODE>SQL_ATTR_ODBC_VERSION</CODE> defines that the needed version of ODBC will be defined and <CODE>SQL_OV_ODBC3</CODE> says that the program will need ODBC 3.0. </P> <P>Next thing to do is to create a handle for the database connection which is of the type <CODE>SQLHDBC</CODE>. Once again you call <CODE>SQLAllocHandle</CODE> this time with <CODE>SQL_HANDLE_DBC</CODE> and the variable to the environment returned by the first call to <CODE>SQLAllocHandle</CODE>. </P><P> Then you may choose to modify the connection attributes, mainly the timeout for any given action on the connection. You do this by calling <CODE><A HREF="gloss.html#conattr">SQLSetConnectAttr</A></CODE> with the connection handle, attribute and value pointer and the string length (if available).</P> <P> Finally we are able to connect to the database via <CODE><A href="gloss.html#conn">SQLConnect</A></CODE>, which needs the name of the data source, the username and password as parameters. For each parameter you need to specify how long the string is or just gib <COde>SQL_NTS</CODE> which says that it is a string which length has to be determined by <CODE>SQLConnect</CODE> </P> That's it, we are connected to the database. Please note, that all functions mentioned on this page return either <CODE>SQL_SUCCESS</CODE>, <CODE>SQL_SUCCESS_WITH_INFO</CODE> if all went smoothly or <CODE>SQL_ERROR</CODE> or <CODE>SQL_INVALID_HANDLE</CODE> in case of an error. We will have a look on how to get diagnostic messages a little later. <P> So let's have a look at the code: </TD> </TR> </TABLE> <TABLE> <TR> <TD> <PRE><CODE class="list"> <A NAME="list"></A> /* odbc.c testing unixODBC */ #include <stdlib.h> #include <stdio.h> #include <odbc/sql.h> #include <odbc/sqlext.h> #include <odbc/sqltypes.h> SQLHENV V_OD_Env; <FONT COLOR="green">// Handle ODBC environment</FONT> long V_OD_erg; <FONT COLOR="green">// result of functions</FONT> SQLHDBC V_OD_hdbc; <FONT COLOR="green">// Handle connection</FONT> char V_OD_stat[10]; <FONT COLOR="green">// Status SQL</FONT> SQLINTEGER V_OD_err,V_OD_rowanz,V_OD_id; SQLSMALLINT V_OD_mlen; char V_OD_msg[200],V_OD_buffer[200]; int main(int argc,char *argv[]) { <FONT COLOR="green">// 1. allocate Environment handle and register version </FONT> V_OD_erg=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&V_OD_Env); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error AllocHandle\n"); exit(0); } V_OD_erg=SQLSetEnvAttr(V_OD_Env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error SetEnv\n"); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } <FONT COLOR="green">// 2. allocate connection handle, set timeout</FONT> V_OD_erg = SQLAllocHandle(SQL_HANDLE_DBC, V_OD_Env, &V_OD_hdbc); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error AllocHDB %d\n",V_OD_erg); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } SQLSetConnectAttr(V_OD_hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0); <FONT COLOR="green">// 3. Connect to the datasource "web" </FONT> V_OD_erg = SQLConnect(V_OD_hdbc, (SQLCHAR*) "web", SQL_NTS, (SQLCHAR*) "christa", SQL_NTS, (SQLCHAR*) "", SQL_NTS); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error SQLConnect %d\n",V_OD_erg); SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, V_OD_stat, &V_OD_err,V_OD_msg,100,&V_OD_mlen); printf("%s (%d)\n",V_OD_msg,V_OD_err); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } printf("Connected !\n"); <FONT COLOR="green">/* continued on next page */</FONT> </CODE> </PRE> </TD> </TR> </TABLE> </BODY> </HTML> PK �e(\�W��\ \ Tutorial/dsn.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Obtainign Datasources</TITLE> <LINK REL="Stylesheet" href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0"> <TR> <TD colspan="3" class="big">Obtaining a Datasourcename</TD> </TR> <TR> <TD colspan="3"><P>A simple query should be a nobrainer right now. But what if your programm runs on a system where you can't be sure which datasource names are configured?</P> <P>Then you should use <A hrEF="gloss.html#dsn"><CODE>SQLDataSources()</CODE></a>. After allocating a environment handle you may use this to find out about the DSN and the supplied description for the datasource.</P> <P>As ODBC knows systemwide and userwide datasources, you need to give a direction which datasource types you are looking for. There you may specify either of the following values:</P> <TABLE COLS="2" border="0" width="90%"> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of all available datasources (either user or systemwide). </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST_USER</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of the available user datasources. </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST_SYSTEM</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of the available system datasources. </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_NEXT</CODE></TD> <TD>Fetches the next datasource. Depending on <CODE>SQL_FETCH_FIRST_USER</CODE>, <CODE>SQL_FETCH_FIRST_SYSTEM</CODE> or <CODE>SQL_FETCH_FIRST</CODE> this may only be a user datasource, only a system datasource or one of either. </TR> </TABLE> <P>So let's have a look on a small function, which will return all available datasource names. You may insert this code into the program which you built before and call it somewhere after you've obtained an environment handle.</P> <CODE class="list"><PRE> void OD_ListDSN(void) { char l_dsn[100],l_desc[100]; short int l_len1,l_len2,l_next; l_next=SQL_FETCH_FIRST; while( SQLDataSources(V_OD_Env,l_next,l_dsn, sizeof(l_dsn), &l_len1, l_desc, sizeof(l_desc), &l_len2) == SQL_SUCCESS) { printf("Server=(%s) Beschreibung=(%s)\n",l_dsn,l_desc); l_next=SQL_FETCH_NEXT; } } </PRE></CODE> </TD> </TR> </TABLE> </BODY> </HTML> PK �e(\�r#8� � Tutorial/navi.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Navigation </TITLE> <LINK REL="stylesheet" href="odbc.css"> </HEAD> <BODY bgcolor="white"> <TABLE Width="90%" cellspacing="1" bgcolor="black"> <TR> <TD class="center">ODBC Programming Tutorial</TD> </TR> </TABLE> <TABLE Width="90%"> <TR> <TD> </TD> </TR> <TR> <TD><a href="intro.html" target="inha">Introduction</A> </TD> </TR> <TR> <TD><a href="conne.html" target="inha">Connection</A> </TD> </TR> <TR> <TD><a href="close.html" target="inha">Closing</A> </TD> </TR> <TR> <TD><a href="query.html" target="inha">Queries</A> </TD> </TR> <TR> <TD><A href="resul.html" target="inha">Results</A> </TD> </TR> <TR> <TD><A href="dsn.html" target="inha">Obtaining DSN</A> </TD> </TR> <TR> <TD> <A Href="gloss.html" target="inha">Index / Glossary</A> </TD> </TR> <TR> <TD> <A Href="http://genix.net/unixODBC/" target="_top">unixODBC Home</A> </TD> </TR> </TABLE> </BODY> </HTML> PK �e(\v8� � Tutorial/close.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Closing a connection</TITLE> <LINK REL="Stylesheet" href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0"> <TR> <TD colspan="3" class="big">Closing a connection</TD> </TR> <TR> <TD colspan="3"><P>Before your program terminates you need to free all resources you have allocated. If you checked the source on the previous page, you certainly spotted <CODE><A HREF="gloss.html#free">SQLFreeHandle</A></CODE>. This function must be used to free each allocated handle. It expects a parameter which states the type of the handle to be freed and the handle itself. So if you want to free an environment handle you should call (in our example program):</P> <CODE> SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); </CODE> <P> Before you free any handle make sure that it is no longer needed, wouldn't be funny, if you released to connection handle but forgot to close the connection ;)</P> <P> And if you want to close a connection you need <CODE><A HREF="gloss.html#clos">SQLDisconnect</A></CODE>. This closes the connection associated with the connection handle offered as argument to <CODE>SQLDisconnect</CODE>. In our programm we need to call:</P> <CODE> SQLDisconnect(V_OD_hdbc); </CODE> <P> If you need source code, please have a look <A HREF="conne.html#list">here</A>.</P> </TD> </TR> </TABLE> </BODY> </HTML> PK �e(\���;, , Tutorial/resul.htmlnu �[��� <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Fetching Data</TITLE> <LINK REL="StyleSheet" Href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0"> <TR> <TD colspan="3" class="big">Fetching data from a result set</TD> </TR> <TR> <TD colspan="3"><P>If the execution of the statement went fine you are now able to fetch the data <A Href="gloss.html#col">column</A> by column. May be you would first like to know how many columns there are in the result set (if you use a <CODE> SELECT * FROM tkeyuser</CODE> you wouldn't know in your program). A call to <a href="gloss.html#ccol"><CODE>SQLNumResultCols</CODE></A>. This function takes the statement handle and a pointer to an integer variable which will yield the number of columns after the call.</P> Knowing that much we can add this to our program: <CODE><PRE> <FONT COLOR="green">// At the beginning add:</FONT> SQLSMALLINT V_OD_colanz; <FONT COLOR="green">// Num of columns</FONT> <FONT COLOR="green">// At the end add:</FONT> V_OD_erg=SQLNumResultCols(V_OD_hstmt,&V_OD_colanz); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Fehler im ResultCols %d\n",V_OD_erg); SQLFreeHandle(SQL_HANDLE_STMT,V_OD_hstmt); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } printf("Number of Columns %d\n",V_OD_colanz); </PRE></CODE> <P> The next thing you need to know is how many <A href="gloss.html#row">rows</A> have been returned by the query. A call to <A HREF="gloss.html#crow"><CODE>SQLRowCount</CODE></A> should quench your thirst for knowledge. </P> <P> The last thing to do is to fetch the data itself from the result set. You should call <A HREF="gloss.html#fetc"><CODE>SQLFetch</CODE></A> with a statement handle (which has been allocated and <CODE>SQLBind</CODE> has been called for all columns). <CODE>SQLFetch</CODE> returns <CODE>SQL_NO_DATA</CODE> if there is no more data in the result set. </P> <P>So here is the complete source code. Real C-programmers will moan in disgust how inefficient the program is coded, but I prefer it that way (doesn't it look a little bit like PASCAL?). Take it as a starting point for your own endeavors with ODBC.</P> <CODE class="list"><PRE> /* odbc.c testing unixODBC */ #include <stdlib.h> #include <stdio.h> #include <odbc/sql.h> #include <odbc/sqlext.h> #include <odbc/sqltypes.h> SQLHENV V_OD_Env; <FONT COLOR="green">// Handle ODBC environment</FONT> long V_OD_erg; <FONT COLOR="green">// result of functions</FONT> SQLHDBC V_OD_hdbc; <FONT COLOR="green">// Handle connection</FONT> char V_OD_stat[10]; <FONT COLOR="green">// Status SQL</FONT> SQLINTEGER V_OD_err,V_OD_rowanz,V_OD_id; SQLSMALLINT V_OD_mlen,V_OD_colanz; char V_OD_msg[200],V_OD_buffer[200]; int main(int argc,char *argv[]) { <FONT COLOR="green">// 1. allocate Environment handle and register version </FONT> V_OD_erg=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&V_OD_Env); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error AllocHandle\n"); exit(0); } V_OD_erg=SQLSetEnvAttr(V_OD_Env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error SetEnv\n"); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } <FONT COLOR="green">// 2. allocate connection handle, set timeout</FONT> V_OD_erg = SQLAllocHandle(SQL_HANDLE_DBC, V_OD_Env, &V_OD_hdbc); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error AllocHDB %d\n",V_OD_erg); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } SQLSetConnectAttr(V_OD_hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0); <FONT COLOR="green">// 3. Connect to the datasource "web" </FONT> V_OD_erg = SQLConnect(V_OD_hdbc, (SQLCHAR*) "web", SQL_NTS, (SQLCHAR*) "christa", SQL_NTS, (SQLCHAR*) "", SQL_NTS); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error SQLConnect %d\n",V_OD_erg); SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, V_OD_stat, &V_OD_err,V_OD_msg,100,&V_OD_mlen); printf("%s (%d)\n",V_OD_msg,V_OD_err); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } printf("Connected !\n"); V_OD_erg=SQLAllocHandle(SQL_HANDLE_STMT, V_OD_hdbc, &V_OD_hstmt); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Fehler im AllocStatement %d\n",V_OD_erg); SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, V_OD_stat,&V_OD_err,V_OD_msg,100,&V_OD_mlen); printf("%s (%d)\n",V_OD_msg,V_OD_err); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } SQLBindCol(V_OD_hstmt,1,SQL_C_CHAR, &V_OD_buffer,150,&V_OD_err); SQLBindCol(V_OD_hstmt,2,SQL_C_ULONG,&V_OD_id,150,&V_OD_err); V_OD_erg=SQLExecDirect(V_OD_hstmt,"SELECT dtname,iduser FROM tkeyuser order by iduser",SQL_NTS); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Error in Select %d\n",V_OD_erg); SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, V_OD_stat,&V_OD_err,V_OD_msg,100,&V_OD_mlen); printf("%s (%d)\n",V_OD_msg,V_OD_err); SQLFreeHandle(SQL_HANDLE_STMT,V_OD_hstmt); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } V_OD_erg=SQLNumResultCols(V_OD_hstmt,&V_OD_colanz); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { SQLFreeHandle(SQL_HANDLE_STMT,V_OD_hstmt); SQLDisconnect(V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } printf("Number of Columns %d\n",V_OD_colanz); V_OD_erg=SQLRowCount(V_OD_hstmt,&V_OD_rowanz); if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO)) { printf("Number ofRowCount %d\n",V_OD_erg); SQLFreeHandle(SQL_HANDLE_STMT,V_OD_hstmt); SQLDisconnect(V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); exit(0); } printf("Number of Rows %d\n",V_OD_rowanz); V_OD_erg=SQLFetch(V_OD_hstmt); while(V_OD_erg != SQL_NO_DATA) { printf("Result: %d %s\n",V_OD_id,V_OD_buffer); V_OD_erg=SQLFetch(V_OD_hstmt); } ; SQLFreeHandle(SQL_HANDLE_STMT,V_OD_hstmt); SQLDisconnect(V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); return(0); } </PRE> </CODE> If I find some more time I will add something about diagnostics, cursor positioning updating and and and... </TD> </TR> </TABLE> </BODY> </HTML> PK �e(\C��N �N Tutorial/gloss.htmlnu �[��� <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Developer Studio"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Glossary </TITLE> <LINK REL="StyleSheet" Href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0" cellspacing="0"> <TR> <TD colspan="3" class="big">Index / Glossary</TD> </TR> <TR> <TD colspan="3"> <TABLE Cols="13" width=90% bgcolor="black"> <TR> <TH class="head"><a href="#A">A</A></TH> <TH CLASS="head"><a href="#B">B</A></TH> <TH CLASS="head"><a href="#C">C</A></TH> <TH CLASS="head"><a href="#D">D</A></TH> <TH CLASS="head"><a href="#E">E</A></TH> <TH CLASS="head"><a href="#F">F</A></TH> <TH CLASS="head"><a href="#G">G</A></TH> <TH CLASS="head"><a href="#H">H</A></TH> <TH CLASS="head"><a href="#I">I</A></TH> <TH CLASS="head"><a href="#J">J</A></TH> <TH CLASS="head"><a href="#K">K</A></TH> <TH CLASS="head"><a href="#L">L</A></TH> <TH CLASS="head"><a href="#M">M</A></TH> </TR> <TR> <TH CLASS="head"><a href="#N">N</A></TH> <TH CLASS="head"><a href="#O">O</A></TH> <TH CLASS="head"><a href="#P">P</A></TH> <TH CLASS="head"><a href="#Q">Q</A></TH> <TH CLASS="head"><a href="#R">R</A></TH> <TH CLASS="head"><a href="#S">S</A></TH> <TH CLASS="head"><a href="#T">T</A></TH> <TH CLASS="head"><a href="#U">U</A></TH> <TH CLASS="head"><a href="#V">V</A></TH> <TH CLASS="head"><a href="#W">W</A></TH> <TH CLASS="head"><a href="#X">X</A></TH> <TH CLASS="head"><a href="#Y">Y</A></TH> <TH CLASS="head"><a href="#Z">Z</A></TH> </TR> </TABLE> </TD> </TR> </TABLE> <table width="90%" cols="3" border="0" cellspacing="0"> <TR> <TD class="head" width="60"><a name="C"><B>C</B></A></TD> <TD width="20" class="head"> </TD> <TD class="head"><A Name="col">Column</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD><P>A column is another name for field in a SQL table. It has a data type (Integer, Char, Money etc) and a name by which it is addressed.</P> <P>You specify the name of a column in a query (either DELETE, UPDATE, SELECT or INSERT)</P> </TD> </TR> <TR> <TD class="head" width="60"><a name="D"><B>D</B></A></TD> <TD width="20" class="head"> </TD> <TD class="head"><A Name="dsrc">data source</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>A data source defines all informationen needed by ODBC to connect to a database. This includes the name of the driver to use (Postgres, mySQL etc.), the name of the user, his password, the server name on which the database resides and of course the name of the database. There are a lot more options available. </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="dtyp">Data Types</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD><P> The following table show some ODBC data types and how the relate to standard C data types:</P> <TABLE COLS="3" border="0" cellspacing="1"> <TR> <TH CLASS="head">Type identifier</TH> <TH CLASS="head">ODBC typedef</TH> <TH CLASS="head">C typedef</TH> </TR> <TR> <TD class="small">SQL_C_CHAR</TD> <TD class="small">SQLCHAR * </TD> <TD class="small">unsigned char * </TD> </TR> <TR> <TD class="small">SQL_C_SSHORT</TD> <TD class="small">SQLSMALLINT</TD> <TD class="small">short int </TD> </TR> <TR> <TD class="small">SQL_C_USHORT </TD> <TD class="small">SQLUSMALLINT </TD> <TD class="small">unsigned short int </TD> </TR> <TR> <TD class="small">SQL_C_SLONG </TD> <TD class="small">SQLINTEGER</TD> <TD class="small">long int</TD> </TR> <TR> <TD class="small">SQL_C_FLOAT</TD> <TD class="small">SQLREAL</TD> <TD class="small">float </TD> </TR> <TR> <TD class="small">SQL_C_DOUBLE</TD> <TD class="small">SQLDOUBLE, SQLFLOAT</TD> <TD class="small">double </TD> </TR> <TR> <TD class="small">SQL_C_BINARY </TD> <TD class="small">SQLCHAR *</TD> <TD class="small">unsigned char </TD> </TR> <TR> <TD class="small">SQL_C_TYPE_DATE</TD> <TD class="small">SQL_DATE_STRUCT</TD> <TD class="small"> struct <BR>tagDATE_STRUCT {<BR> SQLSMALLINT year; <BR> SQLUSMALLINT month; <BR> SQLUSMALLINT day; <BR> } DATE_STRUCT; </TD> </TR> <TR> <TD class="small">SQL_C_TYPE_TIME </TD> <TD class="small">SQL_TIME_STRUCT </TD> <TD class="small">struct<BR>tagTIME_STRUCT {<BR> SQLUSMALLINT hour; <BR> SQLUSMALLINT minute; <BR> SQLUSMALLINT second; <BR> } TIME_STRUCT; </TD> </TR> </TABLE> <P>You will need the type identifier in calls to <A HREF="#bind">SQLBindCol</A>. </TD> </TR> <TR> <TD colspan="2"> </TD> <TD > </TD> </TR> <TR> <TD class="head" width="60"><a name="O"><B>O</B></A></TD> <TD width="20" class="head"> </TD> <TD class="head"><A Name="oini">odbc.ini</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD><CODE>/etc/odbc.ini</CODE> is the configuration file for system <A HREF="#dsrc">data sources</A>. It contains information which will be needed when connecting to a database. It is modified by a graphical utility ODBCConfig. </TD> </TR> <TR> <TD class="head" width="60"><a name="R"><B>R</B></A></TD> <TD width="20" class="head"> </TD> <TD class="head"><A Name="row">Row</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>A row is a set of <A HREF="#col">columns</A> in a query. For example in our <A HREF="intro.html#tab">table</A> there are two users. Each user makes up a row in the table or in the result of our query. </TD> </TR> <TR> <TD class="head" width="60"><a name="S"><B>S</B></A></TD> <TD width="20" class="head"> </TD> <TD class="head"><A Name="alloc">SQLAllocHandle</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>allocates needed handles. <CODE><PRE> SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandlePtr); </PRE></CODE> <H4>Arguments</H4> <h5>HandleType</h5> <P> Defines the type of handle to be allocated by <CODE>SQLAllocHandle</CODE>. There are four possible values:</P> <CODE> SQL_HANDLE_ENV<BR> SQL_HANDLE_DBC<BR> SQL_HANDLE_STMT<BR> SQL_HANDLE_DESC </CODE> <H5>InputHandle</H5> This is the input handle in whose context the new handle will be allocated. If <CODE>HandleType</CODE> is <CODE>SQL_HANDLE_ENV</CODE>, this is <CODE>SQL_NULL_HANDLE</CODE>. For a handle of type <CODE>SQL_HANDLE_DBC</CODE>, this has to be an environment handle, and if it is <CODE>SQL_HANDLE_STMT</CODE> or <CODE>SQL_HANDLE_DESC</CODE>, it must be a connection handle. <H5>OutputHandlePtr</H5> Pointer to a buffer in which to return the allocated handle. <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,</CODE> or <CODE>SQL_ERROR</CODE>. <HR width="20%" align="center"> </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="bind">SQLBindCol</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD > binds a variable to a column in the result. <CODE><PRE> SQLRETURN SQLBindCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLPOINTER TargetValuePtr, SQLINTEGER BufferLength, SQLINTEGER *StrLen_or_IndPtr); </PRE></CODE> <H4>Arguments</H4> <H5>StatementHandle</H5> <CODE>StatementHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> and will hold all information and the result set of the statement. <H5>ColumnNumber</H5> Number of the column in the result set. Starts with 1. <H5>TargetType</H5> Type identifier of the <A href="#dtyp">data type</A> <H5>TargetValuePtr</H5> The pointer to the variable in which the data will be stored. <H5>BufferLength</H5> The size of the buffer <CODE>TargetValuePtr</CODE> points at in bytes. <H5>StrLen_or_IndPtr</H5> When data is fetched, returns either <UL> <LI>The length of the data available to return <LI>SQL_NO_TOTAL <LI>SQL_NULL_DATA </UL> <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR</CODE> or <CODE>SQL_INVALID_HANDLE</CODE>. <HR align="center" width="20%"> </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="conn">SQLConnect</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD > connects to a datasource <CODE><PRE> SQLRETURN SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSMALLINT NameLength1, SQLCHAR *UserName, SQLSMALLINT NameLength2, SQLCHAR *Authentication, SQLSMALLINT NameLength3); </PRE></CODE> <H4>Arguments</H4> <H5>ConnectionHandle</H5> <CODE>ConnectionHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> and will hold all information about the connection. <H5>ServerName</H5> Name of the database server <H5>NameLength1</H5> The length of <CODE>ServerName</CODE> or <CODE>SQL_NTS</CODE> <H5>UserName</H5> The name of the user who connects to the database. <H5>NameLength2</H5> The length of <CODE>UserName</CODE> or <CODE>SQL_NTS</CODE> <H5>Authentication</H5> Password of the user <H5>NameLength3</H5> The length of <CODE>Authentication</CODE> or <CODE>SQL_NTS</CODE> <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR</CODE> or <CODE>SQL_INVALID_HANDLE</CODE>. <HR align="center" width="20%"> </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="dsn">SQLDataSources</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD > fetches avaible datasource names either user, system or both. <CODE><PRE> SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle, SQLUSMALLINT Direction, SQLCHAR *ServerName, SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1Ptr, SQLCHAR *Description, SQLSMALLINT BufferLength2, SQLSMALLINT *NameLength2Ptr); </PRE></CODE> <H4>Arguments</H4> <H5>EnvironmentHandle</H5> <CODE>EnvironmentHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE>. <H5>Direction</H5> Which DSN we are looking for. May be on of: <TABLE COLS="2" border="0"> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of all available datasources (either user or systemwide). </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST_USER</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of the available user datasources. </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST_SYSTEM</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of the available system datasources. </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_NEXT</CODE></TD> <TD>Fetches the next datasource. Depending on <CODE>SQL_FETCH_FIRST_USER</CODE>, <CODE>SQL_FETCH_FIRST_SYSTEM</CODE> or <CODE>SQL_FETCH_FIRST</CODE> this may only be a user datasource, only a system datasource or one of either. </TR> </TABLE> <H5>ServerName</H5> The name of the datasource is returned herein. <H5>BufferLength1</H5> Defines how many chars <I>Servername</I> may contain at most. <H5>NameLength1Ptr</H5> The pointer to the variable in which the actual length of the datasource name is stored. If <I>NameLength1Ptr</I> is greater than <I>BufferLength1</I>, then the DSN in <I>ServerName</I> is truncated to fit. <H5>BufferLength</H5> The size of the buffer <CODE>TargetValuePtr</CODE> points at in bytes. <H5>Description</H5> The description supplied with the datasource, giving more information on the datasource in human readable form. <H5>BufferLength2</H5> Defines how many chars <I>Description</I> may contain at most. <H5>NameLength2Ptr</H5> The pointer to the variable in which the actual length of the description is stored. If <I>NameLength2Ptr</I> is greater than <I>BufferLength2</I>, then the description in <I>Description</I> is truncated to fit. <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR</CODE>, <CODE>SQL_NO_DATA></CODE> or <CODE>SQL_INVALID_HANDLE</CODE>. <HR align="center" width="20%"> </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="exec">SQLExecDirect</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD > Executes a SQL statement <CODE><PRE> SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength); </PRE></CODE> <H4>Arguments</H4> <H5>StatementHandle</H5> <CODE>StatementHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> and will hold all information and the result set of the statement. <H5>StatementText</H5> The SQL statement to be executed <H5>TextLength</H5> The length of <CODE>StatementText</CODE> or <CODE>SQL_NTS</CODE> <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR</CODE> or <CODE>SQL_INVALID_HANDLE</CODE>. <HR align="center" width="20%"> </TD> </TR> <TR> <TD width="20" colspan="2"> </TD> <TD class="head"><A Name="clos">SQLDisconnect</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>disconnects the specified connection <CODE><PRE> SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle); </PRE></CODE> <H4>Arguments</H4> <H5>ConnectionHandle</H5> The handle of the connection to be closed. <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,</CODE> or <CODE>SQL_ERROR</CODE>. <HR width="20%" align="center"> </TD> </TR> <TR> <TD width="20" colspan="2"> </TD> <TD class="head"><A Name="fetc">SQLFetch</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>Fetches the next row of the result set. <CODE><PRE> SQLRETURN SQLFetch(SQLHDBC StatementHandle); </PRE></CODE> <H4>Arguments</H4> <H5>StatementHandle</H5> The handle of the statement to be closed fromwhich the data should be fetched. <H4>Returns</H4> <P><CODE>SQL_SUCCESS, SQL_NO_DATA, SQL_STILL_EXECUTING, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,</CODE> or <CODE>SQL_ERROR</CODE>.</P> <HR width="20%" align="center"> </TD> </TR> <TR> <TD width="20" colspan="2"> </TD> <TD class="head"><A Name="free">SQLFreeHandle</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD> frees allocated handles. <CODE><PRE> SQLRETURN SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle); </PRE></CODE> <H4>Arguments</H4> <h5>HandleType</h5> <P> Defines the type of handle to be freed. There are four possible values:</P> <CODE> SQL_HANDLE_ENV<BR> SQL_HANDLE_DBC<BR> SQL_HANDLE_STMT<BR> SQL_HANDLE_DESC </CODE> <H5>InputHandle</H5> The handle to be freed. Should match the type stated by <CODE>HandleType</CODE> <H4>Returns</H4> <CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,</CODE> or <CODE>SQL_ERROR</CODE>. <HR width="20%" align="center"> </TD> </TR> <TR> <TD width="20" colspan="2"> </TD> <TD class="head"><A Name="ccol">SQLNumResultCols</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>returns the number of columns in the result set. <CODE><PRE> SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCountPtr); </PRE></CODE> <H4>Arguments</H4> <H5>StatementHandle</H5> <CODE>StatementHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> and holds all information and the result set of the statement. <h5>ColumnCountPtr</H5> A pointer to a variable to hold the result value. <H4>Returns</H4> <P><CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_INVALID_HANDLE,</CODE> or <CODE>SQL_ERROR</CODE>.</P> <HR width="20%" align="center"> </TD> </TR> <TR> <TD width="20" colspan="2"> </TD> <TD class="head"><A Name="crow">SQLRowCount</A></TD> </TR> <TR><TD Colspan="2"> </TD> <TD>returns the number of rows affected by INSERT, UPDATE or DELETE. Many drivers (but not all) return the number of rows returned by the last executed SELECT statement too. <CODE><PRE> SQLRETURN SQLSQLRowCount(SQLHSTMT StatementHandle, SQLSMALLINT *RowCountPtr); </PRE></CODE> <H4>Arguments</H4> <H5>StatementHandle</H5> <CODE>StatementHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> and holds all information and the result set of the statement. <h5>RowCountPtr</H5> A pointer to a variable to hold the result value. <H4>Returns</H4> <P><CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_INVALID_HANDLE,</CODE> or <CODE>SQL_ERROR</CODE>.</P> <HR width="20%" align="center"> </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="conattr">SQLSetConnectAttr</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD > modifies attributes of connections. <CODE><PRE> SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength); </PRE></CODE> <H4>Arguments</H4> <H5>ConnectionHandle</H5> <CODE>ConnectionHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> and defines the connection which will be modified. <H5>Attribute</H5> which attribute to set <H5>ValuePtr</H5> Pointer to the value for <CODE>Attribute</CODE>. Depending on <CODE>Attribute</CODE>, <CODE>ValuePtr</CODE> will be a 32-bit integer value or a pointer to a null-terminated string. <H5>StringLength</H5> If <CODE>ValuePtr</CODE> points to a character string or a binary buffer, this argument should be the length of <CODE>*ValuePtr</CODE>. Otherwise, for <CODE>ValuePtr</CODE> of type integer <CODE>StringLength</CODE> is ignored. <H4>Returns</H4> <P><CODE>SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR</CODE> or <CODE>SQL_INVALID_HANDLE</CODE>.</P> <HR align="center" width="20%"> </TD> </TR> <TR> <TD colspan="2"> </TD> <TD class="head"><A NAME="envattr">SQLSetEnvAttr</A></TD> </TR> <TR> <TD colspan="2"> </TD> <TD > sets attributes of environments. <CODE><PRE> SQLRETURN SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength); </PRE></CODE> <H4>Arguments</H4> <H5>EnvironmentHandle</H5> <CODE>EnvironmentHandle</CODE> must have been allocated by <CODE>SQLAllocHandle</CODE> <H5>Attribute</H5> which attribute to set <H5>ValuePtr</H5> Pointer to the value for <CODE>Attribute</CODE>. Depending on <CODE>Attribute</CODE>, <CODE>ValuePtr</CODE> will be a 32-bit integer value or a pointer to a null-terminated string. <H5>StringLength</H5> If <CODE>ValuePtr</CODE> points to a character string or a binary buffer, this argument should be the length of <CODE>*ValuePtr</CODE>. Otherwise, for <CODE>ValuePtr</CODE> of type integer <CODE>StringLength</CODE> is ignored. <H4
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0 |
proxy
|
phpinfo
|
???????????