我使用的是IDS 11.70。Informix:计数临时表中的列数?
我希望能够获得临时表中的列数,因此在4gl/genero代码中我可以有一个函数,将正确数量的问号放入“放置游标”语句中。
例如,要替换这种代码:
declare put_curs1 cursor for
insert into my_temp_table values(?,?,?,?,?,?)
像这样的东西:
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
我们已经做到这一点对于我们普通表,因此,如果表架构应更改为具有更多或更少的列,那么代码将不会因使用放置游标而插入的列数错误而中断。 在此功能常规表,让我们使用的列数:
select count(*)
from systables, syscolumns
where systables.tabname = table_name
and systables.tabid = syscolumns.tabid
但在试图做到这一点对于临时表,我什么也看不见我加入或什么列表示有多少列在临时表中。这是我到目前为止有:
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;
所以不是select *
我需要select count(columns)
- 但我在哪里加盟,所以我可以算列?我戳了一下,但无法找到我需要的连接。
感谢, 布莱斯Stenberg发明
嗨乔纳森,在我们的环境中,我们不使用任何ESQL/C,所以我将无法实现您的解决方案。我们只使用Genero进行编码。数据库必须知道某个地方的临时表中有哪些列,可能有人知道在哪里找到它......谢谢您的回复。问候,布莱斯Stenberg。 – user1840734 2013-03-20 02:37:48