Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:51:11+00:00 2026-05-26T01:51:11+00:00

I have to insert three tables independently .. but if first table is inserted

  • 0

I have to insert three tables independently .. but if first table is inserted successfully, then only 2nd table is needed to insert the data. If any error occurs while inserting the 2nd table, then it needs to rollback 1st table’s last inserted one, likewise the 3rd table also :

I did currently like this :

   DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(RetailerOrderActivity.this);
dbAdapter.openDataBase();
   for (Map.Entry<String, MyProduct> entry : myProductMap.entrySet()) {
                    String key = entry.getKey();
                    MyProduct myProduct = entry.getValue();

                    ContentValues initialValue = new ContentValues();
                    initialValue.put("BusinessUnit",strBusinessUnit);
                    initialValue.put("ExecutiveCode",strExecutive);

                    if(salesType.equalsIgnoreCase("I")){
                        initialValue.put("InvoiceNo",transactionControl.getNextInvoiceNo());
                        initialValue.put("SalesCategory",transactionControl.getInvoicePrefix());

                    }else if(salesType.equalsIgnoreCase("O")){
                        initialValue.put("InvoiceNo",transactionControl.getNextOrderNo());
                        initialValue.put("SalesCategory",transactionControl.getOrderPrefix());
                    }
                    initialValue.put("ProductCode",key);
                    initialValue.put("LineNumber",i);
                    initialValue.put("Qty",myProduct.getQty());
                    initialValue.put("UnitPrice",myProduct.getPrice());
                    initialValue.put("DiscountValue",myProduct.getDisValue());
                    initialValue.put("DiscountQty",myProduct.getDisQty());


                    long nl = dbAdapter.insertRecordsInDB("WMInvoiceLine", null, initialValue); 

                   //update WMStockRecord table
                    if(nl != -1 ){

                        if((salesType.equalsIgnoreCase("I") && orderStockValidation.equals("1")) || (salesType.equalsIgnoreCase("O") && orderStockValidation.equals("1"))){
                            ContentValues stockValue = new ContentValues();
                            if(myProduct.getAvailableQuantity() < myProduct.getQty()){
                                stockValue.put("Stock",0.00);
                            }else{
                                double tmp = myProduct.getAvailableQuantity() - myProduct.getQty();
                                stockValue.put("Stock",tmp);
                            }
                            stockValue.put("LastUpdatedOn",strDate);
                            stockValue.put("LastUpdatedBy",strExecutive);
                            stockValue.put("ActiveStatus","1");

                            String whereCon = "BusinessUnit = '"+ strBusinessUnit +"' WarehouseCode = '"+defaultSalesWarehouse + "' LocationCode = '" + defaultSalesLocation + "' ProductCode = '" + key + "'";
                            long stock = dbAdapter.updateRecordsInDB("WMStockRecord", stockValue, whereCon, null);
                      }

                        //TO-DO WMInvoicekit
                    }

                    i++;
                   insertStatus = true;
                   lineStatus = true;
                }

but Here is not transaction not available. How we can implement the transaction facility? I am using DBAdapter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:51:12+00:00Added an answer on May 26, 2026 at 1:51 am

    You have to set transaction and you have to commit that transaction if it succeed else you have to cancel that transaction.

    for more information you can refer this answer

    Transaction in sqlite

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an entity context that includes three tables. The first is a table
I have a databse with three tables. The first table is something like: _id
I have an INSERT query that is pulling data from two tables and inserting
I have three tables. Table (t), a resource in my system. It has a
I have three tables [USER] --Master user table [KEYWORD] --Master keyword table [USER_KEYWORD] --[USER]-[KEYWORD]
I have three tables and three stored procedures respectively to insert/update records in these
can a single view be used to insert data into three tables simultaneously. am
I have three tables in my database. A users table, StoreA and StoreB StoreA
Using POSIX threads & C++, I have an Insert operation which can only be
I have three tables STUDENT, DEPARTMENT and COURSE in a University database... STUDENT has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.