﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20201	Oracle String Length Issue with CLOB and NCLOB	Ross Peoples	nobody	"As mentioned in #20200, we are moving from MySQL to Oracle, but are having issues with TextFields. When the length of a field is greater than 2000, I get the following error:


{{{
*** DatabaseError: ORA-01461: can bind a LONG value only for insert into a LONG column
}}}


I am writing a script using Django's ORM to copy the data from one database to the other. Once it gets to a row with more than 2000 characters, it throws that error. I have figured out a workaround, but it's ugly and not a good solution.

This is a part of my scripts (pseudo-code):


{{{
for row in Model.objects.using(source).all():
    row.save(using=target)
}}}


This is my workaround (again, very ugly):


{{{
for row in Model.objects.using(source).all():
    try:
        row.save(using=target)
    except:
        desc = row.description
        row.description = desc[:2000]
        row.save(using=target)

        # once you have a ""good"" save, you can now save the original data with no issues
        row.description = desc
        row.save(using=target)
}}}
 

My lab environment:

Windows 7
Python 2.7 (x86)
cx_Oracle 5.1.2
Oracle 11.2g (running in Exadata cluster)
Django 1.5.1"	Bug	closed	Database layer (models, ORM)	1.5	Release blocker	duplicate	oracle	Ross Peoples shai@…	Unreviewed	0	0	0	0	0	0
