d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Database Design Question
Add Reply New Topic New Poll
Member
Posts: 5,269
Joined: Oct 18 2006
Gold: 21,400.00
Feb 10 2014 12:19am
Current setup:
I have a table "Items" with the schema SKU,isAvaiable. I have a web scraper that pulls availability of those SKUs from the wholesaler every night and changes the boolean column isAvailable to true or false.

Problem:
My inventory completely relies on the wholesaler. I know the wholesaler has errors they refuse to fix, so I need to manually change the IsAvailable boolean. I do not want to edit the web scraper.

My Solution:
Add a new column "AvailableOveride". Add a trigger to not allow changes to IsAvailable if AvailableOveride is not null. Also add a rule to make IsAvailable = AvailableOveride when AvailableOveride is set. That way AvailableOveride could be null and do nothing. AvailableOveride could be true to show always in stock. Or AvailableOveride could be false to show always out of stock.


Is this a horrible solution? Is there a better way? I'm not a huge trigger pro, but this should be simple to write.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 10 2014 12:24am
i must have missed something. what's the point of the trigger at all? just change your SELECT for when you read the data.

eg: select sku, nvl(AvailableOveride, IsAvailable) from items;

you can also wrap this in a view for convenience

This post was edited by carteblanche on Feb 10 2014 12:25am
Member
Posts: 28,331
Joined: Jun 9 2007
Gold: 11,700.00
Feb 10 2014 12:27am
what information on those errors do you have?
how do you get an update on those stock items where the errors are?
Member
Posts: 5,269
Joined: Oct 18 2006
Gold: 21,400.00
Feb 10 2014 12:09pm
Quote (brmv @ Feb 9 2014 11:27pm)
what information on those errors do you have?
how do you get an update on those stock items where the errors are?


The errors are them saying something is in stock, but they don't send it every week so I know they don't have it. Also, we may have 5 of them, but they are out of stock (not their error, but we need to say we have it)

Quote (carteblanche @ Feb 9 2014 11:24pm)
i must have missed something. what's the point of the trigger at all? just change your SELECT for when you read the data.

eg: select sku, nvl(AvailableOveride, IsAvailable) from items;

you can also wrap this in a view for convenience


Forgot a crucial piece of the puzzle. I also have a program at the end that pulls from the db and sends to out. I do not want to change this program either.


My other thought would be to run a program after the web scaper and have that program change IsAvailable to the correct values. I decided this option is less appealing because the data is incorrect for a small window of time.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 10 2014 05:40pm
Quote (xandumx @ Feb 10 2014 01:09pm)
The errors are them saying something is in stock, but they don't send it every week so I know they don't have it.  Also, we may have 5 of them, but they are out of stock (not their error, but we need to say we have it)



Forgot a crucial piece of the puzzle.  I also have a program at the end that pulls from the db and sends to out.  I do not want to change this program either.


My other thought would be to run a program after the web scaper and have that program change IsAvailable to the correct values.  I decided this option is less appealing because the data is incorrect for a small window of time.


so why don't you rename the table to something else, then use a view whose name is the table that's getting selected by this program?
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll