Thema: Delphi StoredProcedure Problem

Einzelnen Beitrag anzeigen

omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#17

Re: StoredProcedure Problem

  Alt 28. Dez 2008, 16:10
SQL-Code:
CREATE PROCEDURE MGLGETNUMBER
RETURNS (NEWNUMBER VARCHAR(10))
AS
DECLARE VARIABLE y CHAR(4);
DECLARE VARIABLE m CHAR(2);
DECLARE VARIABLE lfdnr INT;
BEGIN
  y = EXTRACT(YEAR FROM current_timestamp);
  m = EXTRACT(MONTH FROM current_timestamp);

  SELECT COUNT(*)+1
  FROM rechnungen
  WHERE rnumber STARTING WITH :y || :m
  INTO :lfdnr;

  IF (:lfdnr < 10) THEN
    newnumber = :y || :m || '0' || :lfdnr;
  ELSE
    newnumber = :y || :m || :lfdnr;

  SUSPEND;
END
  Mit Zitat antworten Zitat