Closed Thread
Results 1 to 3 of 3

Thread: How to implement LIFO and FIFO method

  1. #1
    anantabd is offline Newbie
    Join Date
    Oct 2007
    Posts
    1
    Rep Power
    0

    Lightbulb How to implement LIFO and FIFO method

    Dear all i am using ms access database and VB in front end. How i will implement FIFO and LIFO method in inventory. Please give me the database structure and logical process.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    kkelly's Avatar
    kkelly is offline Learning Programmer
    Join Date
    Sep 2007
    Posts
    50
    Rep Power
    0
    If you use an Autonumber field as the primary key in a table you could retrieve the first and last record either with the first and last aggregate functions or the min and max functions on the primary key. Like:
    Code:
    SELECT FIRST(ID)
    FROM myTable
    ORDER BY FIRST(ID);
    or
    Code:
    SELECT MIN(ID)
    FROM myTable;
    If your database requires a time/date stamp then the min and max functions on the time/date field would work. Like:
    Code:
    SELECT MIN(DateTimeField)
    FROM myTable;
    Note that the above SQL only returns the value of a single field.

    Another way you could write the SQL to return more than just a single field is with the TOP function. To get the first record:
    Code:
    SELECT TOP 1 *
    FROM myTable
    ORDER BY ID;
    To get the last record:
    Code:
    SELECT TOP 1 *
    FROM myTable
    ORDER BY DateTimeField DESC;
    You could make two queries. One called GetFirstAsset and one call GetLastAsset, then execute these queries (Stored Procedures) from the Visual Basic code.

  4. #3
    kkelly's Avatar
    kkelly is offline Learning Programmer
    Join Date
    Sep 2007
    Posts
    50
    Rep Power
    0
    Also, I just wanted to mention that it is best to avoid compound SQL statements. A well structured database really has no need for them, and they can be prone to SQL injection.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FIFO memory buffer
    By eagle123 in forum C# Programming
    Replies: 1
    Last Post: 05-17-2010, 05:44 AM
  2. Using an inherited method in another class' method
    By ZipOnTrousers in forum Java Help
    Replies: 1
    Last Post: 11-13-2009, 09:39 AM
  3. Encrypt method (from decrypt method)
    By mmmmmm in forum C# Programming
    Replies: 2
    Last Post: 09-19-2009, 06:18 AM
  4. Help with FIFO QUEUE
    By ghost305 in forum C and C++
    Replies: 6
    Last Post: 04-03-2009, 04:08 AM
  5. FIFO For Batch Processing?
    By TcM in forum Programming Theory
    Replies: 2
    Last Post: 07-30-2008, 10:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts