On Oct 30, 2019, at 2:00 PM, Chip Scheide wrote: > Given the following situation: > [Host_Database] <- [component] -> [external_for_Component] > > - in the case of client/server how is the external database managed? > -- would I place it in the component's resource folder?
You could if you wanted it to get sent to the client to be accessed locally by the client. But you would probably only consider doing this for a read only external database. Changes made to things in the Resources folder on 4D Client can get overwritten when new versions of the database are deployed. > -- is it automagically moved to the client via some other mechanism? > -- or is the component's external database call passed back to the > server, call(s) made and then data transferred to client from server? Check out the documentation for the USE DATABASE command. https://doc.4d.com/4Dv17/4D/17/USE-DATABASE.300-3786769.en.html You use USE REMOTE DATABASE to access an external database managed by 4D Server. If you call USE REMOTE DATABASE from 4D Remote, it sends the request to 4D Server and it does the work and sends back the data. But if you call USE REMOTE DATABASE from 4D Local it still works, it just accesses the external database at the specified path on the local machine. This is the 4D recommended way of doing it. And when you do it like this, 4D Server will manage multiple users accessing the external database for you. It will queue up requests and process them one at a time on 4D Server. And changes made to the external database are immediately available to all 4D Client users. You may need to use the "Execute On Server” property for some methods that are accessing the external database. Example: you want to auto create an empty external database if none exists at the specified path. Set the method that does that to “Execute on Server” so that the CREATE DATABASE DATAFILE will run on 4D Server. You can write it in such a way that there is very little difference between running 4D Local or 4D Remote/4D Server. “Execute on server” method property makes it easy. I have a “Method History” component that I wrote that uses an external database to save snapshots of methods. I use it with 4D Local for all my development. I also use it on a project that uses 4D Team Developer with several developers using 4D Remote. Here is the code I put in On Startup and in On Server Startup database methods. Same code in both places: // configure Method History location and options Case of : (Application type=4D Remote mode) ISE METHOD HISTORY INIT REMOTE (Current user) : (Is compiled mode) // Component not needed when compiled Else // 4D Local and not compiled ISE SET METHOD HISTORY OPTION ("Version Format";"Date Time Version User Name") ISE SET METHOD HISTORY OPTION ("User Name";Current user) ISE SET METHOD HISTORY OPTION ("Version";Sys_GetVersion ) ISE SET METHOD HISTORY OPTION ("Storage Type";"External Database") ISE SET METHOD HISTORY LOCATION (utl_Path_GetDirectoryPath (Structure file)+"Method History"+Folder separator) End case It basically sets some IP variables that other methods in the component use. ISE METHOD HISTORY INIT REMOTE actually calls another method that has “Execute on Server” property so that it can retrieve the value of some IP variables from 4D Server. ISE SET METHOD HISTORY LOCATION sets an IP variable to the path of the external database. It is in the same location on 4D Local or 4D Server — in a folder named “Method History” next to the structure file. And this method also called a method named “CreateExternalDatabase” that has Execute on Server set so that it runs on 4D Server when necessary. Tim ***************************************** Tim Nevels Innovative Solutions 785-749-3444 [email protected] ***************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

