Link to home
Start Free TrialLog in
Avatar of DoukAli
DoukAli

asked on

VB, Teradata

Hello,

Need to query a Teradata Table and if the record exist return code 0 if not sleep for 5 min and try again until record found. Preferably in VB.Net or VBS. Thanks
ASKER CERTIFIED SOLUTION
Avatar of Robberbaron (robr)
Robberbaron (robr)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The query should be structured the same for any size database
if your dataset returns 0 records then sleep.
but because you are looking at such a large table I would have to ask...

What does the query look like?  - perhaps your problem is in getting a fast response.


sql = "SELECT DATA FROM YOURTABLE WHERE CONDITION = TRUE"
DIM DR AS DATAROW
DIM SQLCMD AS NEW OLEDB.OLEDBCOMMAND(SQL,OPENSQLCONN)
DIM SQLDS AS NEW DATASET
DIM SQLDA AS NEW OLEDB.OLEDBDATAADAPTER(SQLCMD)
SQLDA.FILL(SQLDS)
IF SQLDS.TABLES(0).ROWS.COUNT = 0 THEN
'   SLEEP PROCESS
ELSE
  ' DO YOUR KEWL THING HERE
END IF
Avatar of DoukAli
DoukAli

ASKER

The table I'm querying is very small (about 10 records). I'm running some processes and whenever one finishes it would write to a table by updating the value of a column to 1. What I need to do is have this vb code check the table for that value and either return a code ... or just write 'done' in a txt file.

Thanks for your help.
main thing to  remember then is to make sure that the sql code runs in its own transactionn
so that you don't cause contention locks...

begin tran
select x...
commit tran
test
   sleep
else
   do something