К основному контенту

Firebird get words

Задался вопросом сохранения настроек через запятую в одном поле с последующим разбором этой строки в самом Firebird'е.
Вот что получилось. Меня устраивает. Может кому поможет.

create or alter procedure GET_WORDS (
    INSTR varchar(30000),
    DELIMITER varchar(200) = ' ')
returns (
    NUMBER integer,
    WORD varchar(30000))
as
declare variable I integer;
declare variable J integer;
begin
  NUMBER = 1;
  I = 1;
  J = position(:DELIMITER, INSTR, I);
  if (J > I) then
  begin
    WORD = substring(INSTR from I for J - I);
    while (WORD is not null) do
    begin
      if (char_length(trim(WORD)) > 0) then
      begin
        WORD = trim(WORD);
        suspend;
        NUMBER = NUMBER + 1;
      end
      I = J + char_length(DELIMITER);
      J = position(:DELIMITER, INSTR, I);
      if (J = 0) then
      begin
        J = char_length(INSTR);
        if (I < J) then
          WORD = substring(INSTR from I for J);
        else
          WORD = null;
      end
      else
        WORD = substring(INSTR from I for J - I);
    end
  end
end

Комментарии

Популярные сообщения из этого блога

Firebird various delimiters for GET_WORDS

Использование процедуры GET_WORDS для разных разделителей можно в таком виде: select WORD from GET_WORDS((select list(WORD, ';') from GET_WORDS((select list(WORD) from GET_WORDS('12 7712 12,12;12 333556', ' ')), ',')), ';') где используются последовательно несколько разделителей ' ', ',' и ';' .

Библиотека Firebird для моих программ

Часто ставлю свои программы, используемые Firebird, без установки официального клиента. Для нормальной работы программы нужна библиотека fbclient.dll, лучше взятая с сервера, где лежит база Для Windows XP ещё надо Microsoft C/C ++ Runtime Libraries Microsoft.VC80.CRT.manifest msvcp80.dll msvcr80.dll Всё это надо поместить в c:\Windows\System32 или прямо в папку с программой.

When does a ShortCut fire?

Yesterday I discovered a situation wherein a keyboard ShortCut did not fire when I was expecting it to. The specific situation was: I pressed the ShortCut key combination for an Action of an ActionList on an MDI child, while a side bar on the MDI form was focussed. I always was under the impression that ShortCuts would work globally. In exactly which circumstances do or do they not fire? Answer When does a ShortCut fire? That's a deceptively simple question with a surprisingly long answer. First I will deal with some basics and then follow the ShortCut through the VCL code to finally arrive at - I hope - a satisfying conclusion. What is a ShortCut? A ShortCut represents a special keyboard combination of one or more keys that cause an operation. Special means special to the programmer who gives meaning to the specific key combination. In Delphi a ShortCut is of type TShortCut which is declared as a whole number wi...