I've just had a chance to do some testing on this.
It looks like the problem is your code attempts to use the UPDATETEXT command on a text field which is currently set to NULL. Certainly, attempting to do this will produce the error message you report.
You can test this using the attached script, which creates a table (text_text) with an id column, a varchar field and a text field, inserts two rows with the text field set to null, updates the first using a regular update statement then amends it with UPDATETEXT, then updates the second (null) text field using UPDATETEXT.
CREATE TABLE [test_text] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[vc] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[txt] [text] COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
insert test_text (vc)
select 'hello, number 1'
go
insert test_text (vc)
select 'hello, number 2'
go
update test_text set txt = '12325rfegsfdgervsdfgvsdfgvfdsgv'
where id = 1
go
DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(tt.txt)
FROM test_text tt
WHERE tt.id = 1
UPDATETEXT test_text.txt @ptrval 16 1 'b'
GO
DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(tt.txt)
FROM test_text tt
WHERE tt.id = 2
UPDATETEXT test_text.txt @ptrval 16 1 'b'
GO
Perhaps ODBC statements use UPDATETEXT rather than a conventional update statement. I realise it's late in the day to be suggesting this, but do you have to use ODBC rather than OLEDB?
UPDATE: A further test reveals that executing the SQL directly using Win32::ODBC does not show a similar error. I don't have time to run the test using DBD::ODBC, but it's possible that that's where the problem lies.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.