There are different platforms on which DB2 runs and in some the TRUNCATE 
command is supported, but that is not the case for iSeries DB2.
Which version of OS are you running?.

The alternative seems to be a DELETE without a WHERE clause which could be 
set as a TRUNCATE override in another db2 class adapter.
You can use the mssql one as a reference.

Or CLRPFM.

Denes

On Friday, May 6, 2016 at 4:02:18 PM UTC-4, Auden RovelleQuartz wrote:
>
> when i attempt to do a db.tablename.truncate() on a DB2 table, I get the 
> following error:
>
> Ticket ID
>
> 127.0.0.1.2016-05-06.14-57-20.5ee10f85-fb6e-4bfe-8d16-db0b224313b9
> <class 'pyodbc.ProgrammingError'> ('42000', '[42000] [IBM][iSeries Access 
> ODBC Driver][DB2 UDB]SQL0104 - Token TRUNCATE was not valid. Valid tokens: 
> ( END GET SET CALL DROP FREE HOLD LOCK OPEN WITH ALTER. (-104) 
> (SQLExecDirectW)')Version
> web2py™ Version 2.14.5-stable+timestamp.2016.04.14.03.26.16
> Python Python 2.7.9: 
> C:\Users\arovellequartz\Desktop\web2py_win\web2py\web2py.exe (prefix: )
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
>
> Traceback (most recent call last):
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\restricted.py", line 
> 227, in restricted
>     exec ccode in environment
>   File 
> "C:/Users/arovellequartz/Desktop/web2py_win/web2py/applications/test/controllers/default.py"
>  <http://127.0.0.1:8000/admin/default/edit/test/controllers/default.py>, line 
> 57, in <module>
>   File "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\globals.py", 
> line 417, in <lambda>
>     self._caller = lambda f: f()
>   File 
> "C:/Users/arovellequartz/Desktop/web2py_win/web2py/applications/test/controllers/default.py"
>  <http://127.0.0.1:8000/admin/default/edit/test/controllers/default.py>, line 
> 52, in user
>     db.riqtemp26.truncate()
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\objects.py",
>  line 838, in truncate
>     return self._db._adapter.truncate(self, mode)
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\adapters\base.py",
>  line 1004, in truncate
>     self.execute(query)
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\adapters\db2.py",
>  line 98, in execute
>     return self.log_execute(command)
>   File 
> "C:\Users\arovellequartz\Desktop\web2py_win\web2py\gluon\packages\dal\pydal\adapters\base.py",
>  line 1382, in log_execute
>     ret = self.get_cursor().execute(command, *a[1:], **b)
> ProgrammingError: ('42000', '[42000] [IBM][iSeries Access ODBC Driver][DB2 
> UDB]SQL0104 - Token TRUNCATE was not valid. Valid tokens: ( END GET SET CALL 
> DROP FREE HOLD LOCK OPEN WITH ALTER. (-104) (SQLExecDirectW)')
>
>
> Is there something special required to use the truncate() feature with DB2 
> databases?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to