I have a serial column that gives me int(11) serials. I want to combine this with text and put it in a varchar(255) column. I saw a post or two involving number to string conversions, but I must be doing something wrong. I also looked it up on Google for number → string conversions.
Apperantly the .tostring function is not supported my Servoy. What am I doing wrong?
var c = forms.db_sequence.nextid + "";
production_number = "PT" + c;
The other way I tried it was:
var c = "PT" + forms.db_sequence.nextid;
production_number = c;
Neither seemed to work.
Any help would be greatly appreciated.
Thanks.
In JavaScript, there is no need to convert, so this
production_number = "PT" + forms.db_sequence.nextid ;
should work. You say, it doesn’t “seem to work”. What does that mean?
It posts no information in the production_number column at all. Yet when I remove the “PT” + portion the serial will pull thru just fine.
Maybe the target field “production_number” is an integer field?
Maybe the target field “production_number” is an integer field?
No I checked.
The field types are as follows:
production_number - varchar(255)
nextid - int(11)
what about…
var c = forms.db_sequence.nextid;
var d = "" + c;
production_number = "PT" + d;
You could also use he debugger or dialog plugin to evaluate as it steps through the code to find out where it is messing up.
I plugged in the new code, and I get the same thing. Nothing.
I enabled debugger, and it goes thru without any problems. But nothing shows up in that field. I even took a look at the SQL server to see if the data was there, and nothing. The field is enpty.
This truly baffles me.
How are you running the method to set the result field ?
Have you tried using another integer field to see if the same behaviour exists using a different field ?
What backend db are you using ?
Cheers
Harry
How are you running the method to set the result field ?
I am running the method at the creation of a new record. With each new record created, a new production number is also generated.
Have you tried using another integer field to see if the same behaviour exists using a different field ?
No, but it tried the same thing on another layout for a different varchar(255) field, and it did it correctly. So, I’m thinking that there is something wrong with my varchar(255) field. I may delete it and create a new one.
What backend db are you using ?
I am running MySQL.
Any other thoughts?
How is the pk sequence being handled - by Servoy or MySQL ?
Maybe you have latency involved in the method being able to reference the production serial if the serial doesn’t exist until the record has been saved to the backend ?
The fact that another varchar field displays the correct result certainly could point to a problem with that column - although I have no experience of this sort of behaviour in MySQL !?
Cheers
Harry
Well - Problem fixed.
I removed that column and created a new one, and it is working fine.
Something about the column must have been corrupt. - Very strange.
Thanks for all your help!