---
title: "OTL v4 "
author: "zs0723"
date: "2009-06-23T15:31:49Z"
tags: ["C", "C#", "C++", "SQL", "thread"]
slug: "otl-v4"
draft: false
lastmod: "2009-06-23T15:56:21Z"
id: 413557
url: "https://zs0723.iteye.com/blog/413557"
---

1 Set trace level to check what OTL done

 

    unsigned int trace\_level = 0x1 | 0x 2 | 0x4 | 0x8 | 0x10 | 0x20;

    #define OTL\_TRACE\_LEVEL trace\_level

    #define OTL\_TRACE\_LINE\_PREFIX "OTL  "

    #define OTL\_TRACE\_LINE\_SUFFIX std::endl

 

2 How to use OTL

 

   a)  define  some MARCO that the OTL library needed

           

  

   unsigned int trace\_level = 0x1 | 0x2 | 0x4 | 0x8 |0x10 | 0x20;  
    #define OTL\_ORA9I  
    #define OTL\_STL  
    #define OTL\_ANSI\_CPP  
    #define OTL\_TRACE\_LEVEL         trace\_level  
    #define OTL\_TRACE\_STREAM        cerr  
    #define OTL\_TRACE\_LINE\_PREFIX   "OTL "  
    #define OTL\_TRACE\_LINE\_SUFFIX   std::endl

    #include &lt;otlv4.h&gt;

 

    b) intialize otl

 

      otl\_connect::otl\_initialize(1) ; // 1 means in mutiple-thread

   

   c) create otl\_connect object

 

       otl\_connect * pConn = new otl\_connect()

 

        //connect database

      

       if (!pConn -&gt; connected)

                 pConn-&gt;rlogon("usr/pwd")

 

   d) create query stream object

 

       otl\_stream query(1, "here is the sql statement",\*pConn);

 

   e) exit

   

          delete otl\_connect objects

         

          otl\_connect::otl\_terminate()

  

 

   **Note: otl library will throw otl\_exception , so please catch exception in the above operation.**