Sometimes, out of nowhere, you discover you've acquired some wisdom over the years. Wisdom, in this case, was probably inherited from my Unix/Linux background... namely, break a problem into chunks, and attack it left to right.
For example, take a list of names, sort them and get rid of the redundant ones.
cat myNameListFile.txt | sort | uniq > myUniqListOfNames.txt
Unix has a nice way of pipe'ing the output from one app or tool to the next. As you become familiar with the available tools, you start thinking in terms of how you can sub-divide tasks.
For example, you need to generate some customer numbers from your database. This is a one off task, though it has the possibility of being useful further down the road.
You're not sure about the SQL. You can do it, but it's going to take awhile to figure out that lengthy thing. And feeling comfortable with Unions and Joins can be quite a challenge. So, why not do it in chunks? Why not do it in a series of SQL calls, feeding the results of the first query into the second.
But what if that isn't quite working for you in terms of doing so confidently.
This is where a bit of bash scripting or Groovy comes in. There are more tricks to bash shell managing SQL queries and results than you may know. I will address that in a future post. It's how I survived before I discovered Groovy.
Here's the strategy:
1. Create a SQL query that gets all your customers' ID.
2. Execute the query from Groovy so that you can capture the results in a list.
Maybe there were lots of conditions applied to that customer list. Perhaps they're the customers who are not suspended and they reside in Ohio and they're new accounts as of 3 years ago. Simple considerations, but nonetheless, considerations that lengthen your thought process and your SQL query.
Now you can move to the next phase or chunk. All of a sudden that grand design of a SQL query has gotten a little bit simpler.
For example, take a list of names, sort them and get rid of the redundant ones.
cat myNameListFile.txt | sort | uniq > myUniqListOfNames.txt
Unix has a nice way of pipe'ing the output from one app or tool to the next. As you become familiar with the available tools, you start thinking in terms of how you can sub-divide tasks.
For example, you need to generate some customer numbers from your database. This is a one off task, though it has the possibility of being useful further down the road.
You're not sure about the SQL. You can do it, but it's going to take awhile to figure out that lengthy thing. And feeling comfortable with Unions and Joins can be quite a challenge. So, why not do it in chunks? Why not do it in a series of SQL calls, feeding the results of the first query into the second.
But what if that isn't quite working for you in terms of doing so confidently.
This is where a bit of bash scripting or Groovy comes in. There are more tricks to bash shell managing SQL queries and results than you may know. I will address that in a future post. It's how I survived before I discovered Groovy.
Here's the strategy:
1. Create a SQL query that gets all your customers' ID.
2. Execute the query from Groovy so that you can capture the results in a list.
Maybe there were lots of conditions applied to that customer list. Perhaps they're the customers who are not suspended and they reside in Ohio and they're new accounts as of 3 years ago. Simple considerations, but nonetheless, considerations that lengthen your thought process and your SQL query.
Now you can move to the next phase or chunk. All of a sudden that grand design of a SQL query has gotten a little bit simpler.