I am using Oracle PL/SQL on Oracle Database 10g
I use SYS.DBS_JOB to set a job to send an email. [I cannot simply send the email directly because I am sending quite a few emails and sending them too fast overloads the mail server. Therefore I run a loop to send one email each minute]
DBMS_JOB.submit
(l_job,
'begin HTML_EMAIL (''noreply@mywebsite.com'','''
|| myrecord.email
|| ''','''
|| mytitle
|| ''','''
|| ' '
|| ''','''
|| mymessage
|| ''');end;',
schedule_date
);
The text for the job is quite long (2886 characters) and the job fails with the message “ORA-01461 can bind a LONG value only for insert into a LONG column”
Now I am pretty sure that the reason that the job fails is because the text is too long. However I would have thought that the error message would have been “String can not fit into column”
Assuming I am right that my string is too long, what is the maximum length, and also how can I get round this problem…
Thank you
PL/SQL is limited in what you can do directly with LONG fields, and it sounds like your mymessage field is a long. In 10g, you’re better off using CLOB fields for something like this, which can be directly manipulated much more easily.
To start with, try wrapping any LONG fields in this call with the TO_LOB() function and see if that works. Alternately, it may be that your message is overflowing the varchar2 that DBMS_JOB.SUBMIT expects; Oracle may then be treating your string as a LONG. In this case, you’ll have to rewrite your HTML_EMAIL function so that it retrieves the message content from a temporary table rather than a parameter.
There’s some nice info on working with LONG fields here:
http://www.oracle-developer.net/display.php?id=430