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

  • Home
  • SEARCH
  • 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 8508143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:04:39+00:00 2026-06-11T03:04:39+00:00

I want to insert multiple rows with a single insert statement. The following code

  • 0

I want to insert multiple rows with a single insert statement.

The following code inserts one row, and works fine:

create temp table mytmptable
(external_id char(10),
int_id integer,
cost_amount decimal(10,2)
) with no log;

insert into mytmptable values 
('7662', 232, 297.26);

select * from mytmptable;

I’ve tried changing the insert to this, but it gives a syntax error:

insert into mytmptable values 
('7662', 232, 297.26),
('7662', 232, 297.26);

Is there a way to get it working, or do I need to run many inserts instead?

  • 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-11T03:04:41+00:00Added an answer on June 11, 2026 at 3:04 am

    As you found, you can’t use multiple lists of values in a single INSERT statement with Informix.

    The simplest solution is to use multiple INSERT statements each with a single list of values.

    If you’re using an API such as ESQL/C and you are concerned about performance, then you can create an INSERT cursor and use that repeatedly. This saves up the inserts until a buffer is full, or you flush or close the cursor:

    $ PREPARE p FROM "INSERT INTO mytmptable VALUES(?, ?, ?)";
    $ DECLARE c CURSOR FOR p;
    $ OPEN c;
    while (...there's more data to process...)
    {
        $PUT c USING :v1, :v2, :v3;
    }
    $ CLOSE c;
    

    The variables v1, v2, v3 are host variables to hold the string and numbers to be inserted.
    (You can optionally use $ FLUSH c; in the loop if you wish.) Because this buffers the values, it is pretty efficient. Of course, you could also simply use $ EXECUTE p USING :v1, :v2, :v3; in the loop; that foregoes the per-row preparation of the statement, too.

    If you don’t mind writing verbose SQL, you can use the UNION technique suggested by Matt Hamilton, but you will need a FROM clause in each SELECT with Informix. You might specify:

    • FROM "informix".systables WHERE tabid = 1, or
    • FROM sysmaster:"informix".sysdual, or
    • use some other technique to ensure that the SELECT has a FROM clause but only generates one row of data.

    In my databases, I have either a table dual with a single row in it, or a synonym dual that is a synonym for sysmaster:"informix".sysdual. You can get away without the "informix". part of those statements if the database is ‘normal’; the owner name is crucial if your database is an Informix MODE ANSI database.

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

Sidebar

Related Questions

I want to create SQL statement (probably a stored procedure) to insert multiple rows
I have a SQL query where I want to insert multiple rows in single
I want to insert multiple rows from one column by splitting column value. But
What's wrong with this code? i want to insert multiple rows with same movie
I want to clone multiple tables' rows that have a single primary key (PrimKey).
Suppose I want to update two columns in one ON DUPLICATE STATEMENT: INSERT INTO
i want to insert multiple rows in a loop using doctrine 2.. i usually
I want to insert multiple rows into a DB2 table. I have a query
In my SQLite database only one row effect but I want effect 4 rows
I want to insert multiple rows into different tables in my database. The statements

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.