Changeset 17:992ed1fdda52 in livinglogic.python.orasql

Show
Ignore:
Timestamp:
12/15/04 17:28:56 (15 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Convert a string longer than 32768 into a variable. If the procedure
argument is a CLOB this will result in a CLOB variable.

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • NEWS.xml

    r13 r17  
     1<section><title>Changes in 0.4 (released ??/??/2004)</title> 
     2<ulist> 
     3<item><module>ll.orasql</module> now requires <app>ll-core</app>.</item> 
     4<item>Procedures can now be called with string arguments longer that 32768 
     5characters. In this case the argument will be converted to a variable before 
     6the call. The procedure argument must be a <lit>CLOB</lit> in this case.</item> 
     7</ulist> 
     8</section> 
     9 
     10 
    111<section><title>Changes in 0.3 (released 12/09/2004)</title> 
    212<ulist> 
  • orasql.py

    r15 r17  
    4747    _ora2cx = { 
    4848        "number": NUMBER, 
    49         "varchar2": STRING 
     49        "varchar2": STRING, 
     50        "clob": CLOB 
    5051    } 
    5152     
     
    8485            realargs[pos] = value 
    8586 
    86         # Replace out parameters with variables 
     87        # Replace out parameters (and strings that are longer than the allowed 
     88        # maximum) with variables 
    8789        for (pos, (name, datatype, isin, isout)) in enumerate(self._realargs[1]): 
    88             if isout: 
     90            realarg = realargs[pos] 
     91            if isout or (isinstance(realarg, str) and len(realarg) >= 32768): 
    8992                var = cursor.var(self._ora2cx[datatype]) 
    90                 var.setvalue(0, realargs[pos]) 
     93                var.setvalue(0, realarg) 
    9194                realargs[pos] = var 
    9295 
     
    165168        record = type() 
    166169        for (i, field) in enumerate(row): 
    167             if isinstance(field, TIMESTAMP): 
    168                 field = datetime.datetime(field.year, field.month, field.day, field.hour, field.minute, field.second, field.fsecond) 
    169             elif isinstance(field, DATETIME): 
    170                 field = datetime.datetime(field.year, field.month, field.day, field.hour, field.minute, field.second) 
    171170            record[self.description[i][0]] = field 
    172171        return record