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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:50:10+00:00 2026-05-28T14:50:10+00:00

Given: an sqlite database with a table T the table T contains 10 columns

  • 0

Given:

  • an sqlite database with a table T
  • the table T contains 10 columns – C0, C1 … C9.
  • an sqlite3_stmt pointer corresponding to select C3,C2 from T

OK, so I can fetch the selected column values using the sqlite3_column_XXX family of methods (http://www.sqlite.org/capi3ref.html#sqlite3_column_blob), like this:

sqlite3_stmt *s;
sqlite3_prepare_v2(db, query, sizeof(query), &s, NULL);
while ((result = sqlite3_step(s)) == SQLITE_ROW)
{
  const char *v3 = reinterpret_cast<const char *>(sqlite3_column_text(s, 0);
  const char *v2 = reinterpret_cast<const char *>(sqlite3_column_text(s, 1);
}

What I need is the real index of the selected columns, i.e. 3 for v3 and 2 for v2.

Motivation: I want to be able to parse the returned string value into the real column type. Indeed, my schema says that c3 is a datetime, which sqlite treats as TEXT. So, sqlite3_column_type(s, 0) returns SQLITE3_TEXT, but the table metadata (available from pragma table_info(T)) retains the string datetime, which is the intended type of the column. Knowing it, I can parse the returned string into the respective unix time since the epoch, for instance.

But how can I map the query column index to the table column index:

  • query column 0 -> table column 3
  • query column 1 -> table column 2

Thanks.

  • 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-28T14:50:11+00:00Added an answer on May 28, 2026 at 2:50 pm

    You could use the sqlite C function sqlite3_column_decltype to get the declared column data type from the result stmt? It doesn’t specifically answer your question (getting the original column’s index), but could be an alternative way to achieve what you need?

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

Sidebar

Related Questions

How can I edit a particular record in a SQLite table given, Database Name
When I'm trying to fetch data from the sqlite database table the NSArray has
I have a SQLite database in Android with a table that contains longitude, latitude
I am using sqlite database for storing data. One of the table contains fields
I've a table in my database (sqlite) called books which was automatically given an
I would like to optimize this query using SQLite 3. SELECT id FROM Table
If I get records from my SQLite database's master table like this: $database =
I'm using SQLite to maintain a database which contains, among other things, a table
In SQLite, given this database schema CREATE TABLE observations ( src TEXT, dest TEXT,
My setup: I have a sqlite database from which I populate a NSMutableArray of

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.