Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb24b2a5

Browse files
author
Hiroshi Inoue
committed
Add casting for numeric/float4/float8 type value
automatically to compensate the lack of automaticconversion 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 numerictype in MS-Access etc.Thanks Hiroki Kataoka for his checking my code.
1 parentf65ebad commitb24b2a5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎src/interfaces/odbc/convert.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,33 @@ int lobj_fd, retval;
10651065
/*because of no conversion operator for bool and int4, SQL_BIT */
10661066
/*must be quoted (0 or 1 is ok to use inside the quotes) */
10671067

1068+
caseSQL_REAL:
1069+
if (buf)
1070+
my_strcpy(param_string,sizeof(param_string),buf,used);
1071+
sprintf(tmp,"'%s'::float4",param_string);
1072+
strcpy(&new_statement[npos],tmp);
1073+
npos+=strlen(tmp);
1074+
break;
1075+
caseSQL_FLOAT:
1076+
caseSQL_DOUBLE:
1077+
if (buf)
1078+
my_strcpy(param_string,sizeof(param_string),buf,used);
1079+
sprintf(tmp,"'%s'::float8",param_string);
1080+
strcpy(&new_statement[npos],tmp);
1081+
npos+=strlen(tmp);
1082+
break;
1083+
caseSQL_NUMERIC:
1084+
if (buf)
1085+
{
1086+
cbuf[0]='\'';
1087+
my_strcpy(cbuf+1,sizeof(cbuf)-12,buf,used);/* 12 = 1('\'') + strlen("'::numeric") + 1('\0') */
1088+
strcat(cbuf,"'::numeric");
1089+
}
1090+
else
1091+
sprintf(cbuf,"'%s'::numeric",param_string);
1092+
my_strcpy(&new_statement[npos],sizeof(stmt->stmt_with_params)-npos-1,cbuf,strlen(cbuf));
1093+
npos+=strlen(&new_statement[npos]);
1094+
break;
10681095
default:/* a numeric type or SQL_BIT */
10691096
if (param_sqltype==SQL_BIT)
10701097
new_statement[npos++]='\'';/* Open Quote */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp