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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:46:13+00:00 2026-05-24T13:46:13+00:00

I was originally looking for an INSERT OR UPDATE ability in SQLite but searches

  • 0

I was originally looking for an INSERT OR UPDATE ability in SQLite but searches showed similar question askers being pointed to using INSERT OR REPLACE.

I’m obviously misunderstanding how this works and obviously I can’t use WHERE as I’m getting the following SQLiteException…

08-12 01:38:22.973: ERROR/AndroidRuntime(29242): FATAL EXCEPTION: main
08-12 01:38:22.973: ERROR/AndroidRuntime(29242): android.database.sqlite.SQLiteException:
                        near "WHERE":
                            syntax error: 
                                INSERT OR REPLACE INTO SERVERS (
                                    server_name,
                                    service_uri_mobile,
                                    service_uri_wifi,
                                    valid_ssids,
                                    username,password
                                ) VALUES (
                                    'Default',
                                    'http://myserver.com:8790/',
                                    'http://192.168.1.1:8790/',
                                    '[]',
                                    'admin',
                                    'password')
                                WHERE server_name='Default'

The SQL string I’m using is as follows…

String UpdateString = "INSERT OR REPLACE INTO SERVERS " +
    "(server_name,service_uri_mobile,service_uri_wifi,valid_ssids,username,password) VALUES ('" +
    locater.getServerName() + "','" +
    locater.getServiceUriMobile().toString() + "','" +
    locater.getServiceUriWifi().toString() + "','" +
    locater.getValidSsids().toString() + "','" +
    locater.getUsername() + "','" +
    locater.getPassword() + "') " +
    "WHERE server_name='" + locater.getServerName() + "'";

I’ve looked at this page explaining REPLACE but don’t quite understand it. How would I re-write the above SQLite command and have it only try to replace the record where the server_name matches (i.e., the equivalent of a WHERE clause)?

  • 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-24T13:46:13+00:00Added an answer on May 24, 2026 at 1:46 pm

    Looking at the documentation (and mirroring the comments below the question), REPLACE should be used when UPDATEing (or in other words changing) columns that are UNIQUE. To wit:

    REPLACE

    When a UNIQUE constraint violation occurs, the REPLACE algorithm
    deletes pre-existing rows that are causing the constraint violation
    prior to inserting or updating the current row and the command
    continues executing normally.

    http://sqlite.org/lang_conflict.html

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

Sidebar

Related Questions

I originally posted this question looking for an answer with using python, got some
UPDATE : My original question wasn't quite clear. I'm looking for the name of
I am looking to parse INSERT and UPDATE MySQL SQL queries in PHP to
I am attempting to insert many records using T-SQL's MERGE statement, but my query
I was originally looking for a basic tutorial on how to get started using
Original Question I am looking for a function that attempts to quantify how distant
Originally posted on Server Fault , where it was suggested this question might better
This is similar to a recent question. I will be maintaining sorted a list
I used the code from the following question to insert a YouTube video into
I'm looking for a culturally-sensitive way to properly insert a noun into a sentence

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.