dax4fun
Goto Top

Interbase db replikation...

Hi, Leute

brauche eure Hilfe, habe als Aufgabe eine Interbase6 Table bekommen, wo ich wenn eine neue Zeile dazukommt, die ganze Zeile in eine andere DB replizieren soll, die identisch aufgebaut ist.

Dieser neuer Eintrag (Zeile), kommt alle 5 min als fortlaufender event und datums Eintrag, weitere 20+ Einträge sind noch mit an Board (EVENT täglich von 2 bis 288 am nächsten Tag wieder 2-288 )

GRTIME                   GRNUMBER          GRRACENUMBERIX     GRFIRST    GRSECOND    GRODD_001 
25.08.2014 00:05:00               2         749481002          4           5        1502
25.08.2014 00:10:00               3         749481003          5           1        1302
habe mir gedacht das per "stored procedure " zu machen (da wenn event da schnell replizieren!! ) habe eine solche gefunden die vorhanden war, davon will ich eine txt Datei und per isql in die andere db rein

# vorhandene procedure

CONNECT 'D:\ESDS\Database\CONTROLDESK.IB' USER 'SYSDBA' PASSWORD 'masterkey';  
/*
 * Exceptions.
 */ 
CREATE EXCEPTION FAILED_TO_CREATE_FILE 'File could not be created.';  
CREATE EXCEPTION FAILED_TO_WRITE_FILE 'File could not be written.';  


/*
 * Procedure to write file: <TICKETNUMBER>.txt
 */ 
SET TERM ^ ;
CREATE PROCEDURE WRITE_TICKET_FILE (ticketNumber CHAR(40), ticketAmount INTEGER, isCancel INTEGER)
AS
  DECLARE VARIABLE printerSerialNumber VARCHAR(32);
  DECLARE VARIABLE path VARCHAR(128);
  DECLARE VARIABLE filename VARCHAR(256);
  DECLARE VARIABLE filehandle INTEGER;
  DECLARE VARIABLE retwrite INTEGER;
  DECLARE VARIABLE retclose INTEGER;
  DECLARE VARIABLE newline VARCHAR(4);
  DECLARE VARIABLE content VARCHAR(4096);
  DECLARE VARIABLE contentAmountFloat FLOAT;
  DECLARE VARIABLE contentAmountStr VARCHAR(32);
  DECLARE VARIABLE contentStatus VARCHAR(8);
  DECLARE VARIABLE contentLength INTEGER;
BEGIN

  /*
   * Configure following PARAMETERs:
   */   
  printerSerialNumber = '1234567890123456';  
  path = 'C:\\TICKETS\\';  
  
  /*
   * From here no further changes needed
   */   
  newline = CHR(10);
  
  filename = path || ticketNumber || '.txt';  

  filehandle = FOPEN(filename, BITOR(FO_CREAT(), FO_RDWR()));  
  IF (filehandle >= 0) THEN
    BEGIN
      
      contentStatus = '';  
      IF (isCancel = 1) THEN
        BEGIN
          contentStatus = '1;1;';  
        END
      
      contentAmountFloat = ticketAmount;
      contentAmountStr = contentAmountFloat / 100;
      contentAmountStr = TRIM(contentAmountStr);
      contentAmountStr = SUBSTR(contentAmountStr, 1, STRPOS('.',contentAmountStr)+2);  
      
      content = '350,1,______,_,__;+6 Broj listica:;' || newline ||  
                '350,1,______,_,__;+7 ' || SUBSTR(ticketNumber, 0, 21) || ';' || newline ||  
                '350,1,______,_,__;+8 ' || SUBSTR(ticketNumber, 21, 21) || ';' || newline ||  
                '48,1,______,_,__;' || printerSerialNumber || ';1;0000;' || contentStatus || newline ||  
                '52,1,______,_,__;1;' || contentAmountStr || ';0.00;' || newline ||  
                '53,1,______,_,__;' || newline ||  
                '56,1,______,_,__;' || newline;  
      
      contentLength = STRLEN(content);
      
      retwrite = FWRITE(filehandle, content);
      IF (retwrite <> contentLength) THEN
        BEGIN
          retclose = FCLOSE(filehandle);
          EXCEPTION FAILED_TO_WRITE_FILE;
        END
      
      retclose = FCLOSE(filehandle);
    END
  ELSE
    BEGIN
      EXCEPTION FAILED_TO_CREATE_FILE;
    END
    
END
^
SET TERM ; ^
# meine Interpretation ;)
/*
 * Exceptions.
 */ 
CREATE EXCEPTION FAILED_TO_CREATERESULT_FILE 'File could not be created.';  
CREATE EXCEPTION FAILED_TO_WRITERESULT_FILE 'File could not be written.';  


/*
 * Procedure to write file: <TICKETNUMBER>.txt
 */ 
SET TERM ^ ;
CREATE PROCEDURE WRITE_RESULT_FILE (ticketNumber CHAR(40), ticketAmount VARCHAR(4096))
AS
  
  DECLARE VARIABLE path VARCHAR(128);
  DECLARE VARIABLE filename VARCHAR(256);
BEGIN
  path = 'C:\\RESULTS\\';  
  filename = path || ticketNumber || ticketAmount || '.txt';  
  FOPEN(filename);
  FWRITE(filename);
FCLOSE(filename);
END
^
SET TERM ; ^

Content-ID: 247793

Url: https://administrator.de/forum/interbase-db-replikation-247793.html

Ausgedruckt am: 23.12.2024 um 16:12 Uhr