PCL and Customization > Accessing the Patran Database > External Access of the Patran Database
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
External Access of the Patran Database
There cannot be multiple simultaneous transactions on an Patran database. This means that if an external program accesses a database which is currently opened by Patran, Patran must first end the transaction with the database with the “db_commit_raw” function described later in this chapter. Only when the external program is finished accessing the database should Patran resume a translation with the database using the “db_start_transaction_raw” function.
When an external program is modifying or adding data to a database which is currently open, the database must first be closed and then re-opened by Patran after the external program has finished. The database must be closed and re-opened because there is no mechanism for informing Patran of external changes to an already opened database. For example: if an external program were to add a node to a database while it was open, Patran would have no knowledge of this new node.
When accessing the database only to extract information, Patran need not close the database but should end the current transaction and restart it only after the external program is finished. Below is a example of PCL code which would spawn an external forward translator.
FUNCTION my_spawn()
	INTEGER status
	status = db_commit_raw()
	status = utl_process_spawn ( “my_forward_translator argument_1 
	argument_2”, TRUE )
	IF ( utl_process_error ( status ) ) THEN
		utl_display_process_error( status, 3 )
	END IF
	status = db_start_transaction_raw()
END FUNCTION
When spawning an external program which is going to either add or modify data in the database such as a results translator, Patran should close and re-open the database as shown in the following example.
FUNCTION my_spawn()
	INTEGER status
	STRING database_name[256]
	status = db_name_get ( database_name )
	status = uil_file_close.go()
	status = utl_process_spawn ( “my_results_translator argument_1 
argument_2”, TRUE )
	IF ( utl_process_error ( status ) ) THEN
		utl_display_process_error( status, 3 )
	END IF
	status = uil_file_open.go( database_name )
END FUNCTION
If the external process is time consuming, you may wish to have Patran close the database and not re-open it. This would allow you to exit Patran after the external process was initiated or open a new database and continue work on a different model. An example PCL function is given below.
FUNCTION my_spawn()
	INTEGER status
	status = uil_file_close.go()
	status = utl_process_spawn ( “my_results_translator argument_1 
		argument_2”, FALSE )
	IF ( utl_process_error ( status ) ) THEN
	utl_display_process_error( status, 3 )
	END IF
END FUNCTION