SQl Developer Single Query result tab please - oracle-sqldeveloper

In the free application SQL-Developer (provided by Oracle), I tried searching around for this but couldn't immediately find a solution. I find the opening of multiple SQL query result window/tabs mildly annoying. I'm sure there are very useful cases for this feature, but my question is:
Can we turn the multiple query result windows to just one (Toad style). If there's a shortcut key for this, that would be super awesome.

SQL Developer 4.0 (2013)
Close all the Query Result tabs
Tools > Preferences
Database > Worksheet > uncheck "Show query results in new tabs"

So, it turns out this is a bug. If you look closely, you'll notice that for each query run, your results tab is automatically being pinned, causing each new query run to need it's own new tab to display the results.
The automatic pinning is only supposed to be enabled when you explicitly go into Tools->Preferences->Database->Worksheet->"Automatically Freeze Result Tabs".
It is an identified bug, that Oracle fixed with SQL Developer 2.1.1.
Go to oracle.com and download the latest version and this should go away. It was definitely very annoying.

Instead of "Run Statement" click on "Run Script"(F5). This would give the output of two queries in the same Query Result window.

Directly to the database or from an application? Do you mean returning one result set from multiple tables together or multiple result sets in one pane? Are you using SQL 2000, 2005, 2008, or something else? The question is vaguely worded, but I'll try to help anyway.
For the purposes of this answer, I think you're trying to query the database directly. Open SQL Server Management Studio 2005 or newer (Not sure if this works in 2000), click New Query, and type the multiple queries into the pane. i.e.:
select * from table1
select * from table2
will return two result sets in the same window/pane.

Unpin helps keep current tab for next query.
(I am using Oracle SQL Developer 22.x)

I found that this was happening in SQL Dev v4.0.2.15 because I was running 2 SELECT statements. Running one SELECT at a time re-used the Results tab.

Related

VSCode - SQL Server (msql) Extension - Prevent query execution on tab change

I am using the SQL Server (msql) extension in VSCode and really liking it.
However when I want to run 2 queries I am discovering that the results will refresh every time I switch result tabs.
Both results tabs are in the same well (seems to not happen when they are in different wells)
Can I prevent this from happening and retain the original query results?
"mssql.persistQueryResultTabs": true

IN Oracle SQL Developer can you pop-out query results/script output

Was wondering if it was possible to pop-out the query results/script results window/s into separate "windows" windows, so for example I could have my query worksheet on one monitor and the output/results on another via an dual monitor set-up.
Thank you.
No.
But, you CAN take a query worksheet itself out of the main display and move it over to another monitor.
'Float' the worksheet - right click on the editor tab, 'float'.
Then you can minimize the editor bits of the worksheet so it's full screen results
that would look like this

Can I debug a PostgreSQL query sent from an external source, that I can't edit?

I see how to debug queries stored as Functions in the database. But my problem is with an external QGIS plugin that connects to my Postgres 10.4 via network and does a complex query and calculations, and stores the results back into PostGIS tables:
FOR r IN c LOOP
SELECT
(1 - ST_LineLocatePoint(path.geom, ST_Intersection(r.geom, path.geom))) * ST_Length(path.geom)
INTO
station
(continues ...)
When it errors, it just returns that line number as the failing location, but no clue where it was in the loop through hundreds of features. (And any features it has processed are not stored to the output tables when it fails.) I totally don't know enough about the plugin and about SQL to hack the external query, and I suspect if it was a reasonable task the plugin author would have included more revealing debug messages.
So is there some way I could use pgAdmin4 (or anything) from the server side to watch the query process? Even being able to see if it fails the first time through the loop or later would help immensely. Knowing the loop count at failure would point me to the exact problem feature. Being able to see "station" or "r.geom" would make it even easier.
Perfectly fine if the process is miserably slow or interferes with other queries, I'm the only user on this server.
This is not actually a way to watch the RiverGIS query in action, but it is the best I have found. It extracts the failing ST_Intersects() call from the RiverGIS code and runs it under your control, where you can display any clues you want.
When you're totally mystified where the RiverGIS problem might be, run this SQL query:
SELECT
xs."XsecID" AS "XsecID",
xs."ReachID" AS "ReachID",
xs."Station" AS "Station",
xs."RiverCode" AS "RiverCode",
xs."ReachCode" AS "ReachCode",
ST_Intersection(xs.geom, riv.geom) AS "Fraction"
FROM
"<your project name>"."StreamCenterlines" AS riv,
"<your project name>"."XSCutLines" AS xs
WHERE
ST_Intersects(xs.geom, riv.geom)
ORDER BY xs."ReachID" ASC, xs."Station" DESC
Obviously replace <your project name> with the QGIS project name.
Also works for the BankLines step if you replace "StreamCenterlines" with "BankLines". Probably could be adapted to other situations where ST_Intersects() fails without a clue.
You'll get a listing with shorter geometry strings for good cross sections and double-length strings for bad ones. Probably need to widen your display column a lot to see this.
Works for me in pgAdmn4, or in QGIS3 -> Database -> DB Manager -> (click the wrench icon). You could select only bad lines, but I find the background info helpful.

SSMS 2008 adding ALTER TABLE WITH CHECK ADD CONSTRAINT to my Procs

I have searched Google, BOL, and several forums and can't find the answer:
I have a very small data base application that I write some queries and SPs to extract data. A few days ago I opened an exsiting SP to find that something had added code similar to that below, sometimes multiple lines referring to every table in the database. When I set up a new simple SP like "Select * from TinyTable" and re-open it, the same code has been inserted.
The last thing I remember doing was reviewing the settings for results to grid in SSMS 2008 R2. I'm afraid I may have accidently changed a setting but I've spent hours reviewing them and can't identify what it might be.
I have considered reinstalling SSMS to set back to defaults but I have a linked server set up to solve a collation conflict, and don't want to cause problems with that. If anyone can point me in the right direction I'd appreciate it. I may be searching using the wrong terminology but can find nothing. As I say, I don't know for sure a change to the SSMS tools options is the problem but I suspect it could be something I have done.
Here's a sample of what gets automatically inserted at the bottom of every one of my procs:
GO
ALTER TABLE [dbo].[tblLot] WITH CHECK ADD CONSTRAINT [FK_tblLot_tblLocation] FOREIGN KEY([LocID])
REFERENCES [dbo].[tblLocation] ([LocID])
You likely have Tools > Options > SQL Server Object Explorer > Scripting > Object Scripting Options > Generate script for dependent objects set to True. Try changing the value to false.

How to obtain ready-to-execute queries?

Is it possible to obtain SQL queries with inlined parameters of EF context?
I would like to be able to copy-paste queries into management studio and execute them.
I work with ctx.Database.Log delegate, but it traces queries with parameters' values placed inside comments, eg:
.... WHERE [Extent1].[Name] = #p__linq__0
-- p__linq__0: 'ApproveReminder' (Type = AnsiString, Size = 8000)
Which are not runnable without first editing them.
If I understand your question properly, you can do this with SQL Server Profiler.
Run it, and then set up a profile watching the server that EF is connecting to. While it's running, execute your code so that the EF query you're interested in runs against the server. Then stop the profile.
If you peruse what it's recorded, you should be able to identify your query quite easily. Then click on it and the full query text will appear in the window at the bottom of the screen.
You could use Hibernating Rhinos Entity Framework Profiler (commercial software) or you could do this:
var query = context.Customers.Where(...);
((System.Data.Objects.ObjectQuery) query).ToTraceString();
http://visualstudiomagazine.com/blogs/tool-tracker/2011/11/seeing-the-sql.aspx