Ian wrote:
On Apr 25, 11:13 am, Tim Sawyer <list.dja...@calidris.co.uk> wrote:

 >>> import cx_Oracle
 >>> from django.db import connection
 >>> cursor = connection.cursor()
 >>> lOutput = cursor.var(cx_Oracle.STRING)
 >>> cursor.execute("BEGIN %s := 'N'; END;", [lOutput])
Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/home/...snip.../django/db/backends/oracle/base.py", line 349,
in execute
     raise e
DatabaseError: ORA-06550: line 1, column 23:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of
the following:
    ; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.

The trailing semicolon is automatically stripped by the backend, which
is necessary for most of the queries it runs but incorrect for PL/
SQL.  The easiest fix is to add a space or a second semicolon at the
end.  Or you can do what Django does internally, which is to terminate
the PL/SQL block with a forward-slash on its own line after the
semicolon, as if the block were to be entered into sqlplus.  In that
case the forward-slash will be stripped, but the semicolon will be
left alone.

HTH,
Ian


Hmm, nearly. That gets around the error, but the return value isn't populated.

>>> import cx_Oracle
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> lOutput = cursor.var(cx_Oracle.STRING)
>>> cursor.execute("BEGIN %s := 'N'; END; ", [lOutput])
>>> print lOutput
<cx_Oracle.STRING with value None>
>>> print lOutput.getvalue()
None
>>>

Any more clues, or am I just going to have to stick with creating a specific Oracle connection to do this?

Cheers,

Tim.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to