1 /******************************************************************************
2 *
3 * Project: Oracle Spatial Driver
4 * Purpose: Test mainline for Oracle Spatial Driver low level functions.
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 *
7 ******************************************************************************
8 * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
29 #include "ogr_oci.h"
30 #include "cpl_conv.h"
31
32 CPL_CVSID("$Id: ocitest.cpp 082621472436f1c8006dc8c819bb8bac9f5b967d 2018-03-09 19:48:50Z Even Rouault $")
33
34 /************************************************************************/
35 /* main() */
36 /************************************************************************/
37
main(int nArgc,char ** papszArgv)38 int main( int nArgc, char ** papszArgv )
39
40 {
41 OGROCISession *poSession = nullptr;
42 const char *pszStatement = "SELECT * FROM NEPSITE";
43 char **papszResult;
44
45 if( nArgc > 1 )
46 pszStatement = papszArgv[1];
47
48 poSession = OGRGetOCISession( "system", "LetoKing", "" );
49 if( poSession == nullptr )
50 exit( 1 );
51
52 OGROCIStatement oStatement( poSession );
53
54 if( oStatement.Execute( pszStatement ) == CE_Failure )
55 exit( 2 );
56
57 while( (papszResult = oStatement.SimpleFetchRow()) != nullptr )
58 {
59 OGRFeatureDefn *poDefn = oStatement.GetResultDefn();
60 int nColCount = poDefn->GetFieldCount();
61 int i;
62
63 printf( "\n" );
64 for( i = 0; i < nColCount; i++ )
65 {
66 printf( " %s = %s\n",
67 poDefn->GetFieldDefn(i)->GetNameRef(),
68 papszResult[i] );
69 }
70 }
71 }
72