Subject | SP working intermittently |
---|---|
Author | Alan J Davies |
Post date | 2002-01-31T13:55:36Z |
Hi
I am using RC1 with W2000 and have no major problems with stored procedures
and use them a lot. This particular one has caused a problem, however, and
gives either the correct result, or no result at all depending on which
table is the target.
I guess the question is "Should I move single-row table processing out of
an SP into an update procedure within Delphi?"
This is a plastic mouldings production scheduling system, and previously,
they wanted the dates for production contained within each individual order
line. Now there has been commonality (and common-sense) and all dates are
the same, so I have created effectively a mirror of the date fields in a
Parameter Table - Paramfil - and this contains 1 record only.
This is a cut-down version of the SP
CREATE PROCEDURE SCHEDULES
(
NO_DAYS INTEGER, /* Calculate How many weeks to move data by
*/
FIRST_DATE TIMESTAMP /* New Effective Date */
)
AS
begin
Update Paramfil /* AJD note for this email --- used to be Update
OrdItems ------- */
Set Date_01=:First_Date,
Date_02=:First_Date+7, /* Increment each Schedule Period by 1 week
*/
Date_03=:First_Date+14,
Date_04=:First_Date+21,
Date_05=:First_Date+28,
Date_06=:First_Date+35,
Date_07=:First_Date+42,
Date_08=:First_Date+49,
Date_09=:First_Date+56,
Date_10=:First_Date+63,
Date_11=:First_Date+70,
Date_12=:First_Date+77,
LastUpDate=:First_Date; /* Set LastUpdate to New Effective Date */
/*.......
then moves on to next stage of processing
.......*/
end
The SP works with no reported errors, but THE ONLY DATA UPDATED is
LastUpDate - and this is correct
The previous version had "Update OrdItems" instead of "Update Paramfil"and
worked perfectly, updating all fields and all rows - and it still does if I
want to test things.
It is a weird thing! I can force updates within IBConsole passing the
required parameters, but from within Delphi it gives the result as
outlined.
Is there a problem with updating 1 record only?
The tables are as follows:-
/* Domain definitions */
CREATE DOMAIN ADDRESS AS CHAR(30)
default '';
CREATE DOMAIN DECIMALS_0 AS INTEGER
default 0;
CREATE DOMAIN DECIMALS_2 AS NUMERIC(9, 2)
default 0.00;
CREATE DOMAIN DECIMALS_3 AS NUMERIC(9, 3)
default 0;
/* Table: PARAMFIL, Owner: SYSDBA */
CREATE TABLE PARAMFIL
(
SALPERIOD DECIMALS_0,
CONAME ADDRESS,
COADD1 ADDRESS,
COADD2 ADDRESS,
COADD3 ADDRESS,
COADD4 ADDRESS,
COPOSTCODE CHAR(10),
COTEL CHAR(15),
COFAX CHAR(15),
COVATREG CHAR(15),
YEARSTART SMALLINT,
VATRATE0 DECIMALS_3,
VATRATE1 DECIMALS_3,
VATRATE2 DECIMALS_3,
VATRATE3 DECIMALS_3,
NEXT_INV DECIMALS_0,
NEXT_ORDER DECIMALS_0,
NEXT_DNOTE DECIMALS_0,
INVUPDATED CHAR(11),
SAL_PRBAL DECIMALS_2,
BATCH_NO CHAR(20),
TOPLINE SMALLINT,
DNOTE_NMBR DECIMALS_0,
WO_PRINTED DECIMALS_0,
INV_DATE TIMESTAMP,
SCHEDULES CHAR(10),
LASTUPDATE TIMESTAMP,
DATE_01 TIMESTAMP,
DATE_02 TIMESTAMP,
DATE_03 TIMESTAMP,
DATE_04 TIMESTAMP,
DATE_05 TIMESTAMP,
DATE_06 TIMESTAMP,
DATE_07 TIMESTAMP,
DATE_08 TIMESTAMP,
DATE_09 TIMESTAMP,
DATE_10 TIMESTAMP,
DATE_11 TIMESTAMP,
DATE_12 TIMESTAMP
);
/* Domain definitions */
CREATE DOMAIN ACCOUNT_NO AS CHAR(4)
default '' NOT NULL;
CREATE DOMAIN DECIMALS_0 AS INTEGER
default 0;
CREATE DOMAIN DECIMALS_2 AS NUMERIC(9, 2)
default 0.00;
CREATE DOMAIN DECIMALS_4 AS NUMERIC(9, 4)
default 0.0000;
CREATE DOMAIN DELIVERY_NO AS CHAR(10)
default '' NOT NULL;
CREATE DOMAIN DESCRIPTION AS CHAR(25)
default '';
CREATE DOMAIN INVOICE_NO AS CHAR(7)
default '';
CREATE DOMAIN ORDER_NO AS CHAR(8)
default '' NOT NULL;
CREATE DOMAIN PART_NO AS CHAR(16)
default '' NOT NULL;
CREATE DOMAIN REF AS CHAR(15)
default '' NOT NULL;
CREATE DOMAIN YES_NO AS CHAR(1)
default 'N'
check (value in ('Y','N')) NOT NULL;
/* Table: ORDITEMS, Owner: SYSDBA */
CREATE TABLE ORDITEMS
(
ACNO ACCOUNT_NO,
ORDNO ORDER_NO,
INV_NMBR INVOICE_NO,
PARTNO PART_NO,
DESC_1 DESCRIPTION,
DESC_2 DESCRIPTION,
DESC_3 DESCRIPTION,
SELL_PRICE DECIMALS_4,
UNIT CHAR(1),
DISCOUNT DECIMALS_2,
ORD_QTY DECIMALS_0,
INV_QTY DECIMALS_0,
DEL_QTY DECIMALS_0,
INV_DATE TIMESTAMP,
ORDERLINE DECIMALS_0,
REF REF,
DEL_DATE TIMESTAMP,
ORD_DATE TIMESTAMP,
DEL_MONTH SMALLINT,
COMPLETED YES_NO,
SCHEDULE YES_NO,
OVERDUE DECIMALS_0,
WEEK_01 DECIMALS_0,
WEEK_02 DECIMALS_0,
WEEK_03 DECIMALS_0,
WEEK_04 DECIMALS_0,
WEEK_05 DECIMALS_0,
WEEK_06 DECIMALS_0,
WEEK_07 DECIMALS_0,
WEEK_08 DECIMALS_0,
WEEK_09 DECIMALS_0,
WEEK_10 DECIMALS_0,
WEEK_11 DECIMALS_0,
WEEK_12 DECIMALS_0,
DATE_01 TIMESTAMP,
DATE_02 TIMESTAMP,
DATE_03 TIMESTAMP,
DATE_04 TIMESTAMP,
DATE_05 TIMESTAMP,
DATE_06 TIMESTAMP,
DATE_07 TIMESTAMP,
DATE_08 TIMESTAMP,
DATE_09 TIMESTAMP,
DATE_10 TIMESTAMP,
DATE_11 TIMESTAMP,
DATE_12 TIMESTAMP,
DNOTE_NMBR DELIVERY_NO,
DRAWING CHAR(15),
CRIT_DIM1 CHAR(15),
CRIT_DIM2 CHAR(15),
CRIT_DIM3 CHAR(15),
MATERIAL CHAR(15),
TOOL_NO CHAR(15),
NOTES1 CHAR(40),
NOTES2 CHAR(40),
NO_BOXES DECIMALS_0,
INVOICE_IT YES_NO,
INVOICED YES_NO,
DELIVERED DECIMALS_0,
EUROPRICE DECIMALS_2
);
I am using RC1 with W2000 and have no major problems with stored procedures
and use them a lot. This particular one has caused a problem, however, and
gives either the correct result, or no result at all depending on which
table is the target.
I guess the question is "Should I move single-row table processing out of
an SP into an update procedure within Delphi?"
This is a plastic mouldings production scheduling system, and previously,
they wanted the dates for production contained within each individual order
line. Now there has been commonality (and common-sense) and all dates are
the same, so I have created effectively a mirror of the date fields in a
Parameter Table - Paramfil - and this contains 1 record only.
This is a cut-down version of the SP
CREATE PROCEDURE SCHEDULES
(
NO_DAYS INTEGER, /* Calculate How many weeks to move data by
*/
FIRST_DATE TIMESTAMP /* New Effective Date */
)
AS
begin
Update Paramfil /* AJD note for this email --- used to be Update
OrdItems ------- */
Set Date_01=:First_Date,
Date_02=:First_Date+7, /* Increment each Schedule Period by 1 week
*/
Date_03=:First_Date+14,
Date_04=:First_Date+21,
Date_05=:First_Date+28,
Date_06=:First_Date+35,
Date_07=:First_Date+42,
Date_08=:First_Date+49,
Date_09=:First_Date+56,
Date_10=:First_Date+63,
Date_11=:First_Date+70,
Date_12=:First_Date+77,
LastUpDate=:First_Date; /* Set LastUpdate to New Effective Date */
/*.......
then moves on to next stage of processing
.......*/
end
The SP works with no reported errors, but THE ONLY DATA UPDATED is
LastUpDate - and this is correct
The previous version had "Update OrdItems" instead of "Update Paramfil"and
worked perfectly, updating all fields and all rows - and it still does if I
want to test things.
It is a weird thing! I can force updates within IBConsole passing the
required parameters, but from within Delphi it gives the result as
outlined.
Is there a problem with updating 1 record only?
The tables are as follows:-
/* Domain definitions */
CREATE DOMAIN ADDRESS AS CHAR(30)
default '';
CREATE DOMAIN DECIMALS_0 AS INTEGER
default 0;
CREATE DOMAIN DECIMALS_2 AS NUMERIC(9, 2)
default 0.00;
CREATE DOMAIN DECIMALS_3 AS NUMERIC(9, 3)
default 0;
/* Table: PARAMFIL, Owner: SYSDBA */
CREATE TABLE PARAMFIL
(
SALPERIOD DECIMALS_0,
CONAME ADDRESS,
COADD1 ADDRESS,
COADD2 ADDRESS,
COADD3 ADDRESS,
COADD4 ADDRESS,
COPOSTCODE CHAR(10),
COTEL CHAR(15),
COFAX CHAR(15),
COVATREG CHAR(15),
YEARSTART SMALLINT,
VATRATE0 DECIMALS_3,
VATRATE1 DECIMALS_3,
VATRATE2 DECIMALS_3,
VATRATE3 DECIMALS_3,
NEXT_INV DECIMALS_0,
NEXT_ORDER DECIMALS_0,
NEXT_DNOTE DECIMALS_0,
INVUPDATED CHAR(11),
SAL_PRBAL DECIMALS_2,
BATCH_NO CHAR(20),
TOPLINE SMALLINT,
DNOTE_NMBR DECIMALS_0,
WO_PRINTED DECIMALS_0,
INV_DATE TIMESTAMP,
SCHEDULES CHAR(10),
LASTUPDATE TIMESTAMP,
DATE_01 TIMESTAMP,
DATE_02 TIMESTAMP,
DATE_03 TIMESTAMP,
DATE_04 TIMESTAMP,
DATE_05 TIMESTAMP,
DATE_06 TIMESTAMP,
DATE_07 TIMESTAMP,
DATE_08 TIMESTAMP,
DATE_09 TIMESTAMP,
DATE_10 TIMESTAMP,
DATE_11 TIMESTAMP,
DATE_12 TIMESTAMP
);
/* Domain definitions */
CREATE DOMAIN ACCOUNT_NO AS CHAR(4)
default '' NOT NULL;
CREATE DOMAIN DECIMALS_0 AS INTEGER
default 0;
CREATE DOMAIN DECIMALS_2 AS NUMERIC(9, 2)
default 0.00;
CREATE DOMAIN DECIMALS_4 AS NUMERIC(9, 4)
default 0.0000;
CREATE DOMAIN DELIVERY_NO AS CHAR(10)
default '' NOT NULL;
CREATE DOMAIN DESCRIPTION AS CHAR(25)
default '';
CREATE DOMAIN INVOICE_NO AS CHAR(7)
default '';
CREATE DOMAIN ORDER_NO AS CHAR(8)
default '' NOT NULL;
CREATE DOMAIN PART_NO AS CHAR(16)
default '' NOT NULL;
CREATE DOMAIN REF AS CHAR(15)
default '' NOT NULL;
CREATE DOMAIN YES_NO AS CHAR(1)
default 'N'
check (value in ('Y','N')) NOT NULL;
/* Table: ORDITEMS, Owner: SYSDBA */
CREATE TABLE ORDITEMS
(
ACNO ACCOUNT_NO,
ORDNO ORDER_NO,
INV_NMBR INVOICE_NO,
PARTNO PART_NO,
DESC_1 DESCRIPTION,
DESC_2 DESCRIPTION,
DESC_3 DESCRIPTION,
SELL_PRICE DECIMALS_4,
UNIT CHAR(1),
DISCOUNT DECIMALS_2,
ORD_QTY DECIMALS_0,
INV_QTY DECIMALS_0,
DEL_QTY DECIMALS_0,
INV_DATE TIMESTAMP,
ORDERLINE DECIMALS_0,
REF REF,
DEL_DATE TIMESTAMP,
ORD_DATE TIMESTAMP,
DEL_MONTH SMALLINT,
COMPLETED YES_NO,
SCHEDULE YES_NO,
OVERDUE DECIMALS_0,
WEEK_01 DECIMALS_0,
WEEK_02 DECIMALS_0,
WEEK_03 DECIMALS_0,
WEEK_04 DECIMALS_0,
WEEK_05 DECIMALS_0,
WEEK_06 DECIMALS_0,
WEEK_07 DECIMALS_0,
WEEK_08 DECIMALS_0,
WEEK_09 DECIMALS_0,
WEEK_10 DECIMALS_0,
WEEK_11 DECIMALS_0,
WEEK_12 DECIMALS_0,
DATE_01 TIMESTAMP,
DATE_02 TIMESTAMP,
DATE_03 TIMESTAMP,
DATE_04 TIMESTAMP,
DATE_05 TIMESTAMP,
DATE_06 TIMESTAMP,
DATE_07 TIMESTAMP,
DATE_08 TIMESTAMP,
DATE_09 TIMESTAMP,
DATE_10 TIMESTAMP,
DATE_11 TIMESTAMP,
DATE_12 TIMESTAMP,
DNOTE_NMBR DELIVERY_NO,
DRAWING CHAR(15),
CRIT_DIM1 CHAR(15),
CRIT_DIM2 CHAR(15),
CRIT_DIM3 CHAR(15),
MATERIAL CHAR(15),
TOOL_NO CHAR(15),
NOTES1 CHAR(40),
NOTES2 CHAR(40),
NO_BOXES DECIMALS_0,
INVOICE_IT YES_NO,
INVOICED YES_NO,
DELIVERED DECIMALS_0,
EUROPRICE DECIMALS_2
);