Легенда:
новое сообщение
закрытая нитка
новое сообщение
в закрытой нитке
старое сообщение
|
- Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
- Новичкам также крайне полезно ознакомиться с данным документом.
Кто-нибудь работал с OCI 14.01.02 12:11
Автор: Wizard(2) Статус: Незарегистрированный пользователь
|
Ситуация такова. Необходимо выполнить процедуру оракла.
Для этого делается такая последовательность действий:
[code]
// тут пропущена инициализация
//первый параметр типа Number, второй - Date, третий - Number
wsprintf(Sql,"begin BD.PROC1(:1,:2,:3); end;");
OCIStmtPrepare(hStmt->stmthp,hStmt->errhp,(text *)Sql,strlen(Sql),OCI_NTV_SYNTAX, OCI_DEFAULT);
[/code]
Далее необходимо выполнить Bind. У меня имеются переменные типа DWORD, BYTE[10], BYTE[6](записано чаисло). Так вот вопрос - можно ли делать
[code]
OCIBindByPos( hStmt->stmthp, hStmt->bndhp, hStmt->errhp,1,
&Tel->St, sizeof (DWORD), SQLT_NUM, NULL, 0, 0, 0, 0, OCI_DEFAULT);
[/code]
т.е. биндить DWORD с Number. Или нужно сначала сделать
[code]
OCINumberFromInt(hStmt->>errhp,&Tel->St, sizeof(Tel->St),OCI_NUMBER_UNSIGNED,&Num1);
[/code]
а потом
[code]
OCIBindByPos( hStmt->stmthp, hStmt->bndhp, hStmt->errhp,1,
&Num1, sizeof (OCINumber), SQLT_NUM, NULL, 0, 0, 0, 0, OCI_DEFAULT);
[/code]
Для того, чтобы биндить дату я делаю следующее :
[code]
OCIDateFromText(hStmt->>errhp,Data1,10,Format,10,NULL,NULL,&Date1);
OCIBindByPos( hStmt->stmthp, hStmt->bndhp, hStmt->errhp,2,
&Date1, sizeof (OCIDate), SQLT_DAT, NULL, 0, 0, 0, 0, OCI_DEFAULT);
[/code]
Далее возник еще один вопрос, если необходимо перед Bind выполнять преобразование в Number, то надо сделать следующее
[code]
OCINumberFromText (hStmt->errhp,Tel->Card_Nr,6, *fmt, fmt_length, NULL,NULL,&Num2);
OCIBindByPos( hStmt->stmthp, hStmt->bndhp, hStmt->errhp,3,
&Num2, sizeof (OCINumber), SQLT_NUM, NULL, 0, 0, 0, 0, OCI_DEFAULT);
[/code]
так вот в мануале написано, что *fmt это формат преобразования. Я так понял, что это шаблон (для даты я делал 'DD.MM.YYYY'). Каким может быть этот шаблон.
p.s. на мелкие ошибки не обрашайте внимания, т.к. меня интересуют общие вопросы. Всем спасибо.
|
 |
Что никто не знает??? :( 15.01.02 10:32
Автор: Wizard(2) Статус: Незарегистрированный пользователь
|
> Далее возник еще один вопрос, если необходимо перед Bind > выполнять преобразование в Number, то надо сделать > следующее > OCINumberFromText (hStmt->errhp,Tel->Card_Nr,6, > *fmt, fmt_length, NULL,NULL,&Num2); > OCIBindByPos( hStmt->stmthp, hStmt->bndhp, > hStmt->errhp,3, > &Num2, sizeof (OCINumber), SQLT_NUM, > NULL, 0, 0, 0, 0, OCI_DEFAULT); > так вот в мануале написано, что *fmt это формат > преобразования. Я так понял, что это шаблон (для даты я > делал 'DD.MM.YYYY'). Каким может быть этот шаблон. >
Ну может кто знает хотя бы про формат преобразования. Он же вроде один для всего оракла.
|
 |  |
знает :) 15.01.02 23:38
Автор: + <Mikhail> Статус: Elderman
|
> > Далее возник еще один вопрос, если необходимо перед > Bind > > выполнять преобразование в Number, то надо сделать > > следующее > > OCINumberFromText (hStmt->errhp,Tel->Card_Nr,6, > > *fmt, fmt_length, NULL,NULL,&Num2); > > OCIBindByPos( hStmt->stmthp, hStmt->bndhp, > > hStmt->errhp,3, > > &Num2, sizeof (OCINumber), SQLT_NUM, > > NULL, 0, 0, 0, 0, OCI_DEFAULT); > > так вот в мануале написано, что *fmt это формат > > преобразования. Я так понял, что это шаблон (для даты > я > > делал 'DD.MM.YYYY'). Каким может быть этот шаблон. > > > > Ну может кто знает хотя бы про формат преобразования. Он же Bot tebe format dlia NUMBER (t.k eta foo convertiruet text to number, esli tebe nado convertirovat` date dlia etogo est drugie foo (mozhet tebe nado: OCIDateFromText() ?))
Element
Example
Description
, (comma)
9,999
Returns a comma in the specified position. You can specify multiple commas in a number format model.
Restrictions:
A comma element cannot begin a number format model.
A comma cannot appear to the right of a decimal character or period in a number format model.
. (period)
99.99
Returns a decimal point, which is a period (.) in the specified position.
Restriction: You can specify only one period in a number format model.
$
$9999
Returns value with a leading dollar sign.
0
0999
9990
Returns leading zeros.
Returns trailing zeros.
9
9999
Returns value with the specified number of digits with a leading space if positive or with a leading minus if negative.
Leading zeros are blank, except for a zero value, which returns a zero for the integer part of the fixed-point number.
B
B9999
Returns blanks for the integer part of a fixed-point number when the integer part is zero (regardless of "0"s in the format model).
C
C999
Returns in the specified position the ISO currency symbol (the current value of the NLS_ISO_CURRENCY parameter).
D
99D99
Returns in the specified position the decimal character, which is the current value of the NLS_NUMERIC_CHARACTER parameter. The default is a period (.).
Restriction: You can specify only one decimal character in a number format model.
EEEE
9.9EEEE
Returns a value using in scientific notation.
FM
FM90.9
Returns a value with no leading or trailing blanks.
G
9G999
Returns in the specified position the group separator (the current value of the NLS_NUMERIC_CHARACTER parameter). You can specify multiple group separators in a number format model.
Restriction: A group separator cannot appear to the right of a decimal character or period in a number format model.
L
L999
Returns in the specified position the local currency symbol (the current value of the NLS_CURRENCY parameter).
MI
9999MI
Returns negative value with a trailing minus sign (-).
Returns positive value with a trailing blank.
Restriction: The MI format element can appear only in the last position of a number format model.
PR
9999PR
Returns negative value in <angle brackets>.
Returns positive value with a leading and trailing blank.
Restriction: The PR format element can appear only in the last position of a number format model.
RN
rn
RN
rn
Returns a value as Roman numerals in uppercase.
Returns a value as Roman numerals in lowercase.
Value can be an integer between 1 and 3999.
S
S9999
9999S
Returns negative value with a leading minus sign (-).
Returns positive value with a leading plus sign (+).
Returns negative value with a trailing minus sign (-).
Returns positive value with a trailing plus sign (+).
Restriction: The S format element can appear only in the first or last position of a number format model.
TM
TM
"Text minimum". Returns (in decimal output) the smallest number of characters possible. This element is case-insensitive.
The default is TM9, which returns the number in fixed notation unless the output exceeds 64 characters. If output exceeds 64 characters, Oracle automatically returns the number in scientific notation.
Restrictions:
You cannot precede this element with any other element.
You can follow this element only with 9 or E (only one) or e (only one).
U
U9999
Returns in the specified position the "Euro" (or other) dual currency symbol (the current value of the NLS_DUAL_CURRENCY parameter).
V
999V99
Returns a value multiplied by 10n (and if necessary, round it up), where n is the number of 9's after the "V".
X
XXXX
xxxx
Returns the hexadecimal value of the specified number of digits. If the specified number is not an integer, Oracle rounds it to an integer.
Restrictions:
This element accepts only positive values or 0. Negative values return an error.
You can precede this element only with 0 (which returns leading zeroes) or FM. Any other elements return an error. If you specify neither 0 nor FM with X, the return always has 1 leading blank.
Results of Example Number Conversions
number
'fmt'
Result
-1234567890
9999999999S
'1234567890-'
0
99.99
' .00'
+0.1
99.99
' 0.10'
-0.2
99.99
' -.20'
0
90.99
' 0.00'
+0.1
90.99
' 0.10'
-0.2
90.99
' -0.20'
0
9999
' 0'
1
9999
' 1'
0
B9999
' '
1
B9999
' 1'
0
B90.99
' '
+123.456
999.999
' 123.456'
-123.456
999.999
'-123.456'
+123.456
FM999.009
'123.456'
+123.456
9.9EEEE
' 1.2E+02'
+1E+123
9.9EEEE
' 1.0E+123'
+123.456
FM9.9EEEE
'1.23E+02'
+123.45
FM999.009
'123.45'
+123.0
FM999.009
'123.00'
+123.45
L999.99
' $123.45'
+123.45
FML99.99
'$123.45'
+1234567890
9999999999S
'1234567890+'
> вроде один для всего оракла.
|
 |  |  |
Хотелось бы уточнить пару вопросов. 16.01.02 11:04
Автор: Wizard(2) Статус: Незарегистрированный пользователь
|
> Bot tebe format dlia NUMBER Класс!!! То что надо.
Сейчас на скорую руку попробовал - получается, однако кое-что я не понял.
1. Получается, чтобы из "123456" сделать 12-ти значный Number 999999999999(имеется ввиду вместо недостающих символов сначала вставить 0) нужно в исходной строке дописать нули вручную :(. Пытался сделать 0999999999999 - не проходит. Может я что-то пропустил когда читал?
2. По поводу моего первого вопроса в первом сообщении. Обязательно ли делать сначала OCINumberFromInt(...Int1...Num1...) а потом OCIBindByPos(...Num1...). Или можно сразу делать OCIBindByPos(...Int1...), т.е. не может ли оно конвертится автоматически?
За все спасибо.
|
 |  |  |  |  |
Хотелось бы уточнить пару вопросов. 17.01.02 10:36
Автор: Wizard(2) Статус: Незарегистрированный пользователь
|
> Izvini no tebe suda ( ty kogdanibud` RTFM?): > :-D
Что такое RTFM?
|
 |  |  |  |  |  |
Хотелось бы уточнить пару вопросов. 17.01.02 21:07
Автор: + <Mikhail> Статус: Elderman
|
How to RTFM
|
|
|