grolon
Posts: 7
|
Posted: 02/27/2010, 5:05 AM |
|
Hi, I can't use a default value in a text field in the Custom Insert/Update where says "If parameter is empty", and them I select "Use value" and I write a empty string (""), this is because en my table definition I put the field as NOT NULL, but the CC put a NULL value in the SQL query and then show a db error that says that the field is NOT NULL. I need that if the field is empty insert a SQL empty ('') value. I use PHP.
Example:
Supposing I left blank the field in the Record Form:
INSERT INTO table(field) VALUES('');
|
|
|
datadoit
|
Posted: 02/27/2010, 7:05 AM |
|
This is a wee bit confusing. It's not working because you're trying to
put a null value into a NOT NULL field? The field definition needs to
be changed to allow NULL values. Or am I the confused one?
|
|
|
mentecky
Posts: 321
|
Posted: 03/01/2010, 4:25 AM |
|
In "Project Settings" on the "General" page try unchecking the box marked "Exclude missing fields/parameters from data updates"
Rick
_________________
http://www.ccselite.com |
|
|
grolon
Posts: 7
|
Posted: 03/01/2010, 11:55 AM |
|
datadoit:
I don't want to put a NULL value in the table. I want that CC put a empty string(''). I can't change the table structure because other systems that use the same table only work with this value (empty string). The problem is that the CSS insert/update a NULL value if you left a field in blank and I want that CC use the default value(empty string) in case of a field is blank. You set the default value in the Custom Insert/Update Dialog.
I will try Rick . Thanks
|
|
|
grolon
Posts: 7
|
Posted: 03/01/2010, 12:03 PM |
|
Quote mentecky:
In "Project Settings" on the "General" page try unchecking the box marked "Exclude missing fields/parameters from data updates"
Rick
Didn't works Rick. The CC is traying to insert a NULL value yet.
|
|
|
datadoit
|
Posted: 03/01/2010, 2:00 PM |
|
Verified that in the data table definition the default value is ''
(empty string) and not NULL?
|
|
|
grolon
Posts: 7
|
Posted: 03/02/2010, 4:53 AM |
|
Quote datadoit:
Verified that in the data table definition the default value is ''
(empty string) and not NULL?
Yes, Is it.
|
|
|
davidwoo
Posts: 53
|
Posted: 03/02/2010, 7:28 PM |
|
I also try to fix the problem you mentioned here but no luck.
|
|
|
damian
Posts: 838
|
Posted: 03/03/2010, 2:17 PM |
|
if the field is set to NOT NULL why are you leaving it empty? its set that way for a reason...
anyway - if you want to leave it empty always just dont include the field in your grid.... if that field isnt in your grid the submit wont try to update it.
if you sometimes want to put a value there and other times you want it empty (but not null) try setting a default value of '-' or ' '....
_________________
if you found this post useful take the time to help someone else.... :)
|
|
|
grolon
Posts: 7
|
Posted: 03/04/2010, 4:28 AM |
|
Quote damian:
if the field is set to NOT NULL why are you leaving it empty? its set that way for a reason...
anyway - if you want to leave it empty always just dont include the field in your grid.... if that field isnt in your grid the submit wont try to update it.
if you sometimes want to put a value there and other times you want it empty (but not null) try setting a default value of '-' or ' '....
Yes, I sometimes want to put a value there and other times I want to left empty. If I put a default value ( empty ' ' ), CC insert/update NULL, ignoring my default value. I can't put '-' as default value because this field is concatenated width other fields.
|
|
|
grolon
Posts: 7
|
Posted: 03/04/2010, 5:09 AM |
|
The support team of CodeCharge report to me that currently empty string may be used only if Custom Insert/Update Type is set to SQL. I tried and it works. I would prefer this works when the Custom Insert/Update Type is set to Table too, but it resolve the problem now for text fields.
For numeric fields that permits NULL, when Custom Insert/Update Type is set to SQL, I need if the field is empty CC put a NULL value, but use the default value (nothing) and generate a bad SQL:
INSERT INTO table (textField, intergerField) VALUES ('', )
|
|
|
dragoon
Posts: 173
|
Posted: 03/04/2010, 2:27 PM |
|
Make use of a stored procedure and alter the info there
But I think you chose a wrong path; you should consider re-thinking database structure
|
|
|
grolon
Posts: 7
|
Posted: 03/09/2010, 4:40 AM |
|
Quote dragoon:
Make use of a stored procedure and alter the info there
But I think you chose a wrong path; you should consider re-thinking database structure
Thanks for your response, but I can't change the database structure because other systems are reading the table and working.
|
|
|