00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "ocilib_internal.h"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 boolean OCI_NumberGet(OCI_Connection *con, OCINumber *data, void *value,
00046 uword size, uword flag)
00047 {
00048 boolean res = TRUE;
00049
00050 OCI_CHECK(con == NULL, FALSE);
00051 OCI_CHECK(value == NULL, FALSE);
00052 OCI_CHECK(data == NULL, FALSE);
00053
00054 if (flag & OCI_NUM_DOUBLE)
00055 {
00056 OCI_CALL2
00057 (
00058 res, con,
00059
00060 OCINumberToReal(con->err, data, size, value)
00061 )
00062 }
00063 else
00064 {
00065 uword sign = OCI_NUMBER_SIGNED;
00066
00067 if (flag & OCI_NUM_UNSIGNED)
00068 sign = OCI_NUMBER_UNSIGNED;
00069
00070 OCI_CALL2
00071 (
00072 res, con,
00073
00074 OCINumberToInt(con->err, data, size, sign, value)
00075 )
00076 }
00077
00078 return res;
00079 }
00080
00081
00082
00083
00084
00085 boolean OCI_NumberSet(OCI_Connection *con, OCINumber *data, void *value,
00086 uword size, uword flag)
00087 {
00088 boolean res = TRUE;
00089
00090 OCI_CHECK(con == NULL, FALSE);
00091 OCI_CHECK(value == NULL, FALSE);
00092 OCI_CHECK(data == NULL, FALSE);
00093
00094 if (flag & OCI_NUM_DOUBLE)
00095 {
00096 OCI_CALL2
00097 (
00098 res, con,
00099
00100 OCINumberFromReal(con->err, value, size, (OCINumber *) data)
00101 )
00102 }
00103 else
00104 {
00105 uword sign = OCI_NUMBER_SIGNED;
00106
00107 if (flag & OCI_NUM_UNSIGNED)
00108 sign = OCI_NUMBER_UNSIGNED;
00109
00110 OCI_CALL2
00111 (
00112 res, con,
00113
00114 OCINumberFromInt(con->err, value, size, sign, (OCINumber *) data)
00115 )
00116 }
00117
00118 return res;
00119 }
00120
00121
00122
00123
00124
00125
00126 boolean OCI_NumberConvertStr(OCI_Connection *con, OCINumber *num,
00127 const dtext *str, int str_size,
00128 const mtext* fmt, ub4 fmt_size)
00129 {
00130 boolean res = TRUE;
00131 void *ostr1 = NULL;
00132 int osize1 = str_size;
00133 void *ostr2 = NULL;
00134 int osize2 = fmt_size;
00135
00136 #ifdef OCI_CHARSET_MIXED
00137
00138 mtext temp[OCI_SIZE_BUFFER + 1];
00139
00140 #endif
00141
00142 OCI_CHECK(con == NULL, FALSE);
00143 OCI_CHECK(str == NULL, FALSE);
00144 OCI_CHECK(fmt == NULL, FALSE);
00145
00146 #ifdef OCI_CHARSET_MIXED
00147
00148 temp[0] = 0;
00149
00150 ostr1 = temp;
00151 osize1 = (int) wcstombs(temp, str, OCI_SIZE_BUFFER + OCI_CVT_CHAR);
00152
00153 #else
00154
00155 ostr1 = OCI_GetInputDataString(str, &osize1);
00156
00157 #endif
00158
00159 ostr2 = OCI_GetInputMetaString(fmt, &osize2);
00160
00161
00162 memset(num, 0, sizeof(*num));
00163
00164 OCI_CALL2
00165 (
00166 res, con,
00167
00168 OCINumberFromText(con->err, (oratext *) ostr1, (ub4) osize1,
00169 (oratext *) ostr2, (ub4) osize2,
00170 (oratext *) NULL, (ub4) 0, num)
00171 )
00172
00173 #ifndef OCI_CHARSET_MIXED
00174
00175 OCI_ReleaseDataString(ostr1);
00176
00177 #endif
00178
00179 OCI_ReleaseMetaString(ostr2);
00180
00181 return res;
00182 }
00183
00184
00185
00186
00187
00188
00189 boolean OCI_NumberGetFromStr(OCI_Connection *con, void *value, uword size,
00190 uword type, const dtext *str, int str_size,
00191 const mtext* fmt, ub4 fmt_size)
00192 {
00193 OCINumber num;
00194
00195 OCI_CHECK(value == NULL, FALSE);
00196
00197 return (OCI_NumberConvertStr(con, &num, str, str_size, fmt, fmt_size) &&
00198 OCI_NumberGet(con, &num, value, size, type));
00199 }