1

I have a constraint on a transformer with this:

Trim(CollectFrom.collect_from,"-","A")<=TheDate

Here is what collect_from looks like:

'2017-02-27'

And here is what TheDate looks like:

'20170227'

I am unsure exactly how this Trim() function works. My first guess is that it is giving it the same format as 'TheDate' however I don't understand the "A" argument. Could somebody explain it?

camohreally
  • 149
  • 3
  • 4
  • 17

3 Answers3

3

The manual page for TRIM() says that shouldn't work.

When I try to run what you show, I get errors:

SQL[2405]: select trim('2017-02-01', '-', 'A') from dual;
SQL -674: Routine (trim) can not be resolved. 
SQLSTATE: IX000 at /dev/stdin:1
SQL[2406]: select trim('2017-02-01', '-') from dual;
SQL -674: Routine (trim) can not be resolved. 
SQLSTATE: IX000 at /dev/stdin:2

The manual says you need TRIM({BOTH|LEADING|TRAILING} [char] FROM source):

SQL[2407]: select trim(both '-' from '2017-02-12') from dual;
2017-02-12
SQL[2408]: select trim(both '-' from '2017-02-12-') from dual;
2017-02-12
SQL[2409]: select trim(both '-' from '-2017-02-12-') from dual;
2017-02-12
SQL[2410]:

(The SQL command interpreter used is my SQLCMD.)

There's a chance that someone has defined a TRIM function that takes three arguments — that's not detectable from here. You'd have to look in the system catalog of your database to find that.

OTOH, that doesn't seem to be allowed, either:

SQL[2411]: create function trim(a varchar(10), b varchar(20), c varchar(30)) returning varchar(64);
return trim(leading from a) || ' ' || trim(both from b) || ' ' || trim(trailing from c);
end function;
SQL -9710: Overloading of built-in functions is not allowed.
SQLSTATE: IX000 at /dev/stdin:8
SQL[2412]:
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
2

Informix 11.50 has build in trim() function: https://www.ibm.com/support/knowledgecenter/SSGU8G_11.50.0/com.ibm.sqls.doc/ids_sqs_1556.htm But it looks little different from trim() in your question, so I think you use trim() function build by some user.

Normally trim() takes care only at chars at beginning or at end of the string, but in your example trim() had to remove - chars that are in the middle of the string. I guess that last argument A tells trim() to remove all such characters from source string.

To find out what trim() function really do you must find it source. You can do it with some GUI database tools like SQirreL SQL Client (it uses JDBC), you can do it with dbschema Informix utility or with my Python/Jython program that uses ODBC/JDBC: https://code.activestate.com/recipes/576621-dump-informix-schema-to-text

It would be helpful to tell us what version of Informix you use.

Michał Niklas
  • 53,067
  • 18
  • 70
  • 114
0

Trim(CollectFrom.collect_from,"-","A")

Here A means to Remove all the occurrences of '-' from the input string CollectFrom.collect_from . Hence You are getting '20170227' . Here is the document which would give further more information on Trim function.

https://www.ibm.com/support/knowledgecenter/en/SSZJPZ_11.5.0/com.ibm.swg.im.iis.ds.parjob.dev.doc/topics/r_deeref_String_Functions.html

Akshay
  • 1