Модератор: Модераторы
Ustas писал(а):"МИР", (МИР), МИР, , МИР. и т.д.
Containing '"МИР"' or Containing '(МИР)' or Containing 'МИР,' or Containing 'МИР.' or ...
CREATE OR ALTER PROCEDURE SELECT_NEAR (
VAL_INPUT VARCHAR(15) )
RETURNS (
BUF VARCHAR(15),
OUT_STR VARCHAR(15) )
AS
DECLARE VARIABLE first_char_pos INTEGER;
DECLARE VARIABLE last_char_pos INTEGER;
DECLARE VARIABLE left_char_pos INTEGER;
DECLARE VARIABLE right_char_pos INTEGER;
DECLARE VARIABLE prefix VARCHAR(1);
DECLARE VARIABLE suffix VARCHAR(1);
BEGIN
FOR SELECT f1 FROM T1 WHERE f1 CONTAINING :val_input INTO :buf
DO
BEGIN
out_str = val_input;
first_char_pos = POSITION(val_input IN buf);
IF (first_char_pos < 1) THEN first_char_pos = 1;
last_char_pos = first_char_pos + CHAR_LENGTH(val_input) - 1;
IF (first_char_pos > 1) THEN
left_char_pos = first_char_pos - 1;
ELSE
left_char_pos = 1;
right_char_pos = last_char_pos + 1;
prefix = '';
suffix = '';
IF (SUBSTRING(buf from left_char_pos for 1) IN ('"', '(', ')', ',', '.')) THEN
prefix = SUBSTRING(buf from left_char_pos for 1);
IF (SUBSTRING(buf from right_char_pos for 1) IN ('"', '(', ')', ',', '.')) THEN
suffix = SUBSTRING(buf from right_char_pos for 1);
out_str = prefix || out_str || suffix;
SUSPEND;
END
END
SELECT поле FROM таблица
WHERE поле SIMILAR TO '_%[[:SPACE:]!"#$%&,-.]поиск_*'
OR поле SIMILAR TO 'поиск_*'
ORDER BY поле
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2