#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0

    Unhappy Help me simulate the ordering of data while inserting into a table from another table


    Hi,
    I have a problem with inserting data into SQL tables. So far, everything that is entered into my form does get inserted correctly, meaning all data is added successfully to their respective columns. However, sometimes when I insert another set of data, it appears on top of the preceding data. The Third column in my table is called 'Receipt no', is coded to increment each time by one.

    Example:
    (first entry)

    Bank_code Cheque_no Receipt no amt_receipted total_cheque
    1 100 100


    (next entry) : 2 inserted on top of 1

    Bank_code Cheque_no Receipt no amt_receipted total_cheque
    2 200 300
    1 100 <NULL>


    (next entry again)
    Bank_code Cheque_no Receipt no amt_receipted total_cheque
    2 200 <NULL>
    1 100 <NULL>
    3 150 <NULL> - (3 rd row inserted below 1)

    This particular program has a certain logic whereby, whenever a record is inserted, the total_cheque value of the previous record present , becomes <NULL> and the gives the total value of the cheques in the current record total_cheque column.

    But since the order is changed, it gives a <NULL> value for the total_cheque which should not happen.

    Can anyone kindly help me in simulating this incorrect order so as to make sure, the NULL value occurence is only due to this incorrect ordering?
    or
    can there be any other reason that makes this happen??

    Thanks in advance.
    Last edited by s_vidya03; November 14th, 2003 at 04:53 AM.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    21
    Rep Power
    0
    try adding an index to the table
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0
    Thanks for the suggestion.

    we have decided to use Indexing to solve the problem.

IMN logo majestic logo threadwatch logo seochat tools logo