I sometimes get one of those little ideas while banging away on the keyboard, in the realm of "wouldn't it be nice if...". Usually, I forgot about them the next day and I rarely, if ever, think of it again... Or at the least, not for a few months. I can't ever think of those little ideas when people ask me what kind of features I'd like... So now, I'll write it down. As a reminder to myself, or maybe a bit of inspiration to you, who knows.
Today, I was trying to write down an SQL insert statement. It took a huge amount of time, mainly because how it needs to be typed is so different from what it is based upon — and yet it's so very strictly coupled syntaxwise. Let me give an example. The statement could be something in the form of:
insert into bloob (a, b c) values (x, y, z);Simple, no? until the field names and values are not so simple any more.
Usually, the source is a description of a database table. Suppose you can get it into a form of tab delimited rows separated by newlines. In short: a plain tab delimited file. For this file the structure would look like:
bloob a x b y c zAll pretty standard, and likely, it's quite easy to get the data from other sources into this shape, using standard tools.
Now, what I'd like to be able to, is to paste this data into the shape of the SQL statement, plain and simple. That is: it should make use of a template like, for example
insert into $table (@fields) values (@values)given that array items would be joined by a comma (can be parameterized) and that there's a way to link the variables to the source data fields. It would be nice if extra formatting could be applied to each array item (as if with
map
) before it gets inserted — such as wrapping quotes around them.
How? I don't know. I haven't thought that through yet.
And no, I don't want to write a dedicated little script to do each specific case for me.
If, by any chance, you know of an editor that has this or a similar feature, I'd like to know about it.
withhttp://use.perl/org/
with the default text (here the URL) selected, ready to be overtyped by a different text.<a href="http://use.perl/org/">http://use.perl/org/</a>
Or, supposing you have the database table data, formatted as described in the root post, as part of the text document, and you can select it, and apply the SQL-ifying template to it. I think it would be easier to use when you have, say, 5 of those tables and you have to write such an SQL statement for each of them.
Taking one step further still, it's be nice if the "template" could be based on something you just wrote. Thus: you'd paste the template over the selected text, applying the template to the data it replaces.