Schema Commands

Hello

I have a problem with a project, and i could use some help
After the use loges on the system, i want to update a field on a table, and have all the users connected on a view created by a stored procedure. I would like to be done through a service from my app server.
How can this be done;
I have created the table and the service, but i gives me 'CommandText does not return a result set.
Please advice.
I am using Delphi, on win 7
Thank you

Hello again
I forgot to mention another issue, that has to do with the active connection upon schema commands execution. I have tried to change the active connection(connectionname) on the onactivate event on the service module, but seems to ignore me. Please advice

Hello,

I’m not sure if I understand you right. But you could run stored procedure that return dataset in service method like this:

function TDAataService.NewMethod: Binary; var

lDataSet: IDADataSet;
begin
result:=Binary.Create;
try
[…]
ServiceDataStreamer.Initialize(result, aiWrite);
try
[…]
lDataSet: = Connection.NewDataset (‘EXEC storedProcedureName’, ‘DataSetName’);
lDataSet.Open;
ServiceDataStreamer.WriteDataSet (lDataSet, lOptions, lMaxRecords);
[…]
finally
lDataSet := nil;
end;
finally
ServiceDataStreamer.Finalize();
end;

end;

Please inform us also what DB and driver you use

Best regards

Thank you for the reply.
Driver is ADO with SQL.
I will try to describe the scenario in more details.
After users loggs in, i want to run servise on app. server on users database - every user, connects on his own database on remote sql server. All databases have same schema.

I have a view created on the main database on sql server- holds all subscriptions, manages all authenticaitions, and hols information for databases on the server.

So, every time a user loggs in database, the view has to be updated on the main database, in order to know who is logged on and who is logged off.
The view is created throu a stored procedure, and works fine.

So i wish to call servise on app. server to acomplish that.

Hope this helps you.

Hello,

If I understand you right, you need to call service method from server after user has logged on.

You could do this in onDeactivate event of LoginService.
By other hand, you can use TRODBSessionManager or TDADBSessionManager. In this case sessions will be stored in DB.

I have tried to change the active connection(connectionname) on the onactivate event on the service >module, but seems to ignore me.
You should change connection in BeforeAcquireConnection event of service.

Best regards

Thank you for the reply.

Yes, this is the scenario with the user. I will try your suggestion and let you know.
Best regards.

Hello again.

I am absolutely lost.You suggested, i should call the server method, after the user has logged on, onDeactive event of Loginservice. What method should I call, the one you suggested on you prev post(function TDAataService.NewMethod: Binary; …). or something else; In fact, i don’t need a dataset returned after the update command with the service, just call the service and have the job done.
Seems like i miss something with the services and the commands.
Is it possible to just call the update command, and finish the job, or there is always the scenario that commands should return something;
Please help me to understand.
Best regards

Hello,

manosm said: Is it possible to just call the update command, and finish the job, or there is always the scenario that commands should return something;

Of course, it is possible. I just understood from your first post that you need to return result set. If you don’t, you could just call update command without any writing in data streamer and returning result from service method.
The only difference is that you should use Execute method instead of Open if you call stored procedure that doesn’t return dataset:

lDataSet: = Connection.NewDataset (‘EXEC storedProcedureName’, ‘DataSetName’);
lDataSet.Execute;

Best regards

Hello, thank you very much for the information

Another question, can this be done withour stored procedure, just an update command with parametes, server side; A piece of code, would be helpfull.

Best regards.

Hello,

manosm said: Another question, can this be done withour stored procedure, just an update command with parametes, server side;
You could run any SQL statement by using method http://wiki.remobjects.com/wiki/IDAConnection_Interface#NewDataset , for example:

lDataSet: = Connection.NewDataset (‘UPDATE TableName SET Field1=’+Param1+', Field2= ‘+Param2+ ’ WHERE Field3=’+ Param3, ‘DataSetName’);
lDataSet.Execute;

Best regards

Hello, thank you fro the help

It worked, though i would prefer not to send sql command directly from the client.
Best regards.