#20201: Oracle String Length Issue with CLOB and NCLOB
----------------------------------------------+--------------------
     Reporter:  deejross                      |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.5
     Severity:  Normal                        |   Keywords:  oracle
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 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

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20201>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to