Add a numeric field to customer_company

Moderator: crythias

Locked
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

Add a numeric field to customer_company

Post by HervE »

Hello,

I'm trying to add a new column to customer_company.
String columns are OK, but I've got a problem with a numeric column.

I've added it in MySQL this way:

Code: Select all

alter table customer_company add column remaining_reserved_days decimal(5,2);
and I've added it in Config.pm this way:

Code: Select all

[ 'RemainingReservedDays', 'Remaining reserved days', 'remaining_reserved_days', 1, 0, 'int', '', 1 ],
The issue is: because this new field is optional and numeric, whenever I add or update a Customer Company in OTRS without any figure in this field, I've got the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' reserved_days_deadline = '', change_time = current_timestamp, change_by = 2 ' at line 1, SQL: 'UPDATE customer_company SET customer_id = 'XXXX', name = 'XXXXX', street = 'Xxxxxx', zip = '00000', city = 'Xxxx', country = 'Xxxx', url = '', comments = '', valid_id = 1, remaining_reserved_days = , reserved_days_deadline = '', change_time = current_timestamp, change_by = 2 WHERE LOWER(customer_id) = LOWER('XXXX')'

Of course the SQL syntax error is here: remaining_reserved_days = ,

Do you think of an idea to prevent it?

Regards,
HervE
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add a numeric field to customer_company

Post by crythias »

You're allowing decimal, requesting int, and passing null.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

Re: Add a numeric field to customer_company

Post by HervE »

I know.
In Config.pm there is no "decimal" type, only "int" and "var".
Anyway, the issue is the same if I define it as "int" in MySQL.

So in other words the question is: How to pass null from OTRS to the database?
Or also: How to make an empty string converted into null?

Edit:
I tried to modify it to 'var' in Config.pm:

Code: Select all

[ 'RemainingReservedDays', 'Remaining reserved days', 'remaining_reserved_days', 1, 0, 'var', '', 1 ],
Result: no syntax error, but inserts 0 in the database.
And, by the way, inserts 0000-00-00 in the other column I added (a date).
I'd like these 2 columns to remain null when no figure has to be entered.

HervE
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
Locked