Re: Length of smallint field
Posted in 2008
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
monkeys paw wrote: > I have a table with a smallint field. A number is entered into > a 4gl form. I need it to be 0 padded, four digits wide. however, > the LENGTH() function doesn't work on smallint fields. So whether > user enters "600" or "0600", the length call below returns 0. > How can i get around this, i need it entered in military time > by the user, they must enter preceeding zero if time is less > that 1000, like "0900". > > let len = length(calRec.hearing_time) > message len Another option would be to use the proper data type (datetime hour to minute)... You can display it as you want... -- Fernando Nunes Portugal http://informix-technology.blogspot.com My email works... but I don't check it frequently...
Fernando Nunes wrote: > monkeys paw wrote: >> I have a table with a smallint field. A number is entered into >> a 4gl form. I need it to be 0 padded, four digits wide. however, >> the LENGTH() function doesn't work on smallint fields. So whether >> user enters "600" or "0600", the length call below returns 0. >> How can i get around this, i need it entered in military time >> by the user, they must enter preceeding zero if time is less >> that 1000, like "0900". >> >> let len = length(calRec.hearing_time) >> message len > > Another option would be to use the proper data type (datetime hour to > minute)... > You can display it as you want... That's sound advice - if it is a time of day (and it probably is). Otherwise, INTERVAL HOUR TO MINUTE might be appropriate (and the casual observer would be hard-pressed to spot the difference). You can probably use a PICTURE clause in the form to require the digits, and you can provide the colon so the user doesn't have to type it. You can certainly use the PICTURE clause with character fields; I'd have to experiment to see whether it works with DATETIME HOUR TO MINUTE fields. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2008.0229 -- http://dbi.perl.org/ publictimestamp.org/ptb/PTB-4197 sha256 2008-09-11 03:00:07 A120D038EE9959EC79E04C1EB3CA7D9251E82A58CAEC4A57848EF8699EEF5A1A