~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to db/drivers/odbc/table.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <string.h>
18
18
#include <grass/dbmi.h>
19
19
#include <grass/gis.h>
 
20
#include <grass/glocale.h>
20
21
#include "odbc.h"
21
22
#include "globals.h"
22
23
#include "proto.h"
127
128
    cursor *c;
128
129
    SQLRETURN ret;
129
130
    char msg[OD_MSG];
130
 
    char *emsg = NULL;
131
131
    SQLINTEGER err;
132
132
    SQLCHAR ttype[50], *tname;
133
133
    SQLINTEGER nrow = 0;
142
142
 
143
143
    ret = SQLTables(c->stmt, NULL, 0, NULL, 0, tname, sizeof(tname), NULL, 0);
144
144
    if ((ret != SQL_SUCCESS) && (ret != SQL_SUCCESS_WITH_INFO)) {
145
 
        report_error("SQLTables()");
 
145
        db_d_append_error("SQLTables()");
 
146
        db_d_report_error();
146
147
        return DB_FAILED;
147
148
    }
148
149
 
149
150
    /* Get number of rows */
150
151
    ret = SQLRowCount(c->stmt, &nrow);
151
152
    if ((ret != SQL_SUCCESS) && (ret != SQL_SUCCESS_WITH_INFO)) {
152
 
        report_error("SQLRowCount()");
 
153
        db_d_append_error("SQLRowCount()");
 
154
        db_d_report_error();
153
155
        return DB_FAILED;
154
156
    }
155
157
 
156
158
    if (nrow == 0) {
157
 
        G_asprintf(&emsg, "Table %s doesn't exist\n", tname);
158
 
        report_error(emsg);
159
 
        G_free(emsg);
 
159
        db_d_append_error(_("Table %s doesn't exist"), tname);
 
160
        db_d_report_error();
 
161
        
160
162
 
161
163
        return DB_FAILED;
162
164
    }
171
173
        sprintf(cmd, "DROP VIEW %s", tname);
172
174
    }
173
175
    else {
174
 
        G_asprintf(&emsg, "Table %s isn't 'TABLE' or 'VIEW' but %s\n", tname,
175
 
                   ttype);
176
 
        report_error(emsg);
177
 
        G_free(emsg);
178
 
 
 
176
        db_d_append_error(_("Table %s isn't 'TABLE' or 'VIEW' but %s"),
 
177
                          tname, ttype);
 
178
        db_d_report_error();
 
179
        
179
180
        return DB_FAILED;
180
181
    }
181
182
 
185
186
    if ((ret != SQL_SUCCESS) && (ret != SQL_SUCCESS_WITH_INFO)) {
186
187
        SQLGetDiagRec(SQL_HANDLE_STMT, c->stmt, 1, NULL, &err, msg,
187
188
                      sizeof(msg), NULL);
188
 
        G_asprintf(&emsg, "SQLExecDirect():\n%s\n%s (%d)\n", cmd, msg,
189
 
                   (int)err);
190
 
        report_error(emsg);
191
 
        G_free(emsg);
192
 
 
 
189
        db_d_append_error("SQLExecDirect():\n%s\n%s (%d)", cmd, msg,
 
190
                          (int)err);
 
191
        db_d_report_error();
 
192
        
193
193
        return DB_FAILED;
194
194
    }
195
195