Unable to create user-defined function in C++

While I try to deploying user-defined function developed in C++, I'm getting this error "Tried to copy a 20-byte string to 7-byte VString object; VString is too small". Kindly help me with this. Thanks in advance.

Comments

  • skeswaniskeswani - Select Field - Employee

    can you post your code?

  • edited June 2019

    @skeswani Please find an attached text file

  • skeswaniskeswani - Select Field - Employee
    edited June 2019

    the problem I think is here

    returnType.addVarchar(t.getStringLength());

    this result in the copy of a buf which is 20 bytes into a response that is 7 bytes

    resWriter.getStringRef().copy(buf);

    change this to

    returnType.addVarchar(20) ;

    note, putting s '>' sign before the line will help format the code correctly in the forums

  • skeswaniskeswani - Select Field - Employee

    20 or more, this is the output return type for the scalar function. basically the scalar function return varchar(20) in this case. but maybe you want to make it varchar(32) for good measure

  • @skeswani Thanks its work.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file