Skip to Content
avatar image
Former Member

To trim the data from a fix length

Hi Experts,

     I have a requirement in which i need to post the data from a particular character count.

For e.g.:

If the input is like :

distributed update operation failed; rollback required.Invoice date in the future is not allowed at COALXL.WATCH_STL_INVOICE_HDR, line 245 error during execution of trigger 'COALXL.WATCH_STL_INVOICE_HDR' at line 8.


Than i need to send the output like


COALXL.WATCH_STL_INVOICE_HDR, line 245 error during execution of trigger 'COALXL.WATCH_STL_INVOICE_HDR' at line 8.

Means it should truncated from a fixed position and then till the end.

Can you please suggest how can we do this?

Regards,

CB

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 02, 2015 at 05:51 AM

    Hi Chandra,

    Use the textfunction substring, input it like substring(245..0). Just make sure that the length > 245 otherwise it will result in an error.

    Regards,

    Mark


    test.png (21.2 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 02, 2015 at 06:15 AM

    Hi Mark,

         I tried your above logic but substring is not working.

    Its nit calculating the length of the field.


    Capture.png (35.1 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 02, 2015 at 07:06 AM

    Yes I understand... But that would hardly effect... because it is failing to calculate the length ... at that node only ... please correct me if am wrong

    Add comment
    10|10000 characters needed characters exceeded

    • Please try this UDF

          public String udf_SubString(String in, int start, int end, Container container) throws StreamTransformationException {
              int len = in.length();
              if (len < start) {
                  in = "";
              } else if (len < end) {
                  in = in.substring(start, len);
              } else {
                  in = in.substring(start, end);
              }
              return in;
          }