Trimming character columns
От | Cem ÇÖLGEÇEN |
---|---|
Тема | Trimming character columns |
Дата | |
Msg-id | CACVVsG28AEJaU5ts4tEq1+ivNm__Qm4iQ4ziFWuZnf16O6M+FA@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Trimming character columns
|
Список | pgsql-odbc |
Hi,
I want to trimming character(char) columns via ODBC driver. I've done something like this and it works, but I'm not satisfied.
file: convert.c
/*
* First convert any specific postgres types into more useable data.
*
* NOTE: Conversions from PG char/varchar of a date/time/timestamp value
* to SQL_C_DATE,SQL_C_TIME, SQL_C_TIMESTAMP not supported
*/
switch (field_type)
{
/*
* $$$ need to add parsing for date/time/timestamp strings in
* PG_TYPE_CHAR,VARCHAR $$$
*/
/*ADDED*/ case 1042:
/*ADDED*/ rtrim(value);
/*ADDED*/ break;
case PG_TYPE_DATE:
sscanf(value, "%4d-%2d-%2d", &std_time.y, &std_time.m, &std_time.d);
break;
case PG_TYPE_TIME:
{
BOOL bZone = FALSE; /* time zone stuff is unreliable */
int zone;
timestamp2stime(value, &std_time, &bZone, &zone);
}
break;
I have rtim function:
void rtrim(char *str) {
char *s;
s = str + strlen(str);
while (--s >= str) {
if (!isspace(*s)) break;
*s = 0;
}
}
How do I make it more stable?
Thank you.
В списке pgsql-odbc по дате отправления: