powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / логич.операции в дб2
6 сообщений из 6, страница 1 из 1
логич.операции в дб2
    #33824305
будет ли в выражении (sql-процедура):
Код: plaintext
1.
2.
IF ( NOT (ParentCode IS NULL) AND NOT (Trim(ParentCode)='')  ) THEN
....
END IF
выполняться проверка второго условия при неверном первом?
т.е. в случае (ParentCode IS NULL) == True будет ли проверяться
(Trim(ParentCode)='') и если да, будет ли генериться исключение
(сравнение const с NULL)?

спасибо.
...
Рейтинг: 0 / 0
логич.операции в дб2
    #33824597
Mark Barinstein
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Будет.
Сравните:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
begin atomic
declare parentcode int;
set parentcode= 0 ;
IF ( parentcode!= 0  AND  1 /parentcode!= 1 ) THEN
   set parentcode=- 1 ;
END IF;
end@
И, если надо, чтоб отработало:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
begin atomic
declare parentcode int;
set parentcode= 0 ;
IF ( parentcode!= 0 ) THEN
 IF ( 1 /parentcode!= 1 ) THEN
   set parentcode=- 1 ;
 END IF;
END IF;
end@
Правда, в вашем случае никакого исключения генериться не будет, т.к. сравнение константы c NULL в SQL в DB2 - это не криминал.
...
Рейтинг: 0 / 0
логич.операции в дб2
    #33868183
подскажите, пожалуйста, использование в STP
Код: plaintext
GET DIAGNOSTICS v_MSG = MESSAGE_TEXT;
мне дает ошибку :
Код: plaintext
1.
Create stored procedure returns - 104 .
DB2ADMIN.BIDCRDBGN:  39 : [IBM][CLI Driver][DB2/NT] SQL0104N  An unexpected token "MESSAGE_TEXT" was found following "DIAGNOSTICS v_MSG =".  Expected tokens may include:  "<psm_diag_statement_item>".  LINE NUMBER= 39 .  SQLSTATE= 42601 
спасибо
...
Рейтинг: 0 / 0
логич.операции в дб2
    #33868218
Mark Barinstein
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
>>-GET DIAGNOSTICS---------------------------------------------->

>--+-SQL-variable-name--=--+-ROW_COUNT---------+-+-------------><
   |                       '-DB2_RETURN_STATUS-' |
   '-| condition-information |-------------------'

condition-information:

|--EXCEPTION--1------------------------------------------------->

   .-,------------------------------------------.
   V                                            |
>----SQL-variable-name--=--+-MESSAGE_TEXT-----+-+---------------|
                           '-DB2_TOKEN_STRING-'

condition-information
Specifies that the error or warning information for the previously executed SQL statement is to be returned.
If information about an error is needed, the GET DIAGNOSTICS statement must be the first statement specified in the handler that will handle the error.
If information about a warning is needed, and if the handler will get control of the warning condition, the GET DIAGNOSTICS statement must be the first statement specified in that handler.
If the handler will not get control of the warning condition, the GET DIAGNOSTICS statement must be the next statement executed.
This option can only be specified in the context of an SQL Procedure (SQLSTATE 42601).

MESSAGE_TEXT
Identifies any error or warning message text returned from the previously executed SQL statement.
The message text is returned in the language of the database server where the statement is processed.
If the statement completed with an SQLCODE of zero, an empty string is returned for a VARCHAR variable or blanks are returned for a CHAR variable.
DB2_TOKEN_STRING
Identifies any error or warning message tokens returned from the previously executed SQL statement.
If the statement completed with an SQLCODE of zero, or if the SQLCODE had no tokens, an empty string is returned for a VARCHAR variable or blanks are returned for a CHAR variable.
...
Рейтинг: 0 / 0
логич.операции в дб2
    #33868235
у меня и используется в SQL-процедуре:
Код: plaintext
1.
2.
    DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING --, NOT FOUND
    BEGIN
        GET DIAGNOSTICS v_MSG = MESSAGE_TEXT;
...
первым statement - ом в обработчике
...
Рейтинг: 0 / 0
логич.операции в дб2
    #33868295
Mark Barinstein
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING --, NOT FOUND
BEGIN
GET DIAGNOSTICS EXCEPTION 1 v_MSG = MESSAGE_TEXT;
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / логич.операции в дб2
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]