Re: Oracle Pro C problem
Date: 21 Dec 1994 15:49:29 GMT
Message-ID: <3d9iq9$ert_at_rigel.infinet.com>
Jorn Horvik (jornh_at_albatross.no) wrote:
: When I retrieve character strings from the database, the strings are
: padded with blanks. This makes string comparision a bit difficult.
: The question is does anyone know how to avoid the strings being padded
: with blanks?
If you are using Pro*C 1.5 or later, you can do the following, which is
described in the section on datatype equivalencing in the precompilers
guide(s).
EXEC SQL BEGIN DECLARE SECTION;
char emp_name[11];
EXEC SQL VAR emp_name IS STRING (11);
EXEC SQL END DECLARE SECTION; In this way, when ORACLE fetches the data, the blank-padded character variable is converted to a NULL terminated string.
You can also just write a function that starts at the end of the variable, and goes backwards until it finds a non-space, and drop a null there.
-- Brian W. Gardner "Captain, I protest; I am not a 495 Park Blvd. merry man!" - Lt. Worf Worthington, OH 43085 bgardner_at_infinet.com (home) gardner_at_ems.abb.com (office)Received on Wed Dec 21 1994 - 16:49:29 CET