Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    26

    Unanswered: Error when trying to copy data from differents columns

    Hi,

    I am using Sybase v11.x. I am trying to copy from one
    column to another column in a stored procedure as follows:

    UPDATE tbl1
    SET column1 = (select column2 from tbl2 where @variable =
    variable)
    WHERE @parameter = parameter

    Everything is declared approriately.

    The problem seems to be the datatypes TEXT for both column1
    and column2, the error I get is:
    "The ONCE AGGREGATE operation cannot take a TEXT datatype as
    an argument."

    I cannot covert these to other data types and they will
    always be longer than 255 characters.

    Does anyone know a way I can get around this? (apart from
    using version 12.x where I can convert/cast and > 255
    characters)

    Thanks!

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Maybe try a join
    UPDATE tbl1
    SET column1 = tbl2.column2
    from tbl1, tbl2
    where @variable = tbl2.variable
    and @parameter = tbl1.parameter

  3. #3
    Join Date
    Jan 2004
    Posts
    26
    Thanks for your reply. Seems the fact of encapsulating the subquery in brackets I am creating a local variable which is a TEXT datatype and not allowed in this case.

    Instead I:

    UPDATE tbl1
    SET tbl1.col1 = tbl2.col1 from tbl2
    WHERE @param = tbl1.col2 and @param = tbl2.col2

    Cheers

Posting Permissions

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