473,388 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to calculate Stock information?

Hello Sir

I have Error with the following tables one is [INCOME] And one is[Stock].

Income table Columns.
Date ItemID ItemType Amount DriverName TruckNo
---------------------
Stock Table columns.
Itemid ItemName ItemType Amount
-----------------------------------
Now when i enter record to income table
and income itemid not = to stock itemid then
itemid,itemName,ItemType,Amount Should be insert to the Stock table.
elsif income itemid = to stock itemID then
the stock the stock table should be update.
it means that income table amount Should Plus To Stock table amount
stock.amoutn + income.amount.
i try the following code but it does not work.
---------------------------------
Expand|Select|Wrap|Line Numbers
  1. declare
  2. begin
  3. if :income.itemid<>:stock.itemid then
  4. insert into stock(itemid,itemname,itemtype,amount)
  5. values(:income.itemid,:income.itemname,:income.itemtype,:income.amount);
  6.         elsif :income.itemid=:stock.itemid then
  7.         update stock set amount=amount+:income.amount where itemid=:stock.itemid;
  8.     commit_form;
  9.         go_block('Income');
  10.     execute_query;
  11. go_block('stock');
  12. Execute_query;
  13.     end if;
  14. end; 
-----------------------------------
Please sir give me the Exact Answer
Thank you in advance.
Nov 12 '10 #1
5 1894
debasisdas
8,127 Expert 4TB
How the above two mentioned tables are linked ?
Nov 12 '10 #2
They are not linked,Send me Passible answer Plz.
Nov 13 '10 #3
amitpatel66
2,367 Expert 2GB
This will not work because you are checking the current income.item_id with current stock.item_id.

You will need to query the stocks table to check if the entry for a particular item_id occurs in stocks table, if not then insert else update.
Nov 15 '10 #4
ok send me the complete sulotion of this problem, I means what is the possible way to solve the problem thanks
Nov 16 '10 #5
amitpatel66
2,367 Expert 2GB
Here is the pseudo code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT count(*) into v_cnt from stock where item_id = :income.item_id;
  3.  
  4. IF v_cnt > 0 then
  5.  
  6. update stock
  7.  
  8. else
  9.  
  10. insert into stock values.....
  11.  
  12.  
I hope this helps.
Nov 16 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marion Slaughter | last post by:
----FA48570F00BB51C Content-Type: text/html; charset="iso-35B2-E" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>...
7
by: simon | last post by:
Hi I know this has been done to death....but obviously at some point in the dim and distant past! I wish to program a retail database for my shop, I have trawled many forums and I only manage...
5
by: Roy Gourgi | last post by:
Hi, I am used to working in Visual FoxPro and I would like to be able to create a database and store and retrieve information from it. What is the simplest way to do it and what should I be...
2
by: Hank | last post by:
Hello, Does anyone have a formula for calculating the number of days a stock was owned? Of course its real easy if you buy 100 shares on April 1 and sell 100 shares on July 1 but what about...
7
by: Donlingerfelt | last post by:
I would like to download stock quotes from the web, store them, do calculations and sort the results. However I am fairly new and don't have a clue how to parse the results of a web page download....
1
by: Louise | last post by:
I am creating a database that will provide a report that tells the user how many units of each part number is on hand. At present I have a table that contains present stock, and all the present...
1
by: asmusdk | last post by:
I am working on creating a stock management database for a small company. The company receives the merchandise from a handful of suppliers and stocks it before it is sent to the customers –...
1
by: tellme | last post by:
hi...i've one project and need to complete insteadly.I need to develop one system to record a stock.My problem is when we insert new stock,the quantity of the stock in the database will be increase...
2
by: kabradley | last post by:
Hello all! I have a logic problem that I have been working on for quite some time now and can't seem to fix. Hopefully someone can shed some light on the subject. I am starting to work on an...
4
by: student2 | last post by:
Hi :-) I'm using Ms Access 2003 to create a DB for my school project and I need to accomplish the following:- * Calculate balances for stock (inclusive of sales and replenishment to stock) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.