Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Downside of two columns of the same name
Message
 
 
To
05/11/2020 01:08:25
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01677012
Message ID:
01677035
Views:
53
>>Hi,
>>
>>I am testing SQL Server Native Client 11.0, which works with TLS 1.2 and the SQL Server column type VARCHAR(MAX).
>>As far as CursorAdapter (CA), everything works.
>>
>>When I create reports I don't use CA but get the data via SQL Select. And in order for the VARCHAR(MAX) column to return the value that VFP 9 can understand (Memo), I am Casting the VARCHAR(MAX) fields. Here is a segment of what I will end up with:
>>
>>cSqlSelect = "select Cast(MyField1 as Text) as MyField1, Cast(MyField2 as Text) as MyField2, MyTable.* from MyTable"
>>
>>
>>Since I use the MyTable.* (above) all fields, including the MyField1 and MyField2 will be selected. Therefore, the resulting query will have two columns MyField1 and two columns MyField2.
>>
>>Two questions:
>>1. What is the downside of two columns of the same name?
>>2. How will I make sure that my VFP 9 report uses the "right" field? That is, the field MyField1 with the data instead of the empty one?
>>
>>TIA
>
>1. If you use the AS MyField1 clause, there should not be a problem, because in the report you would then reference "MyField1". The Select * would then create another fieldname for the same field, and that one you ignore in your report.
>2. Usually it is best to avoid Select *. First of all performance wise, because you may download data that is not used in the context you are working in. Secondly security wise, because you may download data that should not be visible to the user.
>
>I have another example in my specific environment: In all my reports I have a button "Export to CSV" which allows the user export the underlying data to a CSV file, so they can do whatever they like with that output. For that reason my Select statements select only those fields that should be used in this context, and also in the order in which the columns are selected. It would be awkward if the CSV file would show the columns in a completely different order as they are used to see on the report. The columns that are not visible on the reports (ID's, additional fields etc) are then further to the right. I do export the keys and foreign keys so in Excel they can do further processing, but those are usually not shown on the report output.
>
>Another advantage of doing a specific select is that you can search in the source code where the fields are referenced. For instance you have a field EmailAddress, you would find in which reports you select this field.

Thank you very much for your input. It all makes sense.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform