Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using field values to format SQL output
Message
From
26/08/2008 19:27:54
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01342035
Message ID:
01342041
Views:
21
So quick and such a seemingly simple answer. It must be harder than that.

Well, I see it is much more involved, but maybe I'm wrong. I don't understand your example. Could you use my sample and explain that further?

Also, I would think that there must be case statements, etc., to handle the different scenarios. Should I have a case statement based on the fields, CASE tFieldName = 'SSN', etc. for each field, then parse accordingly?

>I guess you have just a few possibilities for values like N - numeric, AN - alphanumeric and so on. So, grab the length of the field and then depending on the N/AN etc. format accordingly. To get the length from the 9N or 35N we can use
>
>NewString = chrtran(Format, '1234567890','')
>FieldLen = val(chrtran(Format, NewString,''))
>
>>I have these fields in a table. These can be changed if someone has a better way to handle it. I am using values like 9N in the SSN field to mean that during processing, for this carrier, the result of the SSN should be numeric and have a length of 9. For the LastName, it can be alphanumeric and have a length of 35. The dates are just as obvious. For one like MemberID, it starts with a "W" and is followed by 9 numeric values.
>>
>>I'm currently heading down a path where I have a SQL statement that calls a function for each field. In the function I evaluate that field's formatting value that is in this table. Based on that, it runs through some CASE statements and the value is formatted and returned in the SQL result for that field.
>>
>>The issue is how to code to parse apart the format values below and then handle all the possibilities. Should I parse apart the values I have so that I know that 9N means a numeric value with a length of 9, and do the same with the other fields? That seems like a lot of detailed parsing, and I wonder if it is necessary. The dates are easy, but some of the others are not.
>>
>>Any ideas?
>>
>>
>>
>>FieldName     Example of possible value
>>
>>PAYORID       ZZCERT
>>PAYORNAME     O/P MOLINA HEALTHCARE MICHIGAN
>>NPI           10N
>>SSN           9N
>>MEDICARE      10AN
>>MEDICAID
>>MEMBERID      W+9N
>>PROVIDERID    5A
>>FEDTAXID      9N
>>DOB           CCYYMMDD
>>LASTNAME      35AN
>>FIRSTNAME     25AN
>>SUFFIX        3AN
>>TRANSDATE     MMDDCCYY
>>DOSBEGIN      CCYYMMDD
>>DOSEND        CCYYMMDD
>>GENDER        1A
>>CARDNUMBER    15AN
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform