Question

Hi all, I have loads of sql table that i would like to transform to shapefile, but i only want to transform sql tables that have been modified the day before/yesterday. Is this possible in FME?

  • 4 November 2016
  • 7 replies
  • 1 view

Badge


7 replies

Userlevel 2
Badge +17

Hi @nishitaparmar, I think it's possible if the table has a column that stores the date when each record was inserted or updated. Otherwise, it might be difficult.

Badge

Thanks @takashi; but i don't have that for each attribute row. The only thing I have the sql function which give me the last update date for each table in the database.

Userlevel 2
Badge +17

If you can retrieve table names and those last update date by the function, this procedure might be possible.

  1. SQLCreator: Execute the SQL function to create features having two attributes - table name and last update date.
  2. Tester: Select only features whose last update date matches the day before yesterday.
  3. FeatureReader: Read features for each table.
Userlevel 2
Badge +17

If you can retrieve table names and those last update date by the function, this procedure might be possible.

  1. SQLCreator: Execute the SQL function to create features having two attributes - table name and last update date.
  2. Tester: Select only features whose last update date matches the day before yesterday.
  3. FeatureReader: Read features for each table.
Perhaps does the SQL function return a last update date for a specified single table? If so, create a table names list, read the list, and then execute the function for each table with the SQLExecutor.

 

Badge

Sounds logical to me. This is what i did, but not much success

1. SQL Creator - select name, modify_date from sys.tables (used the select statement for my non spatial sql)

2. Tester - but this resulted in reading all 213 tables instead of 3 that were modified yesterday

3. Feature Reader - Requires me to add all the tables from my DB and when i run it, it results in nothing.

Maybe my tester information is not right... really appreciate your help :)

Badge
Perhaps does the SQL function return a last update date for a specified single table? If so, create a table names list, read the list, and then execute the function for each table with the SQLExecutor.

 

this could work too... but how to read the list?

 

 

Userlevel 2
Badge +17

Sounds logical to me. This is what i did, but not much success

1. SQL Creator - select name, modify_date from sys.tables (used the select statement for my non spatial sql)

2. Tester - but this resulted in reading all 213 tables instead of 3 that were modified yesterday

3. Feature Reader - Requires me to add all the tables from my DB and when i run it, it results in nothing.

Maybe my tester information is not right... really appreciate your help :)

Two issues.
  1. The "modify_date" column of the sys.tables table (inherited from the sys.objects) stores the last date when ALTER statement was applied to the table. I'm afraid that it may not be your desired "last update date".
  2. Since the format of the date value from the query will be "YYYYmmddHHMMSS.nnn", you need to change the format (e.g. "YYYYmmdd") and then compare it with the date value of yesterday (e.g. "20161103"). The DateFormatter and the TimeStamper might help you.
See also here to learn more about the issue #1.

 

Microsoft Developers Network | sys.objects (Transact-SQL)

 

Reply