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
  
// -*- Pike -*- 
 
#pike __REAL_VERSION__ 
 
final constant dont_dump_module=1; 
 
#if constant(@module@.oracle) 
 
inherit @module@ : M; 
 
class oracle 
{ 
  inherit M::oracle : O; 
 
  object big_typed_query(object(compile_query)|string query, 
                         void|mapping(int|string: 
                                      int|float|string|multiset(string)) binds, 
                         void|int autocommit) 
    { 
      if(stringp(query)) query=compile_query(query); 
      object ret = query->big_typed_query(binds, autocommit, this); 
      if(query->_type == 1) 
      { 
        return ret; 
      } 
      else if(query->output_variables) 
      { 
        return Sql.sql_result( ({ query->output_variables }) ); 
      } 
    } 
 
  object list_tables(void|string wild) 
    { 
      if(wild) 
      { 
        return big_typed_query("select tname from tab where tname like :wild", 
                               ([":wild":wild])); 
      }else{ 
        return big_typed_query("select tname from tab"); 
      } 
    } 
 
  // Implements the standard API. 
  class big_query 
  { 
    protected object answer; 
 
    // Aliases. 
    function(:int) num_rows; 
    function(:int) num_fields; 
    function(:int) eof; 
    function(:array(mapping(string:mixed))) fetch_fields; 
    function(int:void) seek; 
 
    // Convert to the standard result coding.  
    protected string|int(0..0) compat_convert(mixed x) 
    { 
      if(!x && !intp(x)) return 0; 
      if(multisetp(x)) return ((array(string))x)*","; 
      return (string)x; 
    } 
 
    int(0..0)|array(string|int(0..0)) fetch_row() 
    { 
      array(mixed) res = answer->fetch_row(); 
 
      if (res) { 
        return map(res, compat_convert); 
      } 
      return 0; 
    } 
 
    protected void create(object(compile_query)|string query, 
                          void|mapping(int|string: 
                                       int|float|string|multiset(string)) binds, 
                          void|int autocommit) 
    { 
      answer = big_typed_query(query, binds, autocommit); 
      if (!answer) { 
        destruct(); 
        return; 
      } 
      num_rows = answer->num_rows; 
      num_fields = answer->num_fields; 
      eof = answer->eof; 
      fetch_fields = answer->fetch_fields; 
      seek = answer->seek; 
    } 
  } 
} 
 
#endif