Организация удаленного доступа к распределенным базам данных
Рефераты >> Программирование и компьютеры >> Организация удаленного доступа к распределенным базам данных

AS

BEGIN

ACode = GEN_ID(genNachBillings, 1);

END ^

CREATE PROCEDURE PrGenNachBillDates

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genNachBillDates, 1);

END ^

CREATE PROCEDURE PrGenNachConstUsl

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genNachConstUsl, 1);

END ^

CREATE PROCEDURE PrGenUslDivisions

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslDivisions, 1);

END ^

CREATE PROCEDURE PrGenUslLgots

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslLgots, 1);

END ^

CREATE PROCEDURE PrGenUslsKeys

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslsKeys, 1);

END ^

CREATE PROCEDURE PrGenUsls

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUsls, 1);

END ^

CREATE PROCEDURE PrGenUslCatKeys

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslCatKeys, 1);

END ^

CREATE PROCEDURE PrGenUslCat

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslCat, 1);

END ^

CREATE PROCEDURE PrGenPhones

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genPhones, 1);

END ^

CREATE PROCEDURE PrGenPhonesOwnersKeys

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genPhonesOwnersKeys, 1);

END ^

CREATE PROCEDURE PrGenPhonesOwners

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genPhonesOwners, 1);

END ^

CREATE PROCEDURE PrGenSysSettings

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genSysSettings, 1);

END ^

CREATE PROCEDURE PrGenPhonesKeys

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genPhonesKeys, 1);

END ^

CREATE PROCEDURE PrGenPlat

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genPlat, 1);

END ^

CREATE PROCEDURE PrGenPhonesPostStations

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genPhonesPostStations, 1);

END ^

CREATE PROCEDURE PrGenSysLog

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genSysLog, 1);

END ^

CREATE PROCEDURE PrGenUslTypes

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslTypes, 1);

END ^

CREATE PROCEDURE PrGenUslDivisionsKeys

RETURNS (ACode INTEGER)

AS

BEGIN

ACode = GEN_ID(genUslDivisionsKeys, 1);

END ^

^

CREATE PROCEDURE TalksExamineOwner (APhoneNmb CHAR(7), ADate DATE)

RETURNS (APhone INTEGER)

AS

DECLARE VARIABLE AStreet INTEGER;

DECLARE VARIABLE NOwner INTEGER;

DECLARE VARIABLE APhoneCode INTEGER;

BEGIN

SELECT PKey FROM Phones WHERE (PhoneNmb = :APhoneNmb) AND (:ADate BETWEEN BegDate AND EndDate)

INTO :APhone;

IF (:APhone IS NULL) THEN

BEGIN

SELECT NullOwner FROM SysSettings INTO :NOwner;

SELECT Street FROM PhonesOwners

WHERE (PKey = :NOwner) AND (:ADate BETWEEN PhonesOwners.BegDate AND PhonesOwners.EndDate)

INTO :AStreet;

IF (:AStreet IS NOT NULL) THEN

BEGIN

EXECUTE PROCEDURE PrGenPhonesKeys RETURNING_VALUES :APhone;

INSERT INTO PhonesKeys (Code)

VALUES (:APhone);

INSERT INTO Phones(Owner, PKey, PhoneNmb, Street, InstallDate, RemoveDate, BegDate, EndDate)

VALUES (:NOwner, :APhone, :APhoneNmb, :AStreet, :ADate, "12.12.2222", :ADate, "12.12.2222");

END

END

END ^

CREATE PROCEDURE TalksGetTax

AS

BEGIN

EXIT;

END ^

CREATE PROCEDURE TalksGetPay (APhone INTEGER, ADay DATE, ACallTime INTEGER, AHowLong INTEGER)

RETURNS (APay FLOAT, ACalculated SMALLINT, IsLgot SMALLINT)

AS

DECLARE VARIABLE ATax FLOAT;

DECLARE VARIABLE AProcNach FLOAT;

DECLARE VARIABLE ATalksUsl INTEGER;

DECLARE VARIABLE AOwner INTEGER;

DECLARE VARIABLE ANalog FLOAT;

BEGIN

ACalculated = 0;

SELECT TimeTalksUsl FROM SysSettings INTO :ATalksUsl;

IF (:ATalksUsl IS NULL) THEN EXIT;

SELECT Owner FROM Phones WHERE (PKey = :APhone) AND (:ADay BETWEEN BegDate AND EndDate)

INTO :AOwner;

IF (:AOwner IS NULL) THEN EXIT;

EXECUTE PROCEDURE UslGetOwnerTax(:AOwner, :ATalksUsl, :ADay)

RETURNING_VALUES :ATax, :AProcNach, :ANalog;

IF (:ATax IS NULL) THEN EXIT;

APay = ATax*AHowLong*AProcNach/3000;

ACalculated = 1;

END ^

CREATE PROCEDURE TalksCallBilling (APhone INTEGER, ACallDate DATE, ACallTime INTEGER, AHowLong INTEGER)

RETURNS (ATalksPayCode INTEGER, ACalculated SMALLINT)

AS

DECLARE VARIABLE APay FLOAT;

DECLARE VARIABLE PayCode INTEGER;

DECLARE VARIABLE IsLgot SMALLINT;

DECLARE VARIABLE TTime INTEGER;

DECLARE VARIABLE LTime INTEGER;

BEGIN

EXECUTE PROCEDURE TalksGetPay(APhone, ACallDate, ACallTime, AHowLong)

RETURNING_VALUES :APay, :ACalculated, :IsLgot;

SELECT Code FROM TalksPay WHERE (Phone = :APhone) AND (CallDate = :ACallDate)

INTO PayCode;

IF (:ACalculated = 0) THEN EXIT;

IF (:IsLgot = 0) THEN BEGIN

TTime = AHowLong;

LTime = 0;

END

ELSE BEGIN

LTime = AHowLong;

TTime = 0;

END

IF (:PayCode IS NULL) THEN BEGIN

EXECUTE PROCEDURE PrGenTalksPay RETURNING_VALUES :PayCode;

INSERT INTO TalksPay (Code, Phone, CallDate, TotalSum, TotalFullTime, TotalLgotTime)

VALUES (:PayCode, :APhone, :ACallDate, :APay, :TTime, :LTime);

END

ELSE BEGIN

UPDATE TalksPay

SET TotalSum = TotalSum+:APay,

TotalFullTime = TotalFullTime+:TTime,

TotalLgotTime = TotalLgotTime+:LTime

WHERE Code = :PayCode;

END

END ^

CREATE PROCEDURE UslGetOwnerTax(AOwner INTEGER, AUsl INTEGER, ADate DATE)

RETURNS (ATax FLOAT,

AProcNach FLOAT,

ANalog FLOAT)

AS

DECLARE VARIABLE ACategory INTEGER;

BEGIN

SELECT Category FROM PhonesOwners

WHERE (PKey = :AOwner) AND (:ADate BETWEEN BegDate AND EndDate)

INTO :ACategory;

SELECT Tax, NachCoeff, Nalog FROM UslLgots

WHERE (Usl = :AUsl) AND (:ADate BETWEEN BegDate AND EndDate)

INTO :ATax, :AProcNach, :ANalog;

EXIT;

END

Приложение 2

Приложение 3

Исходные тексты коммуникационного сервиса

ServiceMain.c

Файл ServiceMain.c - Модуль инициализации и управления сервером.

/*************************************************************/

/* Main unit for Communication Service */

/* Copyright (c) 1997 by Malkov O.V. */

/* JSC "Svyazinform" RM */

/*************************************************************/

#include <windows.h>

#include "DoService.h"

#include "CommonConfig.h"

/* Globals */

SERVICE_STATUS ServiceStatus;

SERVICE_STATUS_HANDLE ServiceStatusHandle;

/* Function Prototypes */

void WINAPI ServiceStart (DWORD argc, LPTSTR *argv);

VOID WINAPI ServiceCtrlHandler (IN DWORD opcode);


Страница: