Error
Error Code:
3739
MySQL Error 3739: Invalid Angular Unit Factor
Description
This error indicates that a specified angular unit conversion factor in a Spatial Reference System (SRS) definition is not a positive number, which is a mandatory requirement. It commonly occurs during the creation or modification of SRID definitions or when attempting to use an SRS with an incorrectly configured angular unit.
Error Message
The angular unit conversion factor must be a positive number.
Known Causes
3 known causesInvalid SRS Definition
An attempt was made to define or modify a Spatial Reference System (SRS) using a conversion factor for angular units that is zero or negative.
Corrupted SRS Data Import
Importing spatial data or SRS definitions where the angular unit conversion factor specified within the imported schema is invalid (zero or negative).
Manual Metadata Update Error
Direct SQL manipulation of SRS metadata tables resulted in a non-positive value being assigned to an angular unit conversion factor.
Solutions
3 solutions available1. Correct Invalid Angular Unit Conversion Factor easy
Identify and correct the incorrect positive number used as an angular unit conversion factor.
1
Review the SQL statement or stored procedure that is causing this error. Look for any functions or operations that involve angular units (e.g., `RADIANS()`, `DEGREES()`, or custom functions).
2
Locate the specific part of the statement where an angular unit conversion factor is being used. This might be a literal number or a variable.
3
Ensure that the conversion factor is a positive number. Common incorrect values could be zero, negative numbers, or non-numeric characters.
SELECT RADIANS(90);
-- This is valid.
SELECT RADIANS(0); -- This might cause an issue depending on context, but typically not Error 3739.
SELECT RADIANS(-90); -- This would be an invalid factor.
SELECT RADIANS(90/0); -- Division by zero will cause a different error, but the underlying issue is similar.
4
Replace any invalid (zero or negative) conversion factor with a valid positive number. For example, if you intended to convert degrees to radians, ensure the factor is correctly applied.
UPDATE your_table SET angle_column = angle_column * (PI() / 180.0) WHERE ...;
-- Ensure (PI() / 180.0) is treated as a positive factor.
2. Validate Input Data for Angular Calculations medium
Check and sanitize input data that is used in angular calculations to prevent invalid conversion factors.
1
If the angular unit conversion factor is derived from user input or external data, implement input validation before it's used in SQL queries or stored procedures.
2
In your application code (e.g., PHP, Python, Java), add checks to ensure that any value intended to be an angular conversion factor is greater than zero.
<?php
$input_factor = $_POST['conversion_factor'];
if (!is_numeric($input_factor) || $input_factor <= 0) {
// Handle error: Invalid conversion factor
echo "Error: Conversion factor must be a positive number.";
exit;
}
// Proceed with database query using $input_factor
?>
3
If the factor is stored in a table, add a `CHECK` constraint to enforce that the column storing the factor only accepts positive values.
ALTER TABLE your_settings_table ADD CONSTRAINT positive_conversion_factor CHECK (conversion_factor > 0);
4
Alternatively, use application logic to sanitize the data before inserting or updating it into the database.
3. Inspect Stored Procedures and Functions advanced
Thoroughly examine custom stored procedures and functions for incorrect angular unit conversion factors.
1
Identify all stored procedures and functions in your database that perform angular calculations or use angular unit conversions.
SHOW PROCEDURE STATUS WHERE Db = 'your_database_name';
SHOW FUNCTION STATUS WHERE Db = 'your_database_name';
2
Retrieve the source code for these procedures and functions.
SHOW CREATE PROCEDURE your_procedure_name;
SHOW CREATE FUNCTION your_function_name;
3
Carefully review the code, paying close attention to any arithmetic operations involving angles or explicit conversion factors. Ensure that any literal numbers or variables used as multipliers/divisors in these conversions are positive.
-- Example of potentially problematic code within a stored procedure:
SET @degrees = 45;
SET @radians_per_degree = 0.0174533; -- Correct value
-- SET @radians_per_degree = -0.0174533; -- Incorrect value that would cause Error 3739
SET @radians = @degrees * @radians_per_degree;
4
Correct any instances where a zero or negative number is used as an angular unit conversion factor.
DELIMITER //
CREATE PROCEDURE update_angle(IN angle_degrees DECIMAL(10,2))
BEGIN
DECLARE angle_radians DECIMAL(10,4);
-- Ensure the factor is positive: PI() / 180.0
SET angle_radians = angle_degrees * (PI() / 180.0);
-- ... rest of the procedure
END //
DELIMITER ;
-- Or if a variable is used:
DELIMITER //
CREATE PROCEDURE update_angle_with_factor(IN angle_degrees DECIMAL(10,2), IN conversion_factor DECIMAL(5,4))
BEGIN
DECLARE angle_radians DECIMAL(10,4);
IF conversion_factor <= 0 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Invalid Angular Unit Factor: must be positive.';
ELSE
SET angle_radians = angle_degrees * conversion_factor;
-- ... rest of the procedure
END IF;
END //
DELIMITER ;