powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / SQL in Vper
5 сообщений из 5, страница 1 из 1
SQL in Vper
    #33935872
Nikolay Kulikov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
SQLERRM Function - аналог Oracle PL/SQL SQLERRM

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
Short form message retrieved
values sqlerrm('sql551','AYYANG,UPDATE,SYSCAT.TABLES',',','en_EN', 1 )
SQL0551N  "AYYANG" does not have the privilege to perform operation "UPDATE" on object "SYSCAT.TABLES".

values  sqlerrm('sql551','GEORGE,ANYTHING,NO.TABLES',',','en_EN', 1 )
SQL0551N  "GEORGE" does not have the privilege to perform operation 
"ANYTHING" on object "NO.TABLES".

Long form message retrieved
values sqlerrm('sql551','AYYANG,UPDATE,SYSCAT.TABLES',',','en_EN', 0 )

SQL0551N "<authorization-ID>" does not have the privilege to  perform operation "<operation>" on object  "<name>". 
Explanation: Authorization ID "<authorization-ID>" attempted to perform the  specified "<operation>" on "<name>" without the proper authorization.  
 1 .  If creating or altering a table with referential constraints, this message can indicate that the user does not have the REFERENCES privilege to create or drop a FOREIGN KEY.  In  this case the "<operation>" is "REFERENCES" and the  "<name>" is the object the constraint references.  
 2 .  If attempting to run a DB2 utility or CLI application, the DB2 utility programs or CLI packages may need to be rebound to the database because the userid who created the database no longer exists or no longer has the required privileges. Execute privileges may need to be granted.   3 .  If this error occurs during invocation or creation of a routine:  ….

...
Рейтинг: 0 / 0
SQL in Vper
    #33936833
gardenman
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
)) Спасибо, надо будет заюзать))...
...
Рейтинг: 0 / 0
SQL in Vper
    #33937374
Nikolay Kulikov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Еще немного о нововведениях

В версии 8 SQL функции в DB2 UDB работяют со строками на основании ли одно или двух байтных кодировок

в версии 9 вводятся новые измерения для текстовых функций

CODEUNITS16
CODEUNITS32
OCTETS

CODEUNITS16
Function calculates the length of a string based on 16-bit UTF-16 code units.
Used by many C compilers to represent the wchar_t datatype
Use by Java to represent the CHAR datatype
Useful when an application wants to know how many double byte characters are in a string.
CODEUNITS32
Function calculates the length of a string based on 32-bit UTF-32 code units.
Useful when an application wants to process data in a simple fixed length format, and need the same answer regardless of whether the character is a Unicode supplementary character or not
OCTETS
Function calculates the length of a string as a number of bytes.
Useful for applications that are interested in allocation buffer space, or operations where simple byte processing is needed.

DEFAULT STRING LENGTH UNIT
Default string length unit depends on the context in which the string length unit is used:
CHARACTER STRING: the default string length unit is a byte (or octet).
GRAPHIC STRING: the default string length unit is two bytes. For ASCII and EBCDIC this corresponds to a double byte character. For Unicode, this corresponds to a UTF-16 code point.
BINARY STRING: the default string length unit is a byte (or octet).

A string expression is an expression that returns a value of any built-in string data type
If expression does not return a built-in string type, then an error (SQLSTATE 42815) is returned
Returned Values
If expression is a character string, the result is a character string
If expression is a graphic string, the result is a graphic string
If expression is a binary string, the result is a binary string.


CHARACTER_LENGTH
Return the length of a character (UNICODE) string

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
>>--+-CHARACTER_LENGTH-+--------------------------------->
    '-CHAR_LENGTH-----'

>------(--expression--+---USING-+-CODEUNITS16-+---+--)--><
                      |         |-CODEUNITS32-|   |
                      |         '-OCTETS------'   |
                      |                           |
                      '--,------+-CODEUNITS16-+---'
                                |-CODEUNITS32-|
                                '-OCTETS------' 

CHARACTER_LENGTH(FIRST_NAME USING CODEUNITS16)
CHAR_LENGTH(LAST_NAME, OCTETS)

LENGTH function returns the length of expression in the implicit or explicit string length unit
Код: plaintext
1.
2.
3.
4.
>>--LENGTH--(--expression--+-------------------+--)-----><
                           '-,-+-CODEUNITS16-+-'
                               |-CODEUNITS32-|
                               '-OCTETS------'
LOCATE function finds one string within another
Similar to INSTR function
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
>>-LOCATE-----(-search-string-,-source-string—----------->
>----+----------+--+------------------+--)--><
      '-,-start--'  '-,-+-CODEUNITS16--|
                        |-CODEUNITS32--|
                        '-OCTETS-------'
The schema is SYSIBM. The SYSFUN version of the LOCATE function continues to be available.
LOCATE('here','there',OCTETS)
LOCATE('to','from here to there',6,CODEUNITS16)
Так же есть еще функции
OCTET_LENGTH()

POSITION
Synonym for LOCATE function
No starting position available for search
POSITION('here' IN 'there' USING OCTETS)
POSITION('to','from here to there',CODEUNITS16)

SUBSTRING
SUBSTRING('there' FROM 1 FOR 3 USING CODEUNITS16)
SUBSTRING('test', 2, 2, OCTETS)


STRIP function removes blanks or another specified character from the end, the beginning, or both ends of a string-expression
The STRIP and TRIM functions are the same except that they differ in syntax.
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
>>-STRIP(string-expression-+----------------------------------+)-><
                       |-,BOTH-----+-+------------------+-'
                         |-,B--------| '_,strip-character_'            
                         |-,LEADING--|                                  
                         |-,L--------|                                  
                         |-,TRAILING-|                                  
                         '-,T--------'                                 
Предположим BALANCE of type CHAR(9) has a value of '000345.50'
SELECT STRIP(:BALANCE, LEADING, '0')
  FROM SYSIBM.SYSDUMMY1

Аналогичная STRIP функция TRIM

Также в CLP убрали ограничение на размер SQL оператора в 64K

SQLERRM имеет совсем котороткий вид
Код: plaintext
1.
2.
3.
4.
>--- SQLERRM(---sqlstate---)---><
VALUES SQLERRM(- 526 )
SQL0526N  The requested function does not apply to declared temporary tables.

...
Рейтинг: 0 / 0
SQL in Vper
    #33937389
Nikolay Kulikov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
ALTER позволяет:
alter table drop column
alter table alter column type
alter table alter column nullability
При изменении типов только таблица будет приведена к новому виду однако, только SELECT будут позволены на данной таблице (NO inserts или update) до того как REORG будет выполнен
Не более 3 отдельных ALTERs позволено после чего REORG обязателен
...
Рейтинг: 0 / 0
SQL in Vper
    #33937398
Nikolay Kulikov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Так же

Explain показывает почему не используется MQTs
Lists MQTs which were not used and the reason for their exclusion
Mismatched Elements and Expression Support
Allow for expressions with different order of operation to be considered for MQT selection
C = A + B is equivalent to C = B + A
Maintenance of NULLable MQT columns
Efficient handling of A=B OR (A IS NULL AND B IS NULL) predicates

Смотрите в сторону функции EXPLAIN_GET_MSGS()

которая вам сможет сказать почему не использоваласб MQT в данном запросе.
Для этого нужно еще построить пару таблиц EXPLAIN
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / SQL in Vper
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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