Page 1 of 1
Table exists?
Posted: Wed Nov 13, 2002 8:16 pm
by bhiggins
I'm very new to Vortex, so please bear with me. I've searched for quite a while before asking this.
I've got an application in which I want to create a table on the fly, with the name taken from a form. However, I want to check if a table by that name already exists in the database, and if so inform the user of that.
So...Is there some sort of tableExists function? Or am I way off base?
Thanks,
Bob
Table exists?
Posted: Wed Nov 13, 2002 9:26 pm
by mark
<sql novars "select * from SYSTABLES where NAME=$tablename"></sql>
<if $loop ne 0>
Table exists
<else>
Table does not exist
</if>
You should do some filtering of the user's input so you don't get stupid table names. Maybe something like
<sandr "[^\alpha]+" "" $tablename><$tablename=$ret>
Table exists?
Posted: Wed Nov 13, 2002 10:01 pm
by bhiggins
Of course. Seems clear now, but I was all over the place. This is exactly what I needed. And your suggestion for how to filter the user input is a good one.
Thanks so much,
Bob
Table exists?
Posted: Fri Jul 02, 2010 11:05 pm
by amitic
Is it possible to check if a RAM table already exists?
I would like to emulate 'drop table if exists'.
I can still do:
<vxcp putmsg ... 0>
and then a precautionary 'drop table' and putmsg restore, but it would be nice to have a 'cleaner' approach.
Table exists?
Posted: Mon Jul 05, 2010 10:09 am
by mark
I don't think so. But since a ram table only exists for the duration of your script you can just set a variable when you create it so you know if it exists and when.
Table exists?
Posted: Mon Jul 05, 2010 5:50 pm
by amitic
The script actually creates multiple ram tables with names determined at runtime, but i guess i could have an xtree with table names added when a table is created and removed when it is dropped.
Thank You