JProfiler: how do I populate query param in JDBC view? - jprofiler

As per the title.
The article here doesnt help.
Tried to go Session->Session Setting->Database Settings->JDBC, tick all available tick boxes, but I still get unpopulated query in my JDBC events view.

The query parameters are appended at the end of the SQL statement in square brackets in a map-like syntax, you can see that in your screenshot: [1: ..., 2: ..., 3:...].

Related

How to query string inside a record in Google BigQuery? Docs not working

I want to query a subset of a record in the bitcoin blockchain using the google bigquery database. I go here and click view dataset https://console.cloud.google.com/marketplace/details/bigquery-public-data/bitcoin-blockchain. Then, on the left sidebar, it seems you have to click the dropdown at 'bigquery-public-data', then click 'bitcoin_blockchain' then 'transactions'. Then on the right you have to click the button 'Query Table'. This is the only way I have found to select the table -- just copying and pasting the command below won't recreate the error.
Based on the table that appears following the above instructions, I noticed that outputs are arecord type. I would like to view only one string from inside the record. The string is called output_pubkey_base58.
So I read the docs, and the docs imply the command would be:
SELECT outputs.output_pubkey_base58 FROM `bigquery-public-data.bitcoin_blockchain.transactions` LIMIT 1000;
I get an error: Cannot access value on Array<Struct<output_satoshis ... .. I tried outputs[0].output_pubkey_base58, didn't work
The annoying thing is that this problem is in the same format as the first example, where they query the citiesLived.place parameter from inside the citiesLived record in the same kind of command. : https://cloud.google.com/bigquery/docs/legacy-nested-repeated
You need to unnest the array into a new variable.
SELECT o.output_pubkey_base58
FROM
`bigquery-public-data.bitcoin_blockchain.transactions`,
UNNEST (outputs) as o
LIMIT
1000
Feel the confusion here is about legacy SQL and standard SQL. UNNEST must be used in standard SQL as described in document: https://cloud.google.com/bigquery/docs/reference/standard-sql/migrating-from-legacy-sql#differences_in_repeated_field_handling
Selecting nested repeated leaf fields
Using legacy SQL, you can "dot" into a nested repeated field without needing to consider where the repetition occurs. In standard SQL, attempting to "dot" into a nested repeated field results in an error.

Efficiently access long text from a column in a SQL Server database

Newbie question: I'm using SQL Server on a remote server where I cannot use UDFs of any type. I am using a database where one column is a text column containing several paragraphs of text per entry. As I test my code, I would like to have a way to efficiently access these columns a few at a time.
Currently, the only way I can find to do this is using eg:
SELECT TOP 25 ReportText
FROM MyDb.Table1
...which, of course, gives the output in the Results window, as a single string of characters that I have to keep dragging the column width wider and wider and wider in order to try to see.
What am I missing? I don't need it to look pretty, I just need to be able to see it efficiently....
As #JohnSpecko pointed out in a comment, results to text is exactly what I needed. It is turned on by hitting (ctrl+t) before running your query. Thanks!

How to pass arguments from an Access form to SQL Query with "IN" clause?

I'm having trouble getting this query to display any results.
SELECT Evaluation_Table.*
FROM Evaluation_Table
WHERE (Evaluation_Table.Test_ID
In ([Forms]![Test Data]![Group_Test_IDs]));
The control, [Group_Test_IDs] is a textbox that contains a string of IDs. For example it just contains numbers separated by commas: 1,2,3,4,5.
While debugging, If I changed the query to look like this, it properly returns records:
SELECT Evaluation_Table.*
FROM Evaluation_Table
WHERE (Evaluation_Table.Test_ID
In (1,2,3,4,5));
I can't seem to find the proper syntax. SQL in Access can sometimes be weird.
I can't seem to find the proper syntax.
That's because there is none.
The IN selection cannot be dynamic; your only option is to rewrite the SQL via VBA.

YEARFRAC function on SQL Server not working

I was happy to find you can use an Excel-like YEARFRAC function in MS SQL server (http://technet.microsoft.com/en-us/library/ee634405.aspx), but for some reason I get an error that states:
'yearfrac' is not a recognized built-in function name
when I try to run my query. Here is my code:
SELECT CUSTOMER_ID, PRODUCT_SKU, SUB_START_DATE, SUB_EXP_DATE,
YEARFRAC(sub_start_date, sub_exp_date) AS START_TO_END FROM ...
For the record, I have double-checked the dates are in proper datetime format, and I tried both using no basis (as shown above), and using the available 1-4 bases. I also tried removing the column alias (START_TO_END). None of these worked. Any ideas?
No, that is in Analysis Services (DAX specifically), not in T-SQL. The header on the page does not make it clear which section of the documentation you're in, but look at the table of contents on the left...
Sorry the screen shot is double size, it's because of my Retina screen giving 144dpi instead of 72dpi.
Anyway, you should be able to replicate this functionality with your own UDF or, if you always calculate a specific way, it might even be simple enough to do inline. A calendar table may help.

Is there a way to parser a SQL query to pull out the column names and table names?

I have 150+ SQL queries in separate text files that I need to analyze (just the actual SQL code, not the data results) in order to identify all column names and table names used. Preferably with the number of times each column and table makes an appearance. Writing a brand new SQL parsing program is trickier than is seems, with nested SELECT statements and the like.
There has to be a program, or code out there that does this (or something close to this), but I have not found it.
I actually ended up using a tool called
SQL Pretty Printer. You can purchase a desktop version, but I just used the free online application. Just copy the query into the text box, set the Output to "List DB Object" and click the Format SQL button.
It work great using around 150 different (and complex) SQL queries.
How about using the Execution Plan report in MS SQLServer? You can save this to an xml file which can then be parsed.
You may want to looking to something like this:
JSqlParser
which uses JavaCC to parse and return the query string as an object graph. I've never used it, so I can't vouch for its quality.
If you're application needs to do it, and has access to a database that has the tables etc, you could run something like:
SELECT TOP 0 * FROM MY_TABLE
Using ADO.NET. This would give you a DataTable instance for which you could query the columns and their attributes.
Please go with antlr... Write a grammar n follow the steps..which is given in antlr site..eventually you will get AST(abstract syntax tree). For the given query... we can traverse through this and bring all table ,column which is present in the query..
In DB2 you can append your query with something such as the following, but 1 is the minimum you can specify; it will throw an error if you try to specify 0:
FETCH FIRST 1 ROW ONLY