~ubuntu-branches/ubuntu/maverick/myodbc/maverick

« back to all changes in this revision

Viewing changes to test/my_position.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-05-10 03:07:47 UTC
  • mfrom: (8.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090510030747-pvy1kyun4743gws8
Tags: 3.51.19r646-1
* New upstream release
  - fix build failure with current libmysqlclient.  Closes: #521185.
* Fix lintian warnings about ignoring errors in postinst, config scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  Copyright (C) 1997-2007 MySQL AB
3
 
 
4
 
  This program is free software; you can redistribute it and/or modify
5
 
  it under the terms of version 2 of the GNU General Public License as
6
 
  published by the Free Software Foundation.
7
 
 
8
 
  There are special exceptions to the terms and conditions of the GPL
9
 
  as it is applied to this software. View the full text of the exception
10
 
  in file LICENSE.exceptions in the top-level directory of this software
11
 
  distribution.
12
 
 
13
 
  This program is distributed in the hope that it will be useful,
14
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
  GNU General Public License for more details.
17
 
 
18
 
  You should have received a copy of the GNU General Public License
19
 
  along with this program; if not, write to the Free Software
20
 
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
 
*/
22
 
 
23
 
#include "odbctap.h"
24
 
 
25
 
/** Test SQL_POSITION */
26
 
DECLARE_TEST(t_chunk)
27
 
{
28
 
    SQLRETURN rc;
29
 
    char      txt[100];
30
 
    SQLLEN    len;
31
 
 
32
 
    if (!driver_supports_setpos(hdbc))
33
 
        return;
34
 
 
35
 
    SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_chunk",SQL_NTS);
36
 
 
37
 
    rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_chunk(id int not null primary key, description varchar(50), txt text)",SQL_NTS);
38
 
    mystmt(hstmt,rc);
39
 
 
40
 
    rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_chunk VALUES(1,'venu','Developer, MySQL AB')",SQL_NTS);
41
 
    mystmt(hstmt,rc);
42
 
 
43
 
    rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_chunk VALUES(2,'monty','Michael Monty Widenius - main MySQL developer')",SQL_NTS);
44
 
    mystmt(hstmt,rc);
45
 
 
46
 
    rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_chunk VALUES(3,'mysql','MySQL AB- Speed, Power and Precision')",SQL_NTS);
47
 
    mystmt(hstmt,rc);
48
 
 
49
 
    SQLFreeStmt(hstmt,SQL_CLOSE);    
50
 
 
51
 
    rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * from t_chunk",SQL_NTS);
52
 
    mystmt(hstmt,rc);
53
 
 
54
 
    rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 1);
55
 
    mystmt(hstmt,rc);
56
 
 
57
 
    rc = SQLSetPos(hstmt, 1, SQL_POSITION, SQL_LOCK_NO_CHANGE);
58
 
    mystmt(hstmt,rc);
59
 
 
60
 
    rc = SQLGetData(hstmt, 2, SQL_C_CHAR, txt, 100, &len);
61
 
    mystmt(hstmt,rc);
62
 
    printMessage("\ntxt:%s(%d)",txt,len);
63
 
 
64
 
    SQLFreeStmt(hstmt,SQL_RESET_PARAMS);
65
 
    SQLFreeStmt(hstmt,SQL_UNBIND);    
66
 
    SQLFreeStmt(hstmt,SQL_CLOSE);
67
 
 
68
 
  return OK;
69
 
}
70
 
 
71
 
 
72
 
BEGIN_TESTS
73
 
  ADD_TEST(t_chunk)
74
 
END_TESTS
75
 
 
76
 
 
77
 
RUN_TESTS