Strip a file name and use it to query a database
I am trying to strip a file name that comes in this format “AAAA_##########.txt”. (4 letters, underscore, numbers, file type.) I only want the numbers from the file name, and I want to save the number as a variable and use it to query a database.
I have tried using:
1. http://support.adeptia.com/entries/21246101-Calling-SQL-Scripts-through-custom-plugin but i am having trouble getting a result.
2. I tried using a variable in the mapper to capture the number and run the query, but I get errors with this method as well…
-
Have you tried storing the file name in a context variable within the process flow designer, then calling that file name from within the mapping?
Then you can use the data mapper substring function to store the numbers - http://support.adeptia.com/entries/23643572-substring-function
Once the number is stored in a variable, you can use the DBquery function of the data mapper to query the database.
0 -
To get the file name from the context variable in the Data Mapper refer the below link. In this link it is mentioned how to change the extension of the file:
http://support.adeptia.com/entries/23574948-only-file-name-not-the-extention
After getting the file name within the mapper you can use the substring function to get the numbers from the file name. And to escape the single quote in your DB Query you can refer the below link:
http://support.adeptia.com/entries/22260077-How-do-I-escape-a-single-quote
http://support.adeptia.com/entries/21270563-Escaping-apostrophe-before-running-DB-Lookup0
Post is closed for comments.
Comments
2 comments