| Computers Forum Index » Computer - Databases - Informix » checking for existence of temp table... |
|
Page 1 of 1 |
|
| Author |
Message |
| pjfalbe at (no spam) gmail.com... |
Posted: Thu Oct 01, 2009 8:33 pm |
|
|
|
Guest
|
I'm trying to figure out if a program has already created a temporary
table or not. Normaly in 4GL you'd do a
whenever error continue
drop table foo
whenever error stop
create table foo
( col1 char(10)
) with no log
I'm trying to avoid the whenever error continue bit. I came up with
this query it works most of the time except some times the created
column changes value. I know there must be a better way because
onstat can tell about the temporary tables. Any ideas?
-Paul
my query
select count(*)
from sysmaster:syslcktab a, sysmaster:systabnames t,
sysmaster:systxptab c, sysmaster:sysrstcb d,
sysmaster:syssessions g,
sysmaster:sysptnhdr p
where a.partnum = t.partnum
and a.owner = c.address
and c.owner = d.address
and d.sid = g.sid
and t.partnum = p.partnum
and a.grtime in (select created
from sysmaster:systabnames t,
sysmaster:sysptnhdr p
where t.partnum = p.partnum
and sysmaster:bitval(p.flags,32) = 1
and t.tabname = ?
and owner = ?)
and pid = ? |
|
|
| Back to top |
|
|
|
| david at (no spam) smooth1.co.uk... |
Posted: Fri Oct 02, 2009 9:21 pm |
|
|
|
Guest
|
On 1 Oct, 21:33, "pjfa... at (no spam) gmail.com" <pjfa... at (no spam) gmail.com> wrote:
Quote: I'm trying to figure out if a program has already created a temporary
table or not. Normaly in 4GL you'd do a
whenever error continue
drop table foo
whenever error stop
create table foo
( col1 char(10)
) with no log
no! do you
function init_tables()
let module_var_table_foo_exists = false
.. repeat for group of tables
end function
function create_table_foo()
if module_var_table_foo_exists = false
create table foo
if error
return false
endif
endif
return true
end function
function drop_table_foo()
drop table foo
if error
return false
endif
let module_var_table_foo_exists = false
return true
end function
That way you do not even talk to the database server if the table
already exists and avoid the round trip communication and putting load
on the database server!
Whippersnappers these days still need to learn to code efficiently...
Quote: I'm trying to avoid the whenever error continue bit. I came up with
this query it works most of the time except some times the created
column changes value. I know there must be a better way because
onstat can tell about the temporary tables. Any ideas?
-Paul
my query
select count(*)
from sysmaster:syslcktab a, sysmaster:systabnames t,
sysmaster:systxptab c, sysmaster:sysrstcb d,
sysmaster:syssessions g,
sysmaster:sysptnhdr p
where a.partnum = t.partnum
and a.owner = c.address
and c.owner = d.address
and d.sid = g.sid
and t.partnum = p.partnum
and a.grtime in (select created
from sysmaster:systabnames t,
sysmaster:sysptnhdr p
where t.partnum = p.partnum
and sysmaster:bitval(p.flags,32) = 1
and t.tabname = ?
and owner = ?)
and pid = ? |
|
|
| Back to top |
|
|
|
| Ian Goddard... |
Posted: Tue Oct 06, 2009 2:38 pm |
|
|
|
Guest
|
pjfalbe at (no spam) gmail.com wrote:
Quote: 1. I'm using Aubit4GL and I talked Mike into reporting errors which
occur during "whenever error continue"
to the errorlog. It's a great feature you'd be amazed at what errors
show up when you do it.
It just shows the wisdom of the old saying "be careful of what you wish
for; you might get it".
Maybe you need a cron job to cat from /dev/null to the log file.
--
Ian
Hotmail is for spammers. Real mail address is igoddard
at nildram co uk |
|
|
| Back to top |
|
|
|
|