4e257d2002-05-08Martin Nilsson // -*- Pike -*-
a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
8c3dda2001-06-05Fredrik Hübinette (Hubbe) 
414b7d2008-07-13Marcus Comstedt final constant dont_dump_module=1;
8c3dda2001-06-05Fredrik Hübinette (Hubbe) 
e0854b2000-03-30Fredrik Hübinette (Hubbe) #if constant(@module@.oracle)
8ba4c02000-03-30Fredrik Hübinette (Hubbe) 
a961922000-03-23Fredrik Hübinette (Hubbe) inherit @module@ : M;
3d305d2000-03-23Fredrik Hübinette (Hubbe)  class oracle {
a961922000-03-23Fredrik Hübinette (Hubbe)  inherit M::oracle : O;
3d305d2000-03-23Fredrik Hübinette (Hubbe) 
b771ae2001-06-11Henrik Grubbström (Grubba)  object big_typed_query(object(compile_query)|string query, void|mapping(int|string: int|float|string|multiset(string)) binds, void|int autocommit)
3d305d2000-03-23Fredrik Hübinette (Hubbe)  { if(stringp(query)) query=compile_query(query);
52f4c02004-01-22Martin Nilsson  object ret = query->big_typed_query(binds, autocommit, this);
3d305d2000-03-23Fredrik Hübinette (Hubbe)  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) {
b771ae2001-06-11Henrik Grubbström (Grubba)  return big_typed_query("select tname from tab where tname like :wild", ([":wild":wild]));
3d305d2000-03-23Fredrik Hübinette (Hubbe)  }else{
b771ae2001-06-11Henrik Grubbström (Grubba)  return big_typed_query("select tname from tab");
3d305d2000-03-23Fredrik Hübinette (Hubbe)  } }
b771ae2001-06-11Henrik Grubbström (Grubba)  // Implements the standard API. class big_query {
35f51c2008-06-28Martin Nilsson  protected object answer;
b771ae2001-06-11Henrik Grubbström (Grubba)  // 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.
35f51c2008-06-28Martin Nilsson  protected string|int(0..0) compat_convert(mixed x)
b771ae2001-06-11Henrik Grubbström (Grubba)  {
75c2b12002-01-07Martin Nilsson  if(!x && !intp(x)) return 0;
b771ae2001-06-11Henrik Grubbström (Grubba)  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; }
35f51c2008-06-28Martin Nilsson  protected void create(object(compile_query)|string query, void|mapping(int|string: int|float|string|multiset(string)) binds, void|int autocommit)
b771ae2001-06-11Henrik Grubbström (Grubba)  { answer = big_typed_query(query, binds, autocommit); if (!answer) { destruct();
adf47e2001-09-13Fredrik Hübinette (Hubbe)  return;
b771ae2001-06-11Henrik Grubbström (Grubba)  } num_rows = answer->num_rows; num_fields = answer->num_fields; eof = answer->eof; fetch_fields = answer->fetch_fields; seek = answer->seek; } }
3d305d2000-03-23Fredrik Hübinette (Hubbe) }
8ba4c02000-03-30Fredrik Hübinette (Hubbe) 
a42d142000-03-30Henrik Grubbström (Grubba) #endif