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 8246435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:30:18+00:00 2026-06-07T22:30:18+00:00

I can’t seem to access an SQLite database table. When trying to do it,

  • 0

I can’t seem to access an SQLite database table. When trying to do it, it says table does not exist. I’ve searched for people with same problems, double checked my code but I can’t find the problem.

Some definitions:

private static final String TABLE_PRODUTOS = "produtos";
private static final String TABLE_CONCORRENTES = "concorrentes";
private static final String TABLE_VENDE = "vende";

private static final String KEY_ID_PROD = "_id";
private static final String KEY_NOME_PROD = "nome_prod";
private static final String KEY_CODBAR_PROD = "codbar_prod";
private static final String KEY_ID_CONC = "_id";
private static final String KEY_NOME_CONC = "nome_conc";
private static final String KEY_VENDE_PROD_ID = "prod_id";
private static final String KEY_VENDE_CONC_ID = "conc_id";
private static final String KEY_VENDE_PRECO = "preco";
private static final String KEY_VENDE_OFERTA = "oferta";

Here’s the code for creating DB:

public void onCreate(SQLiteDatabase db) {

    Log.i("DB","CREATING_DB");

    String CREATE_TABLE_PRODUTOS = "CREATE TABLE " + TABLE_PRODUTOS + "("
            + KEY_ID_PROD + " INTEGER PRIMARY KEY," + KEY_NOME_PROD + " TEXT," + KEY_CODBAR_PROD + " INTEGER" + ")";
    String CREATE_TABLE_CONCORRENTES = "CREATE TABLE " + TABLE_CONCORRENTES
            + "(" + KEY_ID_CONC + " INTEGER PRIMARY KEY," + KEY_NOME_CONC + " TEXT" + ")";
    String CREATE_TABLE_VENDE = "CREATE TABLE " + TABLE_VENDE + "("
            + KEY_VENDE_PROD_ID + " INTEGER," + KEY_VENDE_CONC_ID
            + " INTEGER," + KEY_VENDE_PRECO + " REAL,"
            + KEY_VENDE_OFERTA + "INTEGER" + ")";

    db.execSQL(CREATE_TABLE_PRODUTOS);
    db.execSQL(CREATE_TABLE_CONCORRENTES);
    db.execSQL(CREATE_TABLE_VENDE);
}

Here’s the code for inserting/updating:

public void addVenda_(Venda p_) {
    //bd is my SQLiteDatabase
    if (bd != null && bd.isOpen()) {
    //Log.i("CLOSING_DB", "addVenda");
        bd.close();
    }
    bd = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_VENDE_PRECO, p_.preco); // Contact Name
    values.put(KEY_VENDE_OFERTA, p_.oferta); // Contact Name

    if(getVenda_(p_)){ //getVenda() returns true if row with KEY_VENDE_PROD_ID and KEY_VENDE_CONC_ID already exist
        //Log.i("UPDATE","conc: "+p_.id_conc+" prod: "+p_.id_prod+" preço: "+p_.preco+" oferta: "+p_.oferta);
        bd.update(TABLE_VENDE, values, KEY_VENDE_PROD_ID + " = ? AND "+KEY_VENDE_CONC_ID + " = ?", new String[]{ "" + p_.id_prod, "" + p_.id_conc });
        //bd.rawQuery("update "+TABLE_VENDE+" SET "+KEY_VENDE_PRECO+"="+p_.preco+", "+KEY_VENDE_OFERTA+"="+p_.oferta+" WHERE "+KEY_VENDE_PROD_ID+"="+p_.id_prod+" AND "+KEY_VENDE_CONC_ID+"="+p_.id_conc, null);
    }
    else{
        //Log.i("INSERT","conc: "+p_.id_conc+" prod: "+p_.id_prod+" preço: "+p_.preco+" oferta: "+p_.oferta);
        values.put(KEY_VENDE_PROD_ID, p_.id_prod);
        values.put(KEY_VENDE_CONC_ID, p_.id_conc);
        bd.insert(TABLE_VENDE, null, values);
        //String sql = "INSERT INTO vende(prod_id, conc_id, preco, oferta) values ("+ p_.id_prod+","+p_.id_conc+","+p_.preco+","+p_.oferta +");";
        //bd.rawQuery(sql, null);

    }

}

And here’s the error I get when trying to insert some values on TABLE_VENDE:

sqlite returned: error code = 1, msg = table vende has no column named oferta
Error inserting oferta=0 conc_id=1 preco=1.42 prod_id=3
android.database.sqlite.SQLiteException: table vende has no column named oferta: ,  while compiling: INSERT INTO vende(oferta, conc_id, preco, prod_id) VALUES(?, ?, ?, ?);

I’ve no problem accessing the other two tables (PRODUTOS and CONCORRENTES), just table VENDE.
So my questions are:
Where did “oferta: ” (3rd error) came from?
Am I creating/accessing my DB wrong?
This couldn’t be SQLite’s fault, could it? (probably not..)

Thanks in advance

P.S.: it’s my first question, so forgive me if I mess something up…

  • 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-06-07T22:30:20+00:00Added an answer on June 7, 2026 at 10:30 pm
    KEY_VENDE_OFERTA + "INTEGER"
    

    Leave a space between the key and the word INTEGER.

    KEY_VENDE_OFERTA + " INTEGER"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we close all known/unknown connections to database with the code? I'm using Access
Can I order my users in the database, so I don't have to say
Can we change the color of the divider? Apple documentations says, that we can
Can someone tell me how does the imdb app manage to play trailers on
Can't seem to figure out what's wrong with the simple getJSON call below. It's
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can we use the asterisk character * for a search action in SQL database?
Can anyone help me trying to find out why this doesn't work. The brushes
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Does anyone know how can I replace this 2 symbol below from the string

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.