# Read the return or output parameter of command script

**URL:** https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441
**Category:** Relativity Server
**Created:** [May 20, 2018, 6:43pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441 "2018-05-20T18:43:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![joroberto](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/j/ecae2f/32.png) [@joroberto](https://talk.remobjects.com/u/joroberto)
#### Post date: [May 20, 2018, 6:43pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/1 "2018-05-20T18:43:23Z")

</div>

Hello.

How do I read the return or parameter  
of command script?

Ex:

var sql = ‘select max(id) as maxid from table’;  
var resultsql = lda.selectSQL(sql);

In my client (delphi) I need to read  
this variable “resultsql” (which is an output parameter).

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [May 25, 2018, 8:48am UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/3 "2018-05-25T08:48:59Z")

</div>

Hello

Could you elaborate what you are trying to do? It is not clear where/how this ‘command script’ is executed and the platform of the server app (.NET or Delphi)

---

<div class="post-metadata">

### Author: ![joroberto](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/j/ecae2f/32.png) [@joroberto](https://talk.remobjects.com/u/joroberto)
#### Post date: [May 25, 2018, 3:24pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/4 "2018-05-25T15:24:21Z")

</div>

I use command scripts for various operations, I use  
in Relativity Server, I need to access a return parameter …

Imagine a command scripts that I wanted to know the date and time of the  
server (this is a hypothetical example), as I would do to read this in a  
delphi client?

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [May 25, 2018, 6:55pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/5 "2018-05-25T18:55:40Z")

</div>

Unfortunately you cannot. There is no support for such scripts in Relativity

---

<div class="post-metadata">

### Author: ![joroberto](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/j/ecae2f/32.png) [@joroberto](https://talk.remobjects.com/u/joroberto)
#### Post date: [May 25, 2018, 10:18pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/6 "2018-05-25T22:18:21Z")

</div>

What is the “out” and “result” parameter direction for ?

 ![image](https://talk.remobjects.com/uploads/default/original/2X/d/d82a29615ef12fa95f34af161add35bd77b96e1f.png)

I tried to read in Delphi, but it did not work

```
> lDARemoteCommand := TDARemoteCommand.Create(nil);
> lDARemoteCommand.RemoteService := DMConnection.RemoteService;
> try
> with lDARemoteCommand.ExecuteCall do
> begin
> MethodName := 'ExecuteCommandEx';
> Params.Clear;
> OutgoingCommandNameParameter := Params.Add('ACommandName', rtString, fIn).Name;
> OutgoingParametersParameter := Params.Add('aInputParameters', rtUserDefined, fIn, 'DataParameterArray').Name;
> IncomingAffectedRowsParameter := Params.Add('Result', rtInteger, fResult).Name;
> IncomingParametersParameter := Params.Add('aOutputParameters', rtUserDefined, fOut, 'DataParameterArray').Name;
> lDARemoteCommand.Execute(ACommandName, AParamNames, AParamValues);
> Params.ParamByName(IncomingParametersParameter).OwnsComplexType := True;
> end;
> finally
> FreeAndNil(lDARemoteCommand);
> end;

```

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [May 26, 2018, 7:23pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/7 "2018-05-26T19:23:02Z")

</div>

> [@joroberto](#):
>
> What is the “out” and “result” parameter direction for ?

For parameters being sent out by the **SQL** statement tied to this schema command (either a Stored Procedure or a plain SQL added to the Schema)

> [@joroberto](#):
>
> I tried to read in Delphi, but it did not work

What exactly did you try?

---

<div class="post-metadata">

### Author: ![joroberto](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/j/ecae2f/32.png) [@joroberto](https://talk.remobjects.com/u/joroberto)
#### Post date: [May 29, 2018, 9:30pm UTC](https://talk.remobjects.com/t/read-the-return-or-output-parameter-of-command-script/16441/8 "2018-05-29T21:30:39Z")

</div>

> [@antonk](#):
>
> What exactly did you try?

Because inside command I can read a parameter assigned from my  
delphi application and can not do the reverse? (my application read a  
output parameter)

```
function beforeExecuteCommand(sql, commandName, names, values)
{
   for (var i=0,len=names.length; i<len; i++)
   {
  if (names[i] == "idTurma") // Here I can read this parameter, which I passed through my application in delphi ..
      var idTurma = values[i];
     }
   }
   Result = 'something bla bla' // I wanted to read this parameter in my application delphi.

```
