Skip to main content
Solved

Converting SQL tables to MS Access


I have two sql tables.

One contains inspection records as shown:

The other contains questions for each inspection as shown:

I need to combine these and put them in access as such:

InspectionID; InspectionName; Date; InspectedBy; Old_Spill_ID; Spill_Type; etc.

Any help is much appreciated!

Best answer by mark2atsafe

It seems to me that you want to use the value of the QUESTION column in the second table as the name of a field added to the first table, with the value of the ANSWER column in the second table.

That's sort of easy enough, as long as the values of the QUESTION column are known in advance and can be manually defined in the output schema.

What you need to do is add an AttributeCreator transformer and set it up to create a new attribute called @Value(QUESTION) with the value of @Value(ANSWER)

See the attached workspace:

Then merge the two together using a FeatureMerger and write the data out to the known fields.

I'm using Excel instead of Access, and shortened a few of the attribute names to make it quicker for me, but it should work for you.

Regular FME'ers will notice the odd attribute name under the FeatureMerger, and red connections in the output. It seems to work OK and write those values, even though they aren't exposed in the workspace.

Hope this helps. You can download the workspace as a template from here.

Mark

View original
Did this help you find an answer to your question?

9 replies

itay
Supporter
Forum|alt.badge.img+16
  • Supporter
  • September 6, 2016

Hi,

I would read one of the tables via a reader and use a joiner to add the records of the second table.

After that it a matter of attribute renaming, deleting and such that can be managed via the attribute manager.

Hope this helps.


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • September 6, 2016

You can read both tables and use the FeatureMerger (merge on InspectionID). Use the Inspection table as supplier and the Questions table as requestor. The Merged out put will be the data of the questions with the information of the Inspection added.


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • September 6, 2016

Another way of doing this is using the SQLCreator.

This transformer will take a SQL statement as the source for your FME Workspace.

The SQL would be something like:

Select * from Questions Q, Inspections I where Q.InspectionID = I.InspectionID


  • Author
  • September 6, 2016
itay wrote:

Hi,

I would read one of the tables via a reader and use a joiner to add the records of the second table.

After that it a matter of attribute renaming, deleting and such that can be managed via the attribute manager.

Hope this helps.

I tried reading the inspections table and joining the questions and ended up with 36 records - one for each question. Then tried reversing it reading the questions and joining the inspections - didn't get that to work.

 

 


  • Author
  • September 6, 2016
erik_jan wrote:

You can read both tables and use the FeatureMerger (merge on InspectionID). Use the Inspection table as supplier and the Questions table as requestor. The Merged out put will be the data of the questions with the information of the Inspection added.

if I have 36 questions wouldn't this give me 36 results? I'm looking for on result containing all the inspection info and all the questions/answers.

 

 


  • Author
  • September 6, 2016
erik_jan wrote:

Another way of doing this is using the SQLCreator.

This transformer will take a SQL statement as the source for your FME Workspace.

The SQL would be something like:

Select * from Questions Q, Inspections I where Q.InspectionID = I.InspectionID

Don't know much about SQL but have looked at it. One problem is that two questions are the same but have different answers: person contacted - Y/N and person contacted (given name). SQL doesn't like that in the select statement.

 

 


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • Best Answer
  • September 6, 2016

It seems to me that you want to use the value of the QUESTION column in the second table as the name of a field added to the first table, with the value of the ANSWER column in the second table.

That's sort of easy enough, as long as the values of the QUESTION column are known in advance and can be manually defined in the output schema.

What you need to do is add an AttributeCreator transformer and set it up to create a new attribute called @Value(QUESTION) with the value of @Value(ANSWER)

See the attached workspace:

Then merge the two together using a FeatureMerger and write the data out to the known fields.

I'm using Excel instead of Access, and shortened a few of the attribute names to make it quicker for me, but it should work for you.

Regular FME'ers will notice the odd attribute name under the FeatureMerger, and red connections in the output. It seems to work OK and write those values, even though they aren't exposed in the workspace.

Hope this helps. You can download the workspace as a template from here.

Mark


  • Author
  • September 7, 2016
mark2atsafe wrote:

It seems to me that you want to use the value of the QUESTION column in the second table as the name of a field added to the first table, with the value of the ANSWER column in the second table.

That's sort of easy enough, as long as the values of the QUESTION column are known in advance and can be manually defined in the output schema.

What you need to do is add an AttributeCreator transformer and set it up to create a new attribute called @Value(QUESTION) with the value of @Value(ANSWER)

See the attached workspace:

Then merge the two together using a FeatureMerger and write the data out to the known fields.

I'm using Excel instead of Access, and shortened a few of the attribute names to make it quicker for me, but it should work for you.

Regular FME'ers will notice the odd attribute name under the FeatureMerger, and red connections in the output. It seems to work OK and write those values, even though they aren't exposed in the workspace.

Hope this helps. You can download the workspace as a template from here.

Mark

This works well with the exception that I run into issues with special characters (parenthesis, periods, etc.) in access. How would I expose and reword (rename) the questions?

 

 


mark2atsafe
Safer
Forum|alt.badge.img+43
  • Safer
  • September 7, 2016
jimq66 wrote:
This works well with the exception that I run into issues with special characters (parenthesis, periods, etc.) in access. How would I expose and reword (rename) the questions?

 

 

I think a SubstringReplacer (before the AttributeCreator) is the first thing I'd try.

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings