Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    3

    Unanswered: Updating a Text field

    In a Sybase 11.x stored proc, am having trouble trying to insert/update a TEXT field.

    @txt_fld TEXT
    @vc_1 varchar(255)
    @vc_2 varchar(255)
    @vc_3 varchar(255)
    ...

    insert into #Temp (@Txt_fld) values (@vc_1 + @vc_2 ...)


    The insert of the concatenated varchar fields truncates at 255.

    How do I get all of the varchar fields into the TEXT field?

  2. #2
    Join Date
    Jul 2003
    Posts
    3
    Let me clarify, the TEXT field is in the #Temp table.
    You can't declare TEXT variables in a stored proc.

    In a Sybase 11.x stored proc, am having trouble trying to insert/update a TEXT field.

    create table #Temp
    (@txt_fld TEXT)

    declare
    @vc_1 varchar(255)
    @vc_2 varchar(255)
    @vc_3 varchar(255)
    ...

    insert into #Temp (@Txt_fld) values (@vc_1 + @vc_2 ...)


    The insert of the concatenated varchar fields truncates at 255.

    How do I get all of the varchar fields into the TEXT field?

  3. #3
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    110
    I'm not sure about 11.x but I know this is how you do it on 12.x

    You need to use a command called WRITETEXT, you may need to read up on it. But from my experience you can't insert a text field at the same time you insert a new row, you need to insert the row then update the text field using something similar to the attached

    DECLARE @dialog_col binary(16)
    SELECT @dialog_col = TEXTPTR(dialog)
    FROM topic_tbl
    WHERE topic_key = @topic_key
    WRITETEXT topic_tbl.dialog @dialog_col @text_to_be_inserted

    Hope this helps.

  4. #4
    Join Date
    Jul 2003
    Posts
    3
    Originally posted by bmalar
    I'm not sure about 11.x but I know this is how you do it on 12.x

    You need to use a command called WRITETEXT, you may need to read up on it. But from my experience you can't insert a text field at the same time you insert a new row, you need to insert the row then update the text field using something similar to the attached

    DECLARE @dialog_col binary(16)
    SELECT @dialog_col = TEXTPTR(dialog)
    FROM topic_tbl
    WHERE topic_key = @topic_key
    WRITETEXT topic_tbl.dialog @dialog_col @text_to_be_inserted

    Hope this helps.
    ==============================================
    I tried using the writetext command, but it wouldn't accept the concatenation of the varchar fields

    WRITETEXT topic_tbl.dialog @dialog_col @v1 + @v2 + @v3

    I believe that I shall have to do this another way. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •