Subject | SQL help |
---|---|
Author | Robert martin |
Post date | 2008-08-20T02:28Z |
Hi
I have a situation where I have two tables
CREATE TABLE BranchSend
/* One record for each item to sent to HO, deleted once all confirmed */
(
SendRef BigInt NOT NULL,
RegionRef BigInt NOT NULL,
SendTable VarChar(25), /* Table Name */
PkRef BigInt,
PkRef2 BigInt,
PkRef3 BigInt,
TransferConfirmed D_Boolean,
CONSTRAINT BranchSend_PK PRIMARY KEY (SendRef)
)
and
Table two which as a PK (StockLevelRef)
CREATE TABLE Stocklevel
(
StockLevelRef Numeric(11) NOT NULL,
.....
)
The Branch send table has one record for each branch to send the
Stocklevel record data to. As it is received the transferconfirmed
field is set to 'T'. I want to write an SQL that deletes all StockLevel
records where all branchSend records have transferconfirmed = 'T'.
PkRef is a FK to the StockLevelRef in StockLevel table. The Stock Level
table has an on delete query that will clear the BranchSend table.
I know this should be simple but all my SQLs are turning out slow /
complex. Any hints?
Thanks
Rob
I have a situation where I have two tables
CREATE TABLE BranchSend
/* One record for each item to sent to HO, deleted once all confirmed */
(
SendRef BigInt NOT NULL,
RegionRef BigInt NOT NULL,
SendTable VarChar(25), /* Table Name */
PkRef BigInt,
PkRef2 BigInt,
PkRef3 BigInt,
TransferConfirmed D_Boolean,
CONSTRAINT BranchSend_PK PRIMARY KEY (SendRef)
)
and
Table two which as a PK (StockLevelRef)
CREATE TABLE Stocklevel
(
StockLevelRef Numeric(11) NOT NULL,
.....
)
The Branch send table has one record for each branch to send the
Stocklevel record data to. As it is received the transferconfirmed
field is set to 'T'. I want to write an SQL that deletes all StockLevel
records where all branchSend records have transferconfirmed = 'T'.
PkRef is a FK to the StockLevelRef in StockLevel table. The Stock Level
table has an on delete query that will clear the BranchSend table.
I know this should be simple but all my SQLs are turning out slow /
complex. Any hints?
Thanks
Rob