Weird Dynamic SQL in VBA Heisenbug [closed] - oracle

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a piece of code that generates a pretty long SQL statement, with some dynamic elements to it. This code has been written from the formatted query that I wrote as a parameter to my database querying function: Up to whitespace, the two queries are exactly the same. Indeed, if I copy the generated SQL and apply :%s/\s\{2,}/ /g to it in Vim, the output is identical to the original query (comments removed), with :%j followed by :%s/\s\{2,}/ /g applied... However, the queries produce different outputs!
Actually, they produce different outputs some of the time. When I tried investigating this in my querying tool, the VBA-generated SQL still didn't work as expected, whereas the original did. When I applied the above whitespace-removing transformations to the VBA-generated query, it did work; but what's weird is that the originally generated query (with the extra whitespace) suddenly started working! However, it's inconsistent: there's no deterministic pattern (under my control) that will guarantee the extra whitespace version to work. (My guess is that this may be a caching phenomena, courtesy of the database server.)
Anyway, I guess my question concerns whitespace: I was always under the impression that whitespace was irrelevant to SQL, beyond delimitation. Is this not the case, or is something else going on here? Maybe the generated SQL string is too long (> 6kb)... Any ideas?

One idea to make the query less complex from app perspective is to take the complex part and bury it in a view, then from app, just
select c1,c1, ... from myview;

Related

A generic algorithm for extracting product data from web pages [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Preface: this might seem to be a very beginner-level question maybe stupid or ill-formulated. That's why I don't require a determined answer, but just a hint, a point, which I can start with.
I am thinking of script, which would allow me to parse product pages of different online retailers, such as Amazon, for instance. The following information is to be extracted from the product page:
product image
price
availability (in stock/out of stock)
The key point in the algorithm is that, once implemented, it should work for any retailer, for any product page. So it is pretty universal.
What techniques would allow implementation of such an algorithm? Is it even possible to write such a universal parser?
If the information on the product page is marked up in a structured, machine-readable way, e.g. using schema.org microdata, then you can just parse the page HTML into a DOM tree, traverse the tree to locate the microdata elements, and extract the data you want from them.
Unfortunately, many sites still don't use such structured data markup — they just present the information in a human-readable form, with no consideration given for machine parsing. In such cases, you'll need to customize your data extraction code for each site, so that it knows where the information you want is located on the page. Parsing the HTML and then working with the DOM is still often a good first step, but the rest will have to be site-specific (and may need to be updated whenever the site changes its design).
Of course, you can also try to come up with heuristic methods for locating relevant data, like, say, assuming that a number following a $ sign is probably a price. Of course, such methods are also likely to occasionally produce incorrect matches (like, say, mistaking the "$10" in "Order now and save $10!" for a price). You can adjust and refine your heuristics to be smarter about such things, but no matter how good you get at it, there will always be some new and unexpected cases that you haven't anticipated.

What motivation is behind CheckStyle "inner type last" rule? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm re-evaluating SONAR code quality rules after upgrade to 4.4 and here is strange CheckStyle rule called 'inner type last' which is part of class design group and actually recommends to place inner classes AFTER everything including methods.
What motivation is behind this? I never expected someone to consider this approach as useful but maybe I have missed serious ideology? Checkstyle rule definition doesn't provide any ground neither quick googling (maybe I searched wrong way). Could you please point from where this comes?
This rule assumes that inner types are "side" types that deal only with internal details of the enclosing type, and so that it's not worth showing those details at the very beginning of the source file to not focus attention on them.
IMO, the only (very little) value of this rule is to ensure consistency of code structure across your source code.
Well ... this is indeed a mostly useless rule, especially because it cannot currently (5.7) be configured to enforce inner classes being declared at some other position than at the end. It can safely be disabled, I think.
However, it is the only way to enforce this part of the source file structure, so if you cannot be sure that everybody has her/his formatter properly configured, you might even want this. (Personally, I prefer inner types at the top, so that I know what they are when I read the code that's using them.)
The Checkstyle rules were originally focused on the Sun Code Conventions (1999), which did not say where inner classes should go. Also, the newer and popular Google Java Style (2014) has no opinion on this. Checkstyle even has a DeclarationOrder check, which also cannot check inner class position.
So I guess someone finally said this had to end and added InnerTypeLast. And there we have it. :-)

Coding style. Short functions vs. inline code [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What do you think fellow programmers about using short functions vs using inline code?
Example with function:
//Check if all keys from $keys exist in $array
function functionName(array $array, array $keys) {
return array_diff($keys, array_keys($array));
}
functionName($mas,$keys);
vs. using just the code:
array_diff($keys, array_keys($mas));
I think that in your example, it's superfluous. There's no need to create an extra function call and add bytes to the filesize without good reason.
Also, the inline array_diff($keys, array_keys($mas)); is a lot easier to debug for fellow programmers, than looking through your code to find out exactly what functionName() does and where it is located.
It depends on what functionName actually is.
If you're using customerDetailsAreValid throughout your code and you suddenly have to add validation of $array['email'], you're going to be grateful for the separation of intent and implementation.
If on the other hand you're wrapping array_diff in the function diffArray there isn't much point.
I think clarity is a prime concern when writing logic you hope will be around for any amount of time.
In general, I abhor inline functions. I think they are lazy, promote spaghetti code, and in general exude a complete lack of concern for style/readability/clarity on the part of the developer.
Filesize - I find this argument very arbitrary. The js files are transmitted once and then cahced. In many cases, you find descriptive names, etc, (hopefully comments) that all add to file size. If size is very important , use a file minimizer that makes a file as tiny as possible.
Looking for a function? How about trying to figure out exactly what is going on in a voluminous docReady. CTL-F usually invokes a find facility.
I will grant that there can be simple cases where an inline function detracts little from the readability of the code. However, the inline approach will never be MORE CLEAR than the alternate separation of reference and implementation.
my two cents

Auto-Completion [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How does Google or amazon implement the auto-suggestion at their search box. I am looking for the algorithm with technology stack.
PS: I have searched over the net and found this and this and many many more. But I am more interested in not what they do but how they do it. NoSQL database to store the phases? or is it sorted or hashed according to keyword's? So to rephrase the question: Given the list of different searches ignoring personalization, geographic-location etc, How do they store, manage and suggest it so well.
This comes under the domain of stastical language processing problems. Take a look at spelling suggestion article by Norvig. Auto - completion will use a similar mechanism.
The idea is that from past searches, you know the probability of phrases (or better called bigram, trigram, ngram). For each such phrase, the auto complete selects the one having max value of
P(phrase|word_typed) = P(word_typed|phrase) P(phrase) / P(word_typed)
P(phrase|word_typed) = Probability that phrase is right phrase if word typed
so far is word_typed
Norvig's article is a very accessible and great explanation of this concept.
Google takes your input and gives TOP4 RESULTS ACCORDING TO THE RANK IDs [if results are less it returns parameters as empty strings] given to different keywords which differ dynamically by the hit and miss count.
Then, they make a search query and returns 4 fields with url, title, and 2 more fields in Json, omnibox then populates the data using prepopulate functions in Chrome trunk.

Writing a code beautifier [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'd like to write a code beautifier and i thought of using Ruby to do it. Could someone show me a place to get started? I've seen a lot of code beautifiers online but I've never come across any tutorials on how to write one. Is this a very challenging task for someone who's never undertaken any projects such as writing a compiler, parser, etc. before?
(Is there another langauge which would be more well suited for this kind of task, excluding C/C++?)
Python has an interesting feature - it exposes its own parser to scripts. There are examples that use the AST - abstract syntax tree - and do the pretty printing.
I'm not aware that Ruby exposes its own parser to its scripts in such a way, but there are parsers for Ruby written in Ruby here.
Well... I think the initial steps are what you'd do for any project.
Write a list of requirements.
Describe a user interface to your program, that you like and won't prevent you meeting those requirements.
Now you can write down more of a "code" design, and pick the language that would be easiest for you to meet that design.
Here's some requirements off the top of my head:
Supports code beautifying of these languages: Ruby, Python, Perl
Output code behaves identically to input
Output has consistent use of tabs/spaces
Output has consistent function naming convention
Output has consistent variable naming convention
Output has matching braces and indentation
Make as many as you want, it's your program. ;p I was kidding about the Perl, but I think every language you support is going to add a more work.

Resources