Einzelnen Beitrag anzeigen

Benutzerbild von dataspider
dataspider

Registriert seit: 9. Nov 2003
Ort: 04539 Groitzsch
1.351 Beiträge
 
Delphi 11 Alexandria
 
#18

Re: Falsche Zeichen in einem DB-Feld per SQL finden

  Alt 16. Jul 2008, 21:31
Hi,

ich würde für den Test eine Procedure schreiben:

SQL-Code:
SET TERM ^ ;

CREATE PROCEDURE CHECK_BARCODE (
    barcode varchar(20))
returns (
    result char(1))
as
begin
  /* check barcode */
  result = 'F';
  if (substring(:barcode from 1 for 1) <> 'F') then
  begin
    suspend;
    exit;
  end
  if (substring(:barcode from 2 for 1) not between '0and '9') then
  begin
    suspend;
    exit;
  end
  if (substring(:barcode from 3 for 1) not between '0and '9') then
  begin
    suspend;
    exit;
  end
  if (substring(:barcode from 4 for 1) not between '0and '9') then
  begin
    suspend;
    exit;
  end
  if (substring(:barcode from 5 for 1) not between '0and '9') then
  begin
    suspend;
    exit;
  end
  if (substring(:barcode from 6 for 1) not between '0and '9') then
  begin
    suspend;
    exit;
  end
  if (substring(:barcode from 7 for 1) not between '0and '9') then
  begin
    suspend;
    exit;
  end
  result = 'T';
  suspend;
end^
SET TERM ; ^
das where sollte dann so aussehen:

where (select result from check_barcode(ScanCode)) = 'F' Cu, Frank
Frank Reim
  Mit Zitat antworten Zitat