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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:02:20+00:00 2026-06-18T06:02:20+00:00

In my database there is table name Projtable. Project name contain 4 fields. 1.

  • 0

In my database there is table name “Projtable”. Project name contain 4 fields.
1. projct id = autoincrement (primary key)
2. projctname = varchar
3. projct_detail = varchar
4. order_id = int

now my insertion of projctname and projct_detail works perfectly.
I have to find maximum value of column for orderid.
How can i find this?

My code is :

-(void)insertProject:(Project *)projobj
{
//    next_orderid = next_orderid + 1;
//    projobj.orderid = next_orderid;

    NSLog(@" insert:: %@, %@, %d", projobj.outcome, projobj.projctname, projobj.orderid);
     sqlite3 *database;
    if (sqlite3_open([self.databasePath UTF8String] , &database) == SQLITE_OK)
    {
        const char *sql = "INSERT INTO proj_table (projctname, outcome, orderid) VALUES (?,?,?)";
        sqlite3_stmt *statement;
        statement = [self PrepareStatement:sql];

        int a1 = sqlite3_bind_text(statement, 1, [projobj.projctname UTF8String], -1, SQLITE_TRANSIENT);
        int a2 =  sqlite3_bind_text(statement, 2, [projobj.outcome UTF8String], -1, SQLITE_TRANSIENT);
       int a3= sqlite3_column_int( statement, 3);
        NSLog(@" integer :== %d",a3);
       // int a3 = sqlite3_bind_int(statement, 3, projobj.orderid);
            if (statement)
        {
            if (a1 != SQLITE_OK || a2 != SQLITE_OK || a3 != SQLITE_OK)
            {
                sqlite3_finalize(statement);
                return;
            }
            sqlite3_step(statement);
        }
        sqlite3_finalize(statement);
    }
}

result is 0

  • 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-18T06:02:21+00:00Added an answer on June 18, 2026 at 6:02 am

    Use the SQL select statement

    Select max(orderid) from proj_table;
    

    you can then use the integer+1 as your next value.

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

Sidebar

Related Questions

is there a standard or best practice with database table names and fields in
To get database table name on Entity framework 4.0 I do: ObjectSetInstance.EntitySet.ToString() Is there
I have the following database structure: CREATE TABLE LookupTable ( PK UNIQUEIDENTIFIER PRIMARY KEY,
Assume that in a database table there is a non-key column called RECORD_ID which
I have a database created with table name Accounts There are THREE columns. One
In our database there is a table which is created with ANSI_NULLS OFF .
In a MySQL (5.1) database table there is data that represents: how long a
There is a table employee in the database abc_db at abc@localhost(server) and there is
I have a database in which there is a user table & how many
I'm looking through my organization's database, and there is a table called dbo.Account_Alerts, and

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.