Note that there are some explanatory texts on larger screens.

plurals
  1. POInformix: count number of columns in a temp table?
    primarykey
    data
    text
    <p>I'm using IDS 11.70.</p> <p>I want to be able to get the count of the number of columns in a temporary table so in 4gl/genero code I can have a function that puts the right number of question marks into a 'put cursor' statement.</p> <p>For example, want to replace this sort of code:</p> <pre><code> declare put_curs1 cursor for insert into my_temp_table values(?,?,?,?,?,?) </code></pre> <p>With something like this:</p> <pre><code>let str = "insert into my_temp_table values ( format_place_holder_string_for_insert( "my_temp_table" ) CLIPPED, ")" prepare put_stment1 from str declare put_curs1 cursor for put_stment1 </code></pre> <p>We already do this for our regular tables, so if the table schema should be changed to have more or less columns then the code won't break with the wrong number of columns on inserts using put cursors. In this function for regular tables, to get the column count we use:</p> <pre><code> select count(*) from systables, syscolumns where systables.tabname = table_name and systables.tabid = syscolumns.tabid </code></pre> <p>But in trying to do it for temporary tables, I can't see what I join to or what column indicates how many columns are in the temporary table. This is what I have so far:</p> <pre><code>select * FROM sysmaster:systabnames n, sysmaster:systabinfo i, sysmaster:syssessions s WHERE sysmaster:bitval(i.ti_flags, "0x0020") = 1 AND n.dbsname = database_name AND i.ti_partnum = n.partnum AND s.sid = dbinfo("sessionid") AND n.tabname = table_name; </code></pre> <p>So instead of <code>select *</code> I need <code>select count( columns )</code> - but where do I join to so I can count the columns? I poked around but can't find the join I need.</p> <p>Thanks, Bryce Stenberg</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload