Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Pervasive.SQL > Adding Leading Zeroes to a Flat File

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-08, 23:22
spurs72 spurs72 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
Adding Leading Zeroes to a Flat File

Hi,

I'm using Pervasive to convert an Excel spreadsheet into a flat file. And, I'm having trouble adding leading zeroes to a field that has 6 digits.

Eg.

50 -> 000050
500 -> 000500
5000 -> 005000
50000 -> 050000

Any help is appreciated. Thanks!
Reply With Quote
  #2 (permalink)  
Old 02-10-08, 16:50
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 813
Which tool exactly are you using?
You'll probably want to convert the value into a string and then pad with zeros.
How you do that depends on the tool and interface.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 02-10-08, 17:00
spurs72 spurs72 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
Quote:
Originally Posted by mirtheil
Which tool exactly are you using?
You'll probably want to convert the value into a string and then pad with zeros.
How you do that depends on the tool and interface.

I'm using Map Designer... Would it matter if I have defined the particular field as a text data type? I'm a little new to this but what do you mean by converting the value into a string and pad with zeroes
Reply With Quote
  #4 (permalink)  
Old 02-10-08, 20:43
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 813
I'm more familiar with the PSQL database but in Map Designer you can use RIFL script (VB Script like scription) to manipulate the field when it comes from the source and before it is written to the target.
You'll need to do something like the following (pseudo-code):
1. Convert the value to string.
2. Determine length of the value (50 is 2, 500 is 3, 5000 is 4, etc).
3. Concatenate a string of zeros appropriate for the length. ( "0000" + "50", "000" + "500", etc).
4. Write the value to the target as a string.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #5 (permalink)  
Old 02-10-08, 21:24
spurs72 spurs72 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
Quote:
Originally Posted by mirtheil
I'm more familiar with the PSQL database but in Map Designer you can use RIFL script (VB Script like scription) to manipulate the field when it comes from the source and before it is written to the target.
You'll need to do something like the following (pseudo-code):
1. Convert the value to string.
2. Determine length of the value (50 is 2, 500 is 3, 5000 is 4, etc).
3. Concatenate a string of zeros appropriate for the length. ( "0000" + "50", "000" + "500", etc).
4. Write the value to the target as a string.

Yes, I'm using the RIFL script to manipulate the field. However, I've hit a roadblock with it. I've tried using the FORMAT query to do what I'd like to achieve but it has not worked so far.

Thanks for all the information.
Reply With Quote
  #6 (permalink)  
Old 02-11-08, 14:26
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 813
I'm not real familiar with RIFL script but what exactly have you tried and how did it fail?
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #7 (permalink)  
Old 02-11-08, 17:31
spurs72 spurs72 is offline
Registered User
 
Join Date: Feb 2008
Posts: 5
Quote:
Originally Posted by mirtheil
I'm not real familiar with RIFL script but what exactly have you tried and how did it fail?

I've tried using this syntax - format(fieldname,"000000") but it doesn't add the leading zeroes. I also tried to convert from numeric to a string value and then add the leading zeroes - that didn't work too.

But then, I changed the data type to text - and it WORKED!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On