I know there must be a trick to do what I need to do with a text field, but I`ve spent a day with all the documentation and came up blank.

From within a stored procedure, I want to extract a substring from a text field (for a given offset and length) and store the result as a local variable. READTEXT seem to only behave as a naked select - returning results to the caller.

The only way I could think of to accomplish my goal is to write an extended stored procedure in C (using ods) that creates a new connection to the server (via db-lib calls), executes the readtext statement, and processes the result.

Please, someone tell me that there`s an easier way

Thanks, Mike