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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:47:31+00:00 2026-05-22T15:47:31+00:00

I have to do a big update script – not an SPL (stored procedure).

  • 0

I have to do a big update script – not an SPL (stored procedure).
It’s to be written for an Informix db.

It involves inserting rows into multiple tables, each of which relies on the serial of the insert into the previous table.

I know I can get access to the serial by doing this:

SELECT DISTINCT dbinfo('sqlca.sqlerrd1') FROM systables

but I can’t seem to define a local variable to store this before the insert into the next table.

I want to do this:

insert into table1 (serial, data1, data2) values (0, 'newdata1', 'newdata2');
define serial1 as int;
let serial1 = SELECT DISTINCT dbinfo('sqlca.sqlerrd1') FROM systables;
insert into table2 (serial, data1, data2) values (0, serial1, 'newdata3');

But of course Informix chokes on the define line.

Is there a way to do this without having to create this as a stored procedure, run it once and then delete the procedure?

  • 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-22T15:47:32+00:00Added an answer on May 22, 2026 at 3:47 pm

    If the number of columns in the tables involved is as few as your example, then you could make the SPL permanent, and use it to insert your data, ie:

    EXECUTE PROCEDURE insert_related_tables('newdata1','newdata2','newdata3');

    Obviously that doesn’t scale terribly well, but is OK for your example.

    Another thought that expands on Jonathan’s example and solves any concurrency issues that might arise from the use of MAX() would be to include DBINFO('sessionid') in Table3:

    DELETE FROM Table3 WHERE sessionid = DBINFO('sessionid');
    INSERT INTO Table1 (...);
    INSERT INTO Table3 (sessionid, value)
      VALUES (DBINFO('sessionid'), DBINFO('sqlca.sqlerrd1'));
    INSERT INTO Table2 
      VALUES (0, (SELECT value FROM Table3
                  WHERE sessionid = DBINFO('sessionid'), 'newdata3');
    ...
    

    You could also make Table3 a TEMP table:

    INSERT INTO Table1 (...);
    SELECT DISTINCT DBINFO('sqlca.sqlerrd1') AS serial_value
      FROM some_dummy_table_like_systables
    INTO TEMP Table3 WITH NO LOG;
    INSERT INTO Table2 (...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I'm not talking about doing a SET NOCOUNT OFF. But I have a stored
I have a script that appends some rows to a table. One of the
I have a MySQL table with about 2 million rows, and a script that
I have a rather big php site, which was written for php4 and register_globals
How would you maintain the legacy applications that: Has no unit tests have big
I have a big string (let's call it a CSV file, though it isn't
i have a big web application running in perl CGI. It's running ok, it's
I have a big load of documents, text-files, that I want to search for
I have this big data-entry sort of page, a table kind of layout using

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.