Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.04.23;
Скачать: CL | DM;

Вниз

Выбор неверно заведённой информации   Найти похожие ветки 

 
Alex2006   (2006-03-02 14:35) [0]

Есть база, в которой есть поле count и поля p1,p2,p3,p4,p5 типа integer. Правило заполнения: если поле count=1, то должно быть заполнено одно из полей p1-p5, если count=2, то должно быть заполнено два поля из p1-p5 и т. д. В программе сразу не был предусмотрен контроль и, теперь необходимо с помощью SQL-запроса выдернуть неверно заполненные данные. По умолчанию значения всех указанных полей=0. Спасибо.


 
Johnmen ©   (2006-03-02 14:40) [1]

Печальная история. Я плакал. Спасибо.


 
Alex2006   (2006-03-02 14:47) [2]

Я не плачу а интересуюсь. Может есть в Oracle процедура, работающая по принципу: поле<>0, значит результат=1, иначе результат=0? Если есть, то нет проблем.


 
Vlad ©   (2006-03-02 14:48) [3]


> Alex2006   (02.03.06 14:47) [2]


> Может есть в Oracle процедура, работающая по принципу: поле<>0,
>  значит результат=1, иначе результат=0?


decode


 
Alex2006   (2006-03-02 14:51) [4]

Могу я попросить синтакисис decode с расшифровкой?


 
Vlad ©   (2006-03-02 14:56) [5]

DECODE(expr,search,result[,search,result]...[,default])

Purpose
DECODE compares expr to each search value one by one. If expr is equal to a search, then Oracle returns the corresponding result. If no match is found, then Oracle returns default. If default is omitted, then Oracle returns null.

If expr and search contain character data, then Oracle compares them using nonpadded comparison semantics. expr, search, and result can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The string returned is of VARCHAR2 datatype and is in the same character set as the first result parameter.

The search, result, and default values can be derived from expressions. Oracle evaluates each search value only before comparing it to expr, rather than evaluating all search values before comparing any of them with expr. Consequently, Oracle never evaluates a search if a previous search is equal to expr.

Oracle automatically converts expr and each search value to the datatype of the first search value before comparing. Oracle automatically converts the return value to the same datatype as the first result. If the first result has the datatype CHAR or if the first result is null, then Oracle converts the return value to the datatype VARCHAR2.

In a DECODE function, Oracle considers two nulls to be equivalent. If expr is null, then Oracle returns the result of the first search that is also null.

The maximum number of components in the DECODE function, including expr, searches, results, and default, is 255.

Examples
This example decodes the value warehouse_id. If warehouse_id is 1, then the function returns "Southlake"; if warehouse_id is 2, then it returns "San Francisco"; and so forth. If warehouse_id is not 1, 2, 3, or 4, then the function returns "Non-domestic".

SELECT product_id,
      DECODE (warehouse_id, 1, "Southlake",
                            2, "San Francisco",
                            3, "New Jersey",
                            4, "Seattle",
                               "Non-domestic")
      "Location of inventory" FROM inventories
      WHERE product_id < 1775;


 
Alex2006   (2006-03-02 14:58) [6]

Спасибо, VLAD.


 
Johnmen ©   (2006-03-02 14:59) [7]

>Могу я попросить синтакисис decode с расшифровкой?

Документация недоступна?



Страницы: 1 вся ветка

Текущий архив: 2006.04.23;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.03 c
15-1143786546
КаПиБаРа
2006-03-31 10:29
2006.04.23
Кто нибудь заказывал книги на


2-1144171420
Gear
2006-04-04 21:23
2006.04.23
динамическое создание кнопок на ToolBar


2-1144664227
Рафик
2006-04-10 14:17
2006.04.23
Подскажите компонент для работы с DBASE локально, без BDE


6-1136971997
Dimich1978
2006-01-11 12:33
2006.04.23
Прописать свою прогу в Разрешенные (Брандмауер)


4-1137759065
som
2006-01-20 15:11
2006.04.23
Добавлeние учетных записей