Subject | Re: [firebird-support] SQL help |
---|---|
Author | Robert martin |
Post date | 2008-08-20T02:47:17Z |
Hi cancel that. Sorry brain on Holiday :)
My SQL is
DELETE
FROM StockLevel sl
WHERE NOT EXISTS (SELECT bs.SendRef FROM BranchSend bs WHERE
bs.SendTable = 'STOCKLEVEL' AND bs.PkRef = sl.StocklevelRef AND
bs.TransferConfirmed = 'F')
Robert martin wrote:
My SQL is
DELETE
FROM StockLevel sl
WHERE NOT EXISTS (SELECT bs.SendRef FROM BranchSend bs WHERE
bs.SendTable = 'STOCKLEVEL' AND bs.PkRef = sl.StocklevelRef AND
bs.TransferConfirmed = 'F')
Robert martin wrote:
> 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
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>
>
>