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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:26:15+00:00 2026-06-15T10:26:15+00:00

I have a string as such: string query; query = insert or replace into

  • 0

I have a string as such:

string query;
query = "insert or replace into TABLEA (a,b,c) values (@a,\"@b\",\"@c\");";

that way i can insert strings into B and C with just a simple replace:

string instring("I have a 3\" gauge");
string instring2("I am looking for 1/8\" thickness");
Replace(&query, "@a", to_string(1));
Replace(&query, "@b", instring);
Replace(&query, "@c", instring2);

So now my query string is:

"insert or replace into TABLEA (a,b,c) values (1,\"I have a 3\" gauge\",\"I am looking for 1/8\" thickness\");";

SQLITE3 gets it and it looks like:

insert or replace into TABLEA (a,b,c) values (1,"I have a 3" gauge","I am looking for 1/8" thickness");

The issue is that the strings end prematurely. I tried to add additional escape characters but that wasnt seeming to work either.

Right now i am using sqlite3_exec() to carry out everything. Is there something else i should do? Does a prepared statement handle what i am trying to do?

Should i just try it with prepared_v2 and that might resolve issues?

How should i be approaching this?

  • 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-15T10:26:15+00:00Added an answer on June 15, 2026 at 10:26 am

    In SQL, strings use single quotes, and are escaped by using two single quotes. (Double quotes are accepted for compatibility with MySQL, but should not be used.)

    Your query should look like this:

    INSERT OR REPLACE INTO TableA(a, b, c)
    VALUES (1, 'I have a 3" gauge', 'I am looking for 3/8" thickness')
    

    or like this:

    INSERT OR REPLACE INTO TableA(a, b, c)
    VALUES (1, "I have a 3"" gauge", "I am looking for 3/8"" thickness")
    

    However, to avoid string formatting problems, it is recommended to use parameters.
    This is how it works with direct SQLite function calls (wrappers might work differently):

    const char *sql = "INSERT OR REPLACE INTO TableA(a, b, c) VALUES (1, ?, ?)";
    sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
    sqlite3_bind_text(stmt, 1, "I have a 3\" gauge", -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(stmt, 2, "I am looking for 3/8\" thickness", -1, SQLITE_TRANSIENT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string such as big bad dog, how can I get an
I have the following code that creates my table. I insert data into it
I have a query string such as this: file.php?search=keyword+here&genre1=1&genre4=1&genre19=1&genre181&director=436&actor=347&search_rating=3 I need to extract all
If I have a string such as lotsofcrapsomethingimportantmoreotherstuff is it possible to get Regex
Lets say a have a string such as this one: string txt = Lore
I have an xml string such as this: <s:Envelope xmlns:s=http://schemas.xmlsoap.org/soap/envelope/> <s:Body> <ExecuteResponse xmlns=http://schemas.microsoft.com/xrm/2011/Contracts/Services> <ExecuteResult
I have an input string such as x=y|a=b|c=10 etc which gets converted to dynamic
hey I have a string as such: 357902||190||RUE RACHELLE||ST|||LES CÈDRES|J7T1J9|QC I wish to take
I have a bunch of records with dates formatted as a string such as
I have a string read from another source such as \b\bfoo\bx. In this case,

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.