~ubuntu-branches/ubuntu/trusty/psqlodbc/trusty-proposed

« back to all changes in this revision

Viewing changes to docs/howto-ch.html

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-10-24 07:21:55 UTC
  • mfrom: (16.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131024072155-xlf5odyk3iblcd51
Tags: 1:09.02.0100-2ubuntu1
* Merge with Debian unstable. Remaining Ubuntu changes:
  - debian/tests: Disable iodbc test and dependency, as in Ubuntu iodbc and
    unixodbc are not installable in parallel, and iodbc is obsolete and
    should be removed at some point.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
 
<html>
3
 
  <head>
4
 
    <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5
 
    <title>psqlODBC HOWTO - Ch</title>
6
 
  </HEAD>
7
 
 
8
 
  <body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
9
 
  
10
 
<h1>psqlODBC HOWTO - Ch</h1>
11
 
 
12
 
<p>
13
 
 
14
 
<i>
15
 
Author: Wayne Cheng  (wayne@softintegration.com)<br>
16
 
Release Date: 23 September 2003<br>
17
 
Description: Example based Mini-Howto on Accessing PostgreSQL from Ch
18
 
</i>
19
 
<br><br>
20
 
Ch is a C/C++ interpreter from <a href="http://www.softintegration.com">http://www.softintegration.com</a>.<br>
21
 
It is designed for cross-platform scripting, shell programming, 
22
 
2D/3D plotting, numerical computing, and embedded scripting. 
23
 
 
24
 
<br><br>
25
 
Requirements to get the code to work:
26
 
 
27
 
<br>
28
 
<ul>
29
 
<li>Ch Standard Edition or Professional Edition</li>
30
 
<li>Ch ODBC Toolkit.</li>
31
 
<li>IODBC, UNIXODBC or Microsoft ODBC manager.</li>
32
 
<li>A PostgreSQL datasource.</li>
33
 
</ul>
34
 
 
35
 
<b>How to run ODBC code in Ch</b><br>
36
 
You should be able to use the simple.c scripts, start Ch shell first.
37
 
 
38
 
<br>
39
 
<blockquote>
40
 
<pre>
41
 
% ch
42
 
                                   Ch 
43
 
                  Standard edition, version 4.0.0.11291 
44
 
              (C) Copyright 2001-2003 SoftIntegration, Inc.
45
 
                     http://www.softintegration.com
46
 
/home/wcheng> cd $CHHOME/package/iodbc/demos
47
 
/usr/local/ch/package/iodbc/demos&gt; ls
48
 
odbctest.c  simple.c
49
 
/usr/local/ch/package/iodbc/demos&gt; ./simple.c
50
 
SQLAllocHandle() OK
51
 
SQLSetEnvAttr() ok
52
 
SQLAllocHandle() ok
53
 
SQLSetConnectAttr() ok
54
 
/usr/local/ch/package/iodbc/demos&gt; cat simple.c
55
 
 
56
 
/**************************** simple.c *****************************/ 
57
 
#include &lt;sqlext.h&gt;
58
 
#include &lt;stdio.h&gt;
59
 
 
60
 
void ODBC_error (       /* Get and print ODBC error messages */
61
 
    SQLHENV henv,       /* ODBC Environment */
62
 
    SQLHDBC hdbc,       /* ODBC Connection Handle */
63
 
    SQLHSTMT hstmt)     /* ODBC SQL Handle */
64
 
{
65
 
    UCHAR   sqlstate[10];
66
 
    UCHAR   errmsg[SQL_MAX_MESSAGE_LENGTH];
67
 
    SDWORD  nativeerr;
68
 
    SWORD   actualmsglen;
69
 
    RETCODE rc = SQL_SUCCESS;
70
 
 
71
 
    while ( rc != SQL_NO_DATA_FOUND)
72
 
    {
73
 
        rc = SQLError(henv, hdbc, hstmt,
74
 
                      sqlstate, &nativeerr, errmsg,
75
 
                      SQL_MAX_MESSAGE_LENGTH - 1, &actualmsglen);
76
 
                     
77
 
         if (rc == SQL_ERROR) {
78
 
              printf ("SQLError failed!\n");
79
 
              return;
80
 
         }
81
 
 
82
 
         if (rc != SQL_NO_DATA_FOUND) {
83
 
               printf ("SQLSTATE = %s\n", sqlstate);
84
 
               printf ("NATIVE ERROR = %d\n", nativeerr);
85
 
               errmsg[actualmsglen] = '\0';
86
 
               printf ("MSG = %s\n\n", errmsg);
87
 
          }
88
 
     }
89
 
     if (hdbc != SQL_NULL_HDBC)
90
 
     {
91
 
        SQLFreeHandle (SQL_HANDLE_DBC, hdbc);
92
 
     }
93
 
     if (henv != SQL_NULL_HENV)
94
 
     {
95
 
        SQLFreeHandle (SQL_HANDLE_ENV, henv);
96
 
     }
97
 
}
98
 
 
99
 
int main(void)
100
 
{
101
 
    SQLHENV henv = SQL_NULL_HENV;
102
 
    SQLHDBC hdbc = SQL_NULL_HDBC;
103
 
    SQLHSTMT hstmt = SQL_NULL_HSTMT;
104
 
    RETCODE  rc    = SQL_SUCCESS;
105
 
 
106
 
    rc = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
107
 
 
108
 
    if (rc != SQL_ERROR)
109
 
    {
110
 
        printf("SQLAllocHandle() OK\n");
111
 
        rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3,0);
112
 
        if (rc != SQL_ERROR)
113
 
        {
114
 
            printf("SQLSetEnvAttr() ok\n");
115
 
            rc = SQLAllocHandle (SQL_HANDLE_DBC, henv, &hdbc);
116
 
            if ( rc != SQL_ERROR)
117
 
            {
118
 
                 printf("SQLAllocHandle() ok\n");
119
 
                 rc = SQLSetConnectAttr(hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF,0);
120
 
                 if (rc != SQL_ERROR)
121
 
                 {
122
 
                       printf("SQLSetConnectAttr() ok\n");
123
 
                       SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
124
 
                       SQLFreeHandle(SQL_HANDLE_ENV, henv);
125
 
                 }
126
 
             }
127
 
         }
128
 
     }
129
 
 
130
 
     if (rc == SQL_ERROR)
131
 
     {
132
 
         ODBC_error (henv, hdbc, hstmt);
133
 
     }
134
 
}
135
 
 
136
 
</pre>
137
 
 
138
 
</body>
139
 
</html>
 
 
b'\\ No newline at end of file'