Quick and Dirty Coding Hacks

I have been working with Oracle technology since 2010, and know my way around a database well enough, and do an okay job supporting our E.R.P. system at my job. However, I’m no PL/SQL nor SQL expert. Far from it. And some days I just don’t have the time nor the inclination to “Ask Tom”, so I resort to the tools I am familiar with, no matter how elementary/rudimentary they may be, to get me through the day.

For example: I recently was in a situation where I had to copy three of our prod tables down to a non-prod schema, renaming the tables and each column in the table, for training purposes for a new staff member, so he could follow along with the way the tables were structured in a training manual. I work at Temple University (Go Owls!) which is an Ellucian Banner school, and Banner’s table-naming standards are such that the column headings each have the table name in them. For example, on the SPRIDEN table, every column is named SPRIDEN_[something],  as in SPRIDEN_ID, SPRIDEN_FIRST_NAME … you get the picture. But the training manuals referred to tables in a training schema I no longer had access to,  the  SWRIDEN table, and all column names SWRIDEN_[something]”. Some of these tables have hundreds of columns and I was not inclined to type hundreds of ALTER TABLE” statements into my SQL Developer editor window. Maybe I’m just lazy.

So after creating the new tables by copying the prod versions, via SQL Developer, I could not find a way to globally rename the column headings for the newly copied/renamed tables. If there is such a way to do this, and anyone who may be reading this article knows how, I’d greatly appreciate a comment telling me how to do so. In other words, is there a command where I can say: rename all columns on a table from __ to __?

Instead, I handled this with the tools at hand that I’m familiar with. My Methodology may make you cringe. But remember- this is  “quick and dirty” hack # 1.

First thing: I set my SQL Developer Database preferences for Drag and Drop to format select statements for me, so that I would not have to type out each field name on these very large tables.

Drag and Drop

Next, I selected all of the columns and copied them: (Ctrl+C) …

copy and paste_spriden-image2

… then pasted them onto a new Excel worksheet, in the second column, B (Ctrl+v)

paste_excel-column2-image3

Since each column name is followed by a comma, I globally removed them on the worksheet by selecting the column, and doing a “find & select” then going to the “replace” tab. I just replaced the commas with a space (Literally a hit of the space bar).

remove the commas-image4

Next, I copied that column, with its removed commas, on to another column, skipping one in between. So I went from column “B” to “D”, making sure I  pasted as “values”:

 

copy and paste whole column B to D-image6


paste to D-image7

Now I had identical data in columns “B” and “D”, and needed to replace the old column names with the new. So just like I used “find & select” to replace the commas in column “B” with spaces, I did the same thing in column “D”, replacing the old table name with the new, or in my case, replace SPRIDEN with SWRIDEN:

replace-all_columnd-imag8

So far I had:

two new columns-image9

I was then ready to build the “ALTER TABLE” statements.

In column A1 of the spreadsheet, I entered my alter statement: Alter table SWRIDEN rename column. In C1 put to and in E1, the semicolon to end the SQL statements I’m creating:

prepare your alter statements1-image10

To copy the alter statements down to the last row in A that is adjacent to B,  don’t click and drag!  The easiest way to fill a column in Excel is by hovering over the bottom right corner of the cell you want to copy down, until the small square black box appears in that corner, then double click on the small black box:

the little black square1-image11
Double click on the small black box in the right corner to fill the column of data to the last row of the adjacent column

12c1

Fill columns C  to”  and in E the semicolon

image13a


 

The alter statements have now been built.  Then I simply copied and pasted them right into SQL Developer and executed:

or right into sql developer-image16


 

I hope this little hack will be useful to others out there who may be new to SQL, and just need a fast way to get something done, with older, more familiar tools. Look for more quick and dirty hacks to come. I’d love to hear some of yours as well!

 

Be My Guest – Justin Biard

cleanCoderOne day in the Twitterverse, a  young colleague, Justin Biard, posted a quote regarding professional’s abhorrence to “messes”. That really resonated with me. As one who has frequently had to  “put out fires” and had to clean up bad data caused by others’ (and sometimes her own) erroneous code, nothing instills more fear and frustration than those four little words: “We have a problem”. I fear job aborts, Oracle ORA-  errors, endless loops… the list goes on and on. Just writing the words gives me a pit in my stomach.

I asked Justin what the source of the quote was from and he told me about a book he was reading called The Clean Coder.  We chatted a bit more about the gist of the book, and if he thought it was a good read, and then inquired as to whether he’d consider posting a review of the book here, as a guest blogger. He happily agreed! So without further ado, I give you Justin Biard:


Reading The Clean Coder

Do you have forty-plus years of experience in technology or programming and consider yourself to be a professional? Do you have a pretty good sense of what it means to be a professional programmer? Do you actively mentor and share that knowledge with others around you? Yes, or no, I’m humbled that you would take the time to stop by and read these words. Thank you.

 What are we doing here and why is Helen letting this guy ramble on her blog?

As someone who loves learning how technology works, I *could* be called a nerd, a geek, a techy, or maybe just… a slightly introverted person with Internet access and a penchant for computers. Whatever you call it, I love what I do. I also hang out with other people who love what they do. And because everything sounds better with an “Ugh” at the end, we form a group and call it ODTUG (pronounced Oh Dee Tug). This is not a shameless plug for the user group, this is how Helen and I were introduced, through a fellow “nerd”. (We are looking at you Chet @oraclenerd)

Recently I finished reading The Clean Coder: A Code of Conduct for Professional Programmers, by Robert C. Martin. In Mr. Martin’s book a quote struck a chord with me so I tweeted about it.

” …you will drive the system into a swamp from which it may never escape. Professionals fear messes far more than they fear blind alleys.”

This got Helen and I talking about the book and mentorship. Helen asked if I’d be willing to share my thoughts on the book. So here we are.

Note: On the topic of mentorship, Helen started a great series here on her blog. (Stop reading this post, read her posts if you haven’t yet, and then come back here to finish up!)

Is this book about programmers with good personal hygiene?

No (well… maybe?) This book is about professional hygiene. Its about the mindset, the habits and attitudes that a programmer should pursue to achieve professionalism. It is also full of what seem to be pragmatic opinions, grounded in truth.

If you are a professional programmer or mentor of programmers already then you should expect to read this book for enjoyment, rather than education.

Is this book a technical reference with lots of code samples and recipes for solutions?

No, this book is definitely not a technical reference. It does not contain many, if any, code samples. However, it is an insightful look into the history and thought process of someone with over four decades of experience making mistakes as a developer and learning from them.

I work in (or with) IT, maybe even manage a team of developers, but my career is not focused on full-time programming, will I get any value from reading this book?

It depends. To tell you the value of reading a book without first understanding your own needs could be like trying to give fish to a fisherman or it could be like giving delicious bread to the famished. Are you the fisherman (professional programmer or mentor) or the famished (early career developer) possibly starving for mentorship?

Assuming we care about your opinion……. What did you think about this book?

Of my own opinion… Personally, I really enjoyed the book. It is well written. Martin uses plain English and tells plenty of interesting stories. For me, it was a lot like watching an old friend or mentor teach a class of up and coming developers and getting to take notes on technique and style.

On mentorship, I would use this book as a conversation starter to help define professionalism as a programmer and to understand the development philosophy of a team. Martin touches on a wide range of topics including things like:

* When to say “No” and how to say “Yes”
* Coding
* Various levels of testing
* Time management
* Estimating
* Collaboration

I am not a full-time “programmer” (in the traditional sense) and I don’t need to agree with all of Martin’s choices or tool selections, but even then, the spirit of his advice was still relevant. The breadth of topics he covers is a thoughtful roadmap to professionalism as a programmer. Don’t buy this book because I thought it was good. Research it for yourself. Read some reviews on Amazon (or wherever you buy books). Ask around and get other opinions.

Whether or not anyone else reads the book, I hope you all aspire to be (or to continue being) professionals and that you love what you do.

Thank you Helen, for the opportunity to share my thoughts with your readers.

Cheers!


Read more by Justin at cubenoob.com and icodealot.com

Follow Justin on Twitter @icodealot


A Lesson in Mentoring – Part II

The Universe is trying to tell me something.

Over the past 18 years as a programmer/developer, I haven’t been the most patient person when it came to someone not knowing something “I” thought they should know.

I even had a “Three strikes and you’re out” rule: I’d happily answer your technical question the first time, more frustratingly the second time, probably sarcastically the third time – and then I was done. If you dared ask me the SAME question the fourth time – you would not get an answer.

Pretty darn smug of me.

And then..after obtaining a master’s degree in Educational Leadership, and going on to various other leadership-focused training, including the excellent program from the good folks at ODTUG, I looked around and found myself on higher ground.

I was promoted at work, to an Assistant Director, and had been elected to serve on several board positions for some of the organizations I had been involved with. All that leadership training was paying off.

One of those board positions – particularly, the one as Social Responsibility Chair for the Philadelphia based Network of Women with Careers in Technology (NWCT) led me to an opportunity to participate in a city wide initiative, “Philly Tech Hire”. 

Philly Tech Hire was created in response to the White House’s “Tech Hire Initiative”.  Announced in the spring of 2015, the program slated Philadelphia along with 21 other communities in the nation, such as NY and Detroit, to spearhead local programs to help people living in the margins, for example: low-income workers, women and veterans and other non-traditional “techies”, become tech-savvy developers through non-traditional paths. The ultimate goal is to lead participants  to speedy employment in the technology sector, where talent is needed and where jobs are usually stable and plentiful. (See more at White House Tech Initiative and Philadelphia Works)


Whlogo


Key partners in Philly’s Tech Hire Initiative are Randstad Technologies, Comcast, PNC, LinkedIN, The City of Philadelphia and Technically Philly. Part of the campaign includes a “Shark-Tank” like pitch competition, the brain-child of Greg Payton, Vice President PNC Asset Management Technology. In the pitch competition, four teams of 4-5 participants from the pool of job-seekers are headed up by two mentors, who’s task it is to come up with a technical solution to meet a need for a local non-profit.

Myself along with a few other women from the NWCT board, were invited to be mentors for one of the four teams. Project Kickoff was to be early August, and the final pitch night would be the end of September.

On August 5th, I met the four people participating on my team, “Team Randstad”, and we were given our challenge: Develop an app and process for the Free Library of Philadelphia, which would support their “e-Gadgets” desk – which is basically a “help desk” where people in the community can bring in their electronic “gadgets”, e.g. smart phones, iPads, and get on-the-spot tech help for any issues they may have.

My team initially was made up of a young man attending the Code Academy, who had a few java courses under his belt, a Project Manager working a temp job, a young father of six children under the age of seven who was working full time and going to school, and another young man from the Code Academy who could not make the kickoff meeting. After a few bumps in the road and scheduling conflicts, we ended up losing the two Code Academy students and my final team now has a young woman who has come from the restaurant industry, who is just learning to code, and a Navy Vet, who has been learning to code, but has now been called up to go to Afghanistan in October.

It was pretty much around August 5th that the universe started tapping me on the shoulder and said, “Hey. You. Helen. Yes you..are you ready for the testing of your patience and leadership?” I, along with my co-mentor, had to take this diverse group of four people, complete strangers to myself and to each other, from completely different backgrounds and completely different skill sets and levels, and create a tangible product for the free Library, pitch it, and win it, all in about 8 weeks time.

What an amazing experience it has been. We have had teleconferences, webex meetings, and only one face to face through the past six weeks. I have bitten my tongue so often I’m surprised it hasn’t fallen off. There has been a complete absence of eye-rolling and sarcasm on my part and I’m actually enjoying watching them grow into a cohesive unit, working together. Last night was our “dress rehearsal” for the pitch, and I think we actually have a decent end-product to present to the library on September 30th. There were times in the beginning, with personalities clashing and ideas head butting where I worried it would never happen. But, we did it. They did it, and last night one of the participants told one of the sponsors what a good mentor I had been through it all.

That was the greatest compliment she could have given me. It humbles me.

And also yesterday, this showed up in my inbox: A LinkedIn contact mentioned a quote from Facebook’s Sheryl Sandberg: “Leadership is about making others better as a result of your presence and making sure that impact lasts in your absence.”

This is what the universe is teaching me: Lessons in patience, acceptance that not everyone will grasp something the first, second, or even third time. There is no place for smugness in true leadership.

An Accidental Mentor

Yesterday evening I had dinner and drinks with a very bright young woman, Lori S, who is trying her hand at starting her own business. She’s at one of the pivotal points in her life where she is self-reflecting, trying to figure out her place in the universe and how she can make her mark. At the end of the evening she posted a nice message on social media that included a thank you for “the mentoring”.

Interesting. I hadn’t thought of myself as “mentoring” her during the evening, but lately I’ve been feeling like a  “Wise Old Sage” among the young up-and-comers in Philadelphia, especially among the entrepreneurs and innovators on our tech scene.

If you weren’t already aware, Philadelphia’s young tech scene is thriving. Just Google “Philly’s tech scene” and you’ll be inundated with links on the topic. Over the past year I have been attending a lot of networking events amongst the talented and enthusiastic techies in our city.  Many times I find I am one of the more mature and seasoned folks in the room (Though I usually drag my husband along – who is ten years older than I – thus preventing me from being THE OLDEST person in the room – Thanks, Joe!), and Lori’s thank you brought something to light last night: Sometimes if you’re the most experienced person in the room, people are going to LISTEN to what you’re saying. And suddenly there you are: A role model without even trying.

That’s a little scary. It brings to mind Uncle Ben telling Peter Parker, “With Great Power Comes Great Responsibility”. I’m realizing I have to mind my words, go easy on the sarcasm (really difficult for me), and take great care with the advice I dole out – because they are LISTENING.

A Day of Firsts

Flipping the calendar
Flipping the calendar

Today started a new month.

I love that feeling flipping the calendar to a new month brings: A wrapping-up of last month’s projects, pitfalls, victories and life lessons, rewarded with a clean slate.

And so, here it is. After much nail-biting, self-reflection, self-doubt, quashing of the internal “impostor”, and with the encouragement of many smart and talented friends, I present to you, a blog.

Just writing those words doesn’t even feel natural – not yet. I’m stumbling, but bear with me. I promise to get better.

My intention for this space is to offer up cheery little technical antidotes, amid lessons-learned and (hopefully) some humor.

Welcome, September 1st. Thanks for the hope. Thanks for the fresh start.