KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4D and SQL Parameters with Non-4D Databases Errors
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: August 4, 2016

When calling a Stored Procedure on a non-4D external database server, such as an Oracle DB, and using a 4D Text variable as an output parameter, this may cause an error or even a crash. This is due to the incompatibility of both sides. The fields in the external database are ussually a fixed sized VARCHAR and is typically smaller than the 4D Text Variable. When the output parameter passed to the server is larger than the type it may cause an incorrect typing error or even read beyond the memory size of the VARCHAR's location and cause a crash or an error.

To work around this issue, the output parameter of a stored procedure should be assigned to a fixed length sized Alpha Field in 4D. However the field must be from a saved record, even if a temporary variable is desired.



May cause errors:

C_TEXT($varText)
SQL SET PARAMETER($varText;SQL param out)

Will not cause errors if the variable length matches:

SQL SET PARAMETER([Table_1]Field_2;SQL param out)