Hello,
I am running very basic Delphi project on relativity server and I would like to implement some simple database queries, ie. ‘return row count’ or ‘return all names where client code is 1…’ type of thing but I have absolutely no idea how to accomplish that.
I worked out that I will need to write some JavaScript in Schema Modeler and then call that code from SpiderMonkeyScriptProvider (?), only no clue how to do that. I would appreciate if someone could write a step by step instruction what to do together with example javascript method or at least give some hints how to proceed from here as I found no articles on that subject in Wiki or ROTV or Google.
Thank you for your response. However I don’t see how either of these articles could be helpful in what I want to achieve. I already have a project running on Relativity, setup with domain, schema and data tables in the schema. I know how to view ALL the table content in a grid at run-time but what I don’t know is how to return ‘custom’ datasets, like those described in my original posts, ie.
-return count of records in a table
or
-return sum of field ‘count’ etc.
These are simplest SQL queries I want to send to my schema during runtime.
I think Dynamic Select/Dynamic Where and DA SQL are my answers only I can not work out how to implement it in my code/project (:
I will phrase my question this way:
I want to execute : SELECT SUM(COUNT) FROM TABLE
from my client app(IntraWeb) to Relativity schema- how do I do that (what components & code in which order please). An equivalent of what I am looking for here is using TADSQuery component in Delphi, filling it in with SQL statement(s) and then calling ‘ExecuteSQL’ upon the component’s SQL property.
Please don’t refer me to any of the articles on Wiki because I have read them all around 3x by now and I do not see how to do it.
Thank you vovanl for your answer. I managed to do what I wanted by using TableRequestInfoV6 class. It does what I need it to, but I would think there will be a property on one of the components or a separate component itself to take sql queries. I suppose there is some underlying reason for why there isn’t such thing, ie. RO Team favours other approach for querying DB rather than SQL?
Here is code I’ve used (adapted from DA SQL demo):
procedure TfrmClient1.btnExecuteClick(Sender: TObject);
var
tri: TableRequestInfoV6;
triArr: array of TableRequestInfo;
begin
if Trim(eQuery.Text) = ‘’ then begin
WebApplication.ShowMessage(‘The query is empty. Please select one of the query templates or write your own.’);
exit;
end;
tri := TableRequestInfoV6.Create();
with tri do begin
Sql := eQuery.Text;
IncludeSchema := true;
MaxRecords := 1000;
end;
try
with frmRelativityClient do begin
tbl_anim.ClearRows(true);
dbgResults.Columns.Clear;
SetLength(triArr, 1);
triArr[0] := tri;
RemoteDataAdapter.Fill([tbl_anim], triArr);
end;
except
on E: Exception do WebApplication.ShowMessage('Error executing query: ’ + E.Message);
end;
end;
I will try your solution later vovanl, after I got that new Relativity. My login is ‘bagietka’
Hello,
You can also use your method.
We strongly recommend to use queries from the schema for reasons of security because an intruder can destroy your data on database server.
You can download a new version of Relativity here: https://secure.remobjects.com/portal/downloads/personal.aspx