Write text function "help" with error message

  •  

    Thanks for your help. I'm not going to use this .

    But I would be greatful if you could help me with the following:

    When runing in analyser i get an error message.

    Server: Msg 7133, Level 16, State 2, Procedure uspAddNewsRelease, Line 36

    NULL textptr (text, ntext, or image pointer) passed to WriteText function.

    HELP! dont know why its adding null values to this field

    CREATE PROCEDURE dbo.uspAddNewsRelease

    @newsText   text

    As

    BEGIN TRAN       -- means begin tranasction Need to have this for SQL server 2000

    --EXEC sp_dboption 'BLPT', 'select into/bulkcopy', 'true'

    DECLARE @ptrval binary(16)       --declare varaible  Must be 16 as we used this value later on in our paramaeter for the upload page

    SELECT @ptrval = TEXTPTR(NewsText)  --- text is wrapped in the varaible

    FROM tblNews

    WRITETEXT tblNews.NewsText @ptrval @newsText

    --EXEC sp_dboption 'BLPT', 'select into/bulkcopy', 'false'

    COMMIT

    return @@identity

    GO

  • The error is telling you that the value of ptrval is null and is caused by either

    The table is empty

    Or the row in the table has null in the column NewsText

    Your procedure is only expecting tblNews to contain one row is this correct ?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • yep.writing to the last field updated

  • Try the following (change is bold text).  Also, be aware that WRITETEXT is limited to about 120Kb - refer to BOL. So if your @newsText variable is longer than that, you'll get data truncation and/or an error.

    CREATE PROCEDURE dbo.uspAddNewsRelease

    @newsText text

    AS

    BEGIN TRAN       -- means begin tranasction Need to have this for SQL server 2000

    --EXEC sp_dboption 'BLPT', 'select into/bulkcopy', 'true'

    DECLARE @ptrval binary(16)       --declare varaible  Must be 16 as we used this value later on in our paramaeter for the upload page

    UPDATE tblNews SET NewsText = ''  -- initialize text pointer

    SELECT @ptrval = TEXTPTR(NewsText)  --- text is wrapped in the varaible

      FROM tblNews

    WRITETEXT tblNews.NewsText @ptrval @newsText

    --EXEC sp_dboption 'BLPT', 'select into/bulkcopy', 'false'

    COMMIT

    return @@identity

    GO

  • thanks - i will try it

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply