TScript Basic Read Queries
Select * from table_6 where UserName = "Name"
The first basic example shows you how to write a query that finds a matching object on index_1 and return its contents. This script implicitly takes care of all memory allocation and error handling.
- TScript
#include "ODBPP.ts" public main(variable parameters = null : Structure results) { ODBPP database; CODBPP::Object objectHandle; database.OpenDatabase(L"D:\Database\local.odc"); database.BeginTransaction(); database.OpenTable(6); database.ReadIndex(6,CODBPP.EQUALTO,1,L"Name": objectHandle); database.FragmentObject(6,objectHandle:results); }
Select * from table_1
In this second query shows how TScript handles the basic - select all form table_1 order by objectID. And at this point you may as well be wondering why replace such a small text with that much text, well the answer is because of the freedom TScript allows. The first thing to notice when writing the query, is that we have used TScript native error handling to ignore or throw error up the call stack.
- TScript
#include "ODBPP.ts" public main(variable parameters = null : Structure results) { ODBPP database; CODBPP::Object objectHandle; database.OpenDatabase(L"D:\Database\test.odc"); database.BeginTransaction(); database.OpenTable(1); if(database.ReadIndex(1,CODBPP::FIRST,0: objectHandle)){ for(Integer count = 0; true; count++){ database.FragmentObject(1,objectHandle:results[count]); if(!database.ReadIndex(1,CODBPP::NEXT,0: objectHandle)){ if((error & 0xffff) != CODBPP::NOT_FOUND_INDEX_KEY) return error; break; } } } else if((error & 0xffff) != CODBPP::NOT_FOUND_INDEX_KEY) return error; }
Listen All
Comments (0)