diff options
author | Hiroshi Inoue <inoue@tpf.co.jp> | 2001-02-16 03:10:09 +0000 |
---|---|---|
committer | Hiroshi Inoue <inoue@tpf.co.jp> | 2001-02-16 03:10:09 +0000 |
commit | b24b2a5be0c087706e18534f57fee697d8cfa572 (patch) | |
tree | 4d643a99f6ef44242a197ee275794d7cffcad060 /src | |
parent | f65ebaddb47a0ebeb6993cbe2d6c69208b3e04f3 (diff) | |
download | postgresql-b24b2a5be0c087706e18534f57fee697d8cfa572.tar.gz postgresql-b24b2a5be0c087706e18534f57fee697d8cfa572.zip |
Add casting for numeric/float4/float8 type value
automatically to compensate the lack of automatic
conversion functionality of PostgreSQL server.
For example if there's a numeric type binding
1.2567 --> 1.2567::numeric.
I hope this change would enable the use of numeric
type in MS-Access etc.
Thanks Hiroki Kataoka for his checking my code.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/odbc/convert.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c index 95ac701247b..be96b7ea6da 100644 --- a/src/interfaces/odbc/convert.c +++ b/src/interfaces/odbc/convert.c @@ -1065,6 +1065,33 @@ int lobj_fd, retval; /* because of no conversion operator for bool and int4, SQL_BIT */ /* must be quoted (0 or 1 is ok to use inside the quotes) */ + case SQL_REAL: + if (buf) + my_strcpy(param_string, sizeof(param_string), buf, used); + sprintf(tmp, "'%s'::float4", param_string); + strcpy(&new_statement[npos], tmp); + npos += strlen(tmp); + break; + case SQL_FLOAT: + case SQL_DOUBLE: + if (buf) + my_strcpy(param_string, sizeof(param_string), buf, used); + sprintf(tmp, "'%s'::float8", param_string); + strcpy(&new_statement[npos], tmp); + npos += strlen(tmp); + break; + case SQL_NUMERIC: + if (buf) + { + cbuf[0] = '\''; + my_strcpy(cbuf + 1, sizeof(cbuf) - 12, buf, used); /* 12 = 1('\'') + strlen("'::numeric") + 1('\0') */ + strcat(cbuf, "'::numeric"); + } + else + sprintf(cbuf, "'%s'::numeric", param_string); + my_strcpy(&new_statement[npos], sizeof(stmt->stmt_with_params) - npos - 1, cbuf, strlen(cbuf)); + npos += strlen(&new_statement[npos]); + break; default: /* a numeric type or SQL_BIT */ if (param_sqltype == SQL_BIT) new_statement[npos++] = '\''; /* Open Quote */ |