Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM Client/Server » View Thread |
Messages 1 to 9 of 9 total |
New to Remote Procedures. Need Help |
Thu, Sep 21 2006 7:46 AM | Permanent Link |
"Ian Branch" | Hi Guys,
I haven't been able to find a worked remote procedure as a basis so I am flying a little blind, using the help, and not getting anywhere. I have created the following 'remote procedure'.. PROCEDURE TMainForm.DBEngineCustomFunction(Sender: TObject; CONST FunctionName: STRING; FunctionParams: TDBISAMParams; VAR Result: Variant); VAR Stamp1: TTimeStamp; Stamp2: TTimeStamp; BEGIN IF (AnsiCompareText(FunctionName, 'DaysBetween') = 0) THEN BEGIN { Notice that the function parameters are accessed in a 0-based manner } Stamp1 := DateTimeToTimeStamp(FunctionParams[0].AsDateTime); Stamp2 := DateTimeToTimeStamp(FunctionParams[1].AsDateTime); Result := Trunc((Stamp2.Date - Stamp1.Date) + (((((Stamp2.Time - Stamp1.Time) / 1000) / 60) / 60) / 24)); END; END; I have a Remote Procedure in the Server duly authorised called DaysBetween. I am calling it from my application as follows... PROCEDURE TMainForm.About1Click(Sender: TObject); BEGIN WITH DBSession DO BEGIN RemoteParams[0].AsDateTime := Now(); RemoteParams[1].AsDateTime := Now() - 20; TRY { Now call the procedure } CallRemoteProcedure('DaysBetween'); IF RemoteParamByName('Result').AsInteger > 0 THEN ShowMessage('The call was successful ' + inttostr(RemoteParamByName('Result').AsInteger)) ELSE ShowMessage('The record was not added successfully'); EXCEPT ShowMessage('There was an error calling the ' + 'server-side procedure'); END; END; END; On top of this I'm not 100% sure on the correct configuration of the 'Engine' Could anybody be so kind as to send me a working example of a remote procedure application? i.e. the one above. I would be ever so greatful. Regards & TIA, Ian -- |
Thu, Sep 21 2006 4:11 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ian,
<< I have created the following 'remote procedure'.. >> That's not a remote procedure, it's a custom function. They're two different items altogether. What you want is the OnServerProcedure event handler, not the OnCustomFunction event handler. -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Sep 21 2006 4:46 PM | Permanent Link |
"Ian Branch" | Tim Young [Elevate Software] wrote:
> Ian, > > << I have created the following 'remote procedure'.. >> > > That's not a remote procedure, it's a custom function. They're two different > items altogether. What you want is the OnServerProcedure event handler, not > the OnCustomFunction event handler. Hi Tim, Well I guess I'm more confused than I thought. Ian. -- |
Thu, Sep 21 2006 6:44 PM | Permanent Link |
"Ian Branch" | Anybody,
I have put my test app in the binaries NG. I really would appreciate anybody having a look and see what I have done wrong and/or missed. Don't be bashfull Regards & TIA, Ian -- |
Fri, Sep 22 2006 2:40 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ian,
<< I have put my test app in the binaries NG. I really would appreciate anybody having a look and see what I have done wrong and/or missed. >> The code is fine, except for the location of the server procedure itself. I just looked at the unit code so I can't say for sure, but if the project that you posted has a TDBISAMEngine component with the EngineType set to etServer, then you must call the server-side procedure from a different application. DBISAM does not allow remote sessions within a process that has a TDBISAMEngine component acting as a server. Client Application = Remote Session with Server-Side Procedure calling code Database Server Application = OnServerProcedure event handler code -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Sep 22 2006 5:31 PM | Permanent Link |
"Ian Branch" | Tim Young [Elevate Software] wrote:
> Ian, > > << I have put my test app in the binaries NG. I really would appreciate > anybody having a look and see what I have done wrong and/or missed. >> > > The code is fine, except for the location of the server procedure itself. I > just looked at the unit code so I can't say for sure, but if the project that > you posted has a TDBISAMEngine component with the EngineType set to etServer, > then you must call the server-side procedure from a different application. > DBISAM does not allow remote sessions within a process that has a > TDBISAMEngine component acting as a server. > > Client Application = Remote Session with Server-Side Procedure calling code > Database Server Application = OnServerProcedure event handler code Hi Tim, Ahhh. I think this is the link I hadn't put together. Let me see If I have this right. There are 3 components to having this all work. 1. The DBISAM Server, dbsrvr.exe, running as either an application or a service. 2. A Database Server Application with just the TDBISAMEngine in/on it and the RemoteProcedures/Functions coded into it. 3. Client applications that calls the RemoteProcedures/Functions embeded in the DBISAM Server by the Database Server Application. The Server, dbsrvr, needs to be told about the remote Procedure, nominally by going into it with the Server Admin Utility and adding the Procedure name and eligible users into the 'Procedures' & 'Procedure Users' sections. Yes/No? If yes, then my understanding would be that the TDBISAMEngine componet is simply a view/portal into the DBISAM Server itself allowing various aspects of the Server to be read/written. If so you mention in the Help file the the Remote Procedure is written into a text file. Is this just the name of the remote procedure or does it happen when the Database Server Application runs? Does the Database Server Application have to be run in any particular location/drive/directory? I'm guessing it would be most appropriate for it to be located in/on the same machine/drive/directory as the dbsrvr itself and run after dbsrvr. Regards and thanks for your patience & time as I come to grips with this. Ian -- |
Mon, Sep 25 2006 2:35 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ian,
<< There are 3 components to having this all work. >> Nope, just 2: Correct >>>> 1. The DBISAM Server, dbsrvr.exe, running as either an application or a service. Not Correct >>>> 2. A Database Server Application with just the TDBISAMEngine in/on it and the RemoteProcedures/Functions coded into it. The database server itself has the server-side procedures, etc. coded directly into it. If you navigate to the DBISAM installation directory, you will find the dbsrvr.dpr source code under the \servers\dbsrvr\source subdirectory. You can put your server-side procedures into the event handlers for the server's TDBISAMEngine component found on the main form of the dbsrvr.dpr project and then just recompile it. The reason that I said "database server application" is because the dbsrvr.dpr project is just one example of a database server. You can code one from scratch using the TDBISAMEngine component with its EngineType property set to etServer. That's all there is to it. You can try it yourself, just: 1) Start a new application 2) Drop a TDBISAMEngine component on the main form. 3) Set the EngineType property to etServer 4) Set the Active property to True 5) Run the application Now you should be able to connect to it like any other database server using the 127.0.0.1 loopback address using DBSYS, etc. and the default admin login information. Correct >>>>>>> 3. Client applications that calls the RemoteProcedures/Functions embeded in the DBISAM Server by the Database Server Application. Except for the Database Server Application part. The database server is the database server application - the two are the same thing. << The Server, dbsrvr, needs to be told about the remote Procedure, nominally by going into it with the Server Admin Utility and adding the Procedure name and eligible users into the 'Procedures' & 'Procedure Users' sections. >> Correct. << If yes, then my understanding would be that the TDBISAMEngine componet is simply a view/portal into the DBISAM Server itself allowing various aspects ofthe Server to be read/written. If so you mention in the Help file the the Remote Procedure is written into a text file. Is this just the name of the remote procedure or does it happen when the Database Server Application runs? >> I'm not sure what you're referring to here. Server-side procedures are coded in the database server (by you, the developer), and security for them is set up via the administration functionality as you correctly indicated in you post. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Sep 26 2006 1:25 AM | Permanent Link |
"Ian Branch" | HI Tim,
Ah Ha!!! All along I thought this was external to the Server itself. No wonder I couldn't get a handle on it. OK. Got it now and working perfectly. Thank you for your patience. Regards, Ian |
Tue, Sep 26 2006 3:50 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ian,
<< OK. Got it now and working perfectly. Thank you for your patience. >> No problem - I'm glad you've got it up and running. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |