John Powell (jpowell@cv.hp.com) wrote:
: Here is an SQL puzzle for everyone:
: We need to trim the last character from a variable length parameter
: that is passed into an SPL stored procedure. We have tried setting
: a variable len as:
: let len = length(v_parm_name) - 1;
: let v_short_parm_name = v_parm_name[1, len];
: On the second line we get a syntax error on len. I have run into the
: same problem with a regular SQL statement such as:
: select col1[1, LENGTH(col2)] from table1;
: Any ideas on how to solve this problem? If you can think of any way to
: do, please send your ideas. We could write this in SQL, SPL, 4GL, etc. or
: if we had to, call a C program.
int trim(char *string)
{
if (*string == (char)0) return 0; /* null string! */
string[strlen(string)-1] = (char)0; /* shorten it by 1 */
return 1; /* for success */
}
There's your solution for a C environment... can't help you otherwise.
/* John */
--
\\|\\ John Rumpelein, Internet Services Consultant
\\| Destruction of the empty spaces is my one and only crime.