Skip to main content

Unable to create user-defined function in C++

  • June 18, 2019
  • 5 replies
  • 7 views

jitendramishra

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.

5 replies

skeswani
Forum|alt.badge.img
  • Participating Frequently
  • June 18, 2019

can you post your code?


jitendramishra
  • Author
  • New Participant
  • June 18, 2019

@skeswani Please find an attached text file


skeswani
Forum|alt.badge.img
  • Participating Frequently
  • June 18, 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


skeswani
Forum|alt.badge.img
  • Participating Frequently
  • June 18, 2019

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


jitendramishra
  • Author
  • New Participant
  • June 18, 2019

@skeswani Thanks its work.