Recent News

OCILIB v3.4.0 now available for download

Posted by Vincent Rogier on July 31st, 2009

OCILIB v3.4.0 is now available for download ! Here is the list of the main changes :

  • Added support for Oracle 11g remote instance management
  • Miscelleanous fixes (binds, collections, etc.., see changelog for more details)
  • Miscelleanous modifications (Oracle version handling, etc…, see changelog for more details)

See the complete v3.4.0 change log here

Get the release and enjoy it !

Have a nice weekend.

Working with Oracle spatial types …

Posted by Vincent Rogier on July 27th, 2009

Few days ago, I saw thread in OTN Oracle Call Interface forum about how to handle Oracle Spacial SDO_GEOMETRY in OCI.

I decided to show how it could be done with OCILIB :)

Here is the writegeom sample app from Oracle rewritten with OCILIB :

  • number of lines reduced by factor 4-5
  • much easier code to read
  • the whole sdo_object is binded to the statement

Here is the code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "ocilib.h"
 
#define NB_ELEM 500
 
void error(OCI_Error *err)
{
    printf("msg   : %s\n", OCI_ErrorGetString(err));
    exit(EXIT_FAILURE);
}
 
int main(int argc, char **argv)
{
    OCI_Connection *cn;
    OCI_Statement  *st;
    OCI_Object     *obj_sdo;
    OCI_Coll       *coll_inf,  *coll_ord;
    OCI_Elem       *elem_inf,  *elem_ord;
    OCI_TypeInfo   *tif_inf,   *tif_ord, *tif_sdo;
 
    int i;
 
    /* check command line */
    if (argc < 3) 
    {
        fprintf(stderr, "Usage: %s user password\n", argv[0]);
        return EXIT_FAILURE;
    }
 
    /* init OCILIB */
    if (OCI_Initialize(error, NULL, OCI_ENV_DEFAULT))
    {
        /* connect to oracle */
        if (cn = OCI_ConnectionCreate(NULL, argv[1], argv[2], OCI_SESSION_DEFAULT))
        {
            printf ("\nConnected to Oracle.\n");
 
            /* retreive type info */
            tif_sdo = OCI_TypeInfoGet(cn, "MDSYS.SDO_GEOMETRY", OCI_TIF_TYPE);
            tif_inf = OCI_TypeInfoGet(cn, "MDSYS.SDO_ELEM_INFO_ARRAY", OCI_TIF_TYPE);
            tif_ord = OCI_TypeInfoGet(cn, "MDSYS.SDO_ORDINATE_ARRAY", OCI_TIF_TYPE);
 
            /* create sdo object */
            obj_sdo = OCI_ObjectCreate(cn, tif_sdo);
 
            /* create sub arrays */
            coll_inf = OCI_CollCreate(tif_inf);
            coll_ord = OCI_CollCreate(tif_ord);
 
            /* create sub array element accessors */
            elem_inf = OCI_ElemCreate(tif_inf);
            elem_ord = OCI_ElemCreate(tif_ord);
 
            /* build ordinates collection with test values */
            for (i = 0; i < NB_ELEM; i++)
            {
                OCI_ElemSetDouble(elem_ord, (double) i);
                OCI_CollAppend(coll_ord, elem_ord);
                OCI_CollAppend(coll_ord, elem_ord);
            }
 
            /* setup information collection attribute 'starting_offset' */
            OCI_ElemSetUnsignedInt(elem_inf, 1);
            OCI_CollAppend(coll_inf, elem_inf);
 
            /* setup information collection attribute 'element_type' */
            OCI_ElemSetUnsignedInt(elem_inf, 1);
            OCI_CollAppend(coll_inf, elem_inf);
 
            /* setup information collection attribute 'interpretation' */
            OCI_ElemSetUnsignedInt(elem_inf, 1);
            OCI_CollAppend(coll_inf, elem_inf);
 
 
            /* set sdo object member attributes */
            OCI_ObjectSetInt(obj_sdo,  "SDO_GTYPE", 4);
            OCI_ObjectSetNull(obj_sdo, "SDO_SRID");
            OCI_ObjectSetNull(obj_sdo, "SDO_POINT");
            OCI_ObjectSetColl(obj_sdo, "SDO_ELEM_INFO", coll_inf);
            OCI_ObjectSetColl(obj_sdo, "SDO_ORDINATES", coll_ord);
 
            /*create statement object */
            st = OCI_StatementCreate(cn);
 
            /* prepare, bind and excute statement then commit*/
            OCI_Prepare(st, "INSERT INTO test_insert (gid, geometry) VALUES (1, :sdo)");
            OCI_BindObject(st, "sdo", obj_sdo);
            OCI_Execute(st);
            OCI_Commit(cn);
 
            /* free local objects */
            OCI_ObjectFree(obj_sdo);
            OCI_CollFree(coll_inf);
            OCI_CollFree(coll_ord);
            OCI_ElemFree(elem_inf);
            OCI_ElemFree(elem_ord);
        }
    }
 
    /* disconnect from oracle and cleanup OCILIB */
    OCI_Cleanup();
 
    printf ("\nDisconnected from Oracle.\n");
 
    return EXIT_SUCCESS;
}

Support for 11g remote Instance management in OCILIB v3.4.0

Posted by Vincent Rogier on July 27th, 2009

Hello,

OCILIB v3.4.0 is coming soon :)

This release fixes 3 bugs and adds support for Oracle 11g remote Instance startup/shutdown.

Here is a sample app that startups a remote instance and then shuts it down :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "ocilib.h"
 
int main(int argc, char **argv)
{ 
    OCI_Initialize(error, NULL,  OCI_ENV_DEFAULT);
 
    /* start remote instance */
 
    OCI_DatabaseStartup("db", 
                        "sys_user", 
                        "sys_pwd",                
                        OCI_SESSION_SYSDBA, 
                        OCI_DB_SPM_FULL,
                        OCI_DB_SPF_DEFAULT,
                        NULL);
 
 
     /* shutdown remote instance */
 
    OCI_DatabaseShutdown("db", 
                        "sys_user", 
                        "sys_pwd", 
                         OCI_SESSION_SYSDBA,
                         OCI_DB_SDM_FULL,
                         OCI_DB_SDF_DEFAULT);
 
    OCI_Cleanup();
 
    return EXIT_SUCCESS;
}

Isn’t cool ?

Have a nice day..

OCILIB v3.3.0 now available for download

Posted by Vincent Rogier on July 6th, 2009

OCILIB v3.3.0 is now available for download ! Here is the list of the main changes :

  • Added SQL command and verb retrieving
  • Added support for batched errors for Array DML
  • Extended Lob Support
  • Extended Collection API
  • Modified and extended Bind API
  • Extended OCI_ImmediateXXX() API
  • Extended OCI_XXXFmt() API
  • Miscelleanous fixes (see changelog)
  • Miscelleanous modifications (see changelog)

See the complete v3.3.0 change log here

Get the release and enjoy it !

Have a nice week.

OCILIB SVN repository has been updated (2009-06-23)

Posted by Vincent Rogier on June 23rd, 2009

The current development snapshot of v3.3.0 has been updated.

You can browse the repository on sourceforge here
The temporary v3.3.0 changelog is available here

This latest update includes some bug fixes

Have a nice day !

Recent Comments | Recent Posts

Copyright © OCILIB | OCILIB Logo designed by WolfHound (Developpez.com)
Theme based on Wordpress AngelicDesign by: Website Builder
bottom