Open several SQL Scripts on Toad starup - oracle

i am using Toad for Oracle V11.
And i'm already using View>Toad Options> File to execute on new connections to set some parameters when i start a new connection.
Here is also the option File to load on startup, but here i can only select a single file to open on startup. But I always need three different scripts when I open Toad and i don't want to merge them to one file.
Is it somehow possible to always open those three different scripts when i open toad?

You can't do that, as far as I can tell.
See whether creating a project (using the Project Manager; it's the 6th icon in my TOAD 14 toolbar) helps, as you can add folders or folder items (that would be your scripts) to it.

Related

OleDbException Cannot open file dbf

After I run a query, SELECT SomeColumn FROM SomeTable, via the command window in VFP, I'm unable to access that table from C# using the OleDb Provider until I close VFP.
System.Data.OleDb.OleDbException: 'Cannot open file \\some-server\some-share\SomeTable.dbf.'
It's like VFP is not closing the file handle after executing the query.
How do tell VFP to close the file/table w/o having to close VFP?
use
without any argument closes the table\cursor in current work area.
use in (select('SomeTable'))
closes it in any work area, only if it is open.
Both commands are scoped to current data session. If you are using any sessions other than the default one, then you need to loop those sessions and close in there.
An easier way would be to execute:
set exclusive off
in VFP before opening any tables. Then the tables would be opened shared, and you could open them both from VFP and outside.
Or make that a permanent setting by going to Tools -> Options -> Data and unchecking "Open Exclusive":
BTW, I replied thinking about any table that you would open by using "use" or "select ... from thatTable".
Your question is vague though, maybe you mean the table is created as a result of the query (your query doesn't have that destination though). If that is the case, then the created table is in exclusive use until you close it (using one the commands at top).

SQLite .DB file contents shown in Visual Studio Form DataGridView component

So I have a database file (name.db) on my desktop, as well as a project folder containing my program. I want to create a form to test my program, however I cant seem to get my contents from my database into the form, so I can't even test my code. I try to "connect a database" from the tools menu, but none of the options will allow me to connect my ".db" file.
Below are the images of what I'm trying to do, so you can get an idea.
The Form
The menu of different database options, none of which work
The code for the form
Files on the Desktop
The Problem is, that you never make any requests/queries to your database. Since your database could and most probably does contain mutliple tables you should run a corresponding sql query and then display the result. The following link should give you a good starting point how to integrate sqlite with c++.

Use dbms_output.put_line in Datagrip for .sql files

I started to use Datagrip for my PL/SQL (school) projects that need the use of DBMS_OUTPUT.PUT_LINE. Before this I was using Oracle SQL developer and I was able to use DBMS_OUTPUT by adding the following:
SET serveroutput ON;
There is a related question that shows how to enable or disable showing the contents of the DBMS_OUTPUT buffer but this only works for the Database Console tool window. How can I apply this to any .sql file? Currently, I am copying the content of my .sql files and run it in the Console tool window but there must be a better way.
Turn on this setting in the Output pane:
I second the comment from Prometheos II. Jakob also seems to say the same.
As you might know, the .sql scratch files HAVE to be associated with a console.
You need to toggle the Enable SYS.DBMS_OUTPUT option icon in the associated console and you do see the effect when executing from the associated .sql file.
Steps:
Open your .sql file
Associate it with a console
Open the console and enable Enable SYS.DBMS_OUTPUT option
Go back to the .sql file and run your code. You'll be able to get the DBMS_OUTPUT in the console output.
Suboptimal design by JetBrains, but it works.
My IDE version: IntelliJ 2018.3 Ultimate (DataGrip uses the same code, I think)
Couldn't comment to existing sections due to low rep. Hence, added a new answer.
When everything else fails, read the documentation: Showing DBMS_OUTPUT for Oracle:
For Oracle, you can enable or disable showing the contents of the
DBMS_OUTPUT buffer in the output pane. To do that, use
the apropriate icon (note by LF; can't reference that image) on the toolbar
of the Database Console tool window (Ctrl+F8).
For all that are reading this for version(s) > 2021.1
You can enable the output in the connection properties.
Source
This also works for sql files in DataGrip. Like moscas writes you need to activate the output console toggle button 'Enable SYS.DBMS_OUTPUT'.
Also you need to wrap it with begin end:
begin
dbms_output.put_line('test');
end;
Finaly found it! The previous answer didn't read the question and answer for intelij instead of datagrip which have completely different interface.
For 2021.1 right click on the console list in the service window and there should be a enable DBMS_OUTPUT when you right click.

Permission denied when trying to import a CSV file from PGAdmin

I'm using PGAdmin 1.14.3.
When I try to execute an import command:
COPY grad(country_code, postal_code, place_name, admin_name1, admin_code1, admin_name2, admin_code2, admin_name3, admin_code3, latitude, longitude, accuracy)
FROM 'C:\\Users\\denis\\Desktop\\BP2Project\\USA\\US.txt';
I get a
ERROR: could not open file
"C:\Users\denis\Desktop\BP2Project\USA\US.txt" for reading:
Permission denied SQL state: 42501
I did look up other similar questions and none of them solved my issue.
I logged in as user "postgres" who is the superuser. I don't see why I'm missing permissions. I'm on Windows 7.
The permissions article mentioned in the answer by Houari and Flimzy is a good reference material, but a direct answer (the quick fix I used) is:
Right click the folder containing the data file(s) that permission was denied to and then click Properties.
In the Folder's Properties window, select the Security tab.
Click the Edit button.
In the "Permissions for the folder" window that opened, click the Add... button.
Type Everyone into the "Enter the object names to select" text area box.
Click OK and the window will close.
Verify that the default Read & Execute permissions were set to Allow via the check checkbox in the previous window.
As JLB notes, Write permission is needed if dumping from PostgreSQL, opposed to copying into it.
Click OK and the window will close.
Click the Apply button in the Folder Properties window.
Now you can run the SQL COPY statement that needs to access those files.
Once done, return to the Folder's Properties window.
Click the Edit button.
Select the Everyone entry in the "Group or user names:" field.
Click the Remove button.
Click OK on the remaining open windows.
The permissions have now been returned to what they were.
The user Postgres must have read access on the file from which you are about to copy.
Look at this article to see how to modify files' security access on Windows.
Ok, this is how got COPY command working,to export a table to CSV, step by step.
Pls note that I am using pgAdmin 111.
Create the target folder you want to export a table to. E.g C:\myExports
Set a read/write permission on this folder following the steps below :
Right click the folder containing the data file(s) that permission was denied >to and then click Properties.
In the Folder's Properties window, select the Security tab.
Click the Edit button.
In the "Permissions for the folder" window that opened, click the Add... button.
Type Everyone into the "Enter the object names to select" text area box.
Click OK and the window will close.
Verify that the default Read & Execute permissions were set to Allow via the >check checkbox in the previous window.
Click OK and the window will close.
Click the Apply button in the Folder Properties window.
This is the tricky part, inside myExports folder create a blank CSV file with your desired name.E.g employee.csv
Then run the Copy command like this :
copy employee to 'C:\myExports\employee.csv' delimiter ',' csv;
employee is the table name in this example..
Hope this helps.
If you don't want to give permissions to Everyone, you can add permissions to the account that started the service. In the Control Panel - Administrative Tools - Services, copy the account name in the 'Log On' tab. (On my system the account is called 'Network Service'.) Then share the folder with the CSV-file with this user as shown in the answer above.
To solve this problem you must give permission to the CSV file because that CSV file present in a COPY command are read directly by the server, but not client application. So to make this file accessible to a server we must give full read-write permission so that Postgresql user can read and write on that file.
Reference: article showing step by step procedure.
I just ran into this error and even after adding postgres to permissions on the file folder and the file itself, it still didn't work. So, I put the file in a public folder. On Windows this was the path: "C:\Users\Public\Documents\census.csv." It worked!
Responses to this problem on different threads go something like this
1. "Tell me exactly what command you used"
2. "Make sure you have right permissions"
3. "Just use /copy"
I just tried giving permissions to Everyone on the cvs file I am trying to copy from, and it is still giving me the permission denied error. I think this functionality is broken and has been broken for multiple consecutive releases over multiple consecutive versions of Windows.
for me and I've just spent some long hours on this.
I have a central db residing on a HP box running 14.04 postgresql-9.5 pgAdmin3 postgis-2.2, shares are made through a tweeked Samba share. My clients are using a mixture of windows 10.1, 7, 8.1 and I have one ubuntu 14.04 desktop.
I'm working with large tables updating records and normalising data and have built the routines around SQL copy statements from CSV files which were made from the core COPY public.table_1 TO (the share folder I'd set up in Samba https://www.youtube.com/watch?v=ndAYZ0DJ-U4) '/srv/samba/share/[filename].csv'
I can then update the database once the tables have been amended with COPY table_1 from '/srv/samba/share/test.csv' USING DELIMITERS ',' WITH NULL AS '' CSV HEADER; from any of my clients.
The key as far as I have been able to determine is that the clients doing the updating must be superusers, also everything must tie up in terms of users as there are 4 servers working together here Postgresql, Samba, UNIX and WINS
All of my users are registered on each of the servers with the same username and password homogeneity is the main factor.
I had tried for a long time moving things about and trying various naming conventions but in the end it was http://www.postgresql.org/message-id/CFF47E56EA077241B1FFF390344B5FC10ACB1C0C#webmail.begavalley.nsw.gov.au that sorted me out it was like a big switch clicking in. chown 777 on your shares and group management was an important learning curve but., the hours I've spent on this will reap rewards down the line... Loving Ubuntu loving life and loving the spirit of open source but that just might be sleep deprivation kicking in... IT WORKS
I am trying to execute SQL commands directly from a file in psql 14, and landed the same error.
The reason is that "postgres" user is different from the 'admin' or the main user of the operating-system. So, this main user denies "postgres" to access files from its file system.
Although there is a way to bypass it.
Windows lets any user access the files in 'C:\Users\Public' and Linux distros allow files in '/tmp' folder to do the same.
So, whatever files you are trying to access from postgres' terminal, keep the files in
'C:\Users\Public' for Windows
'/tmp' in Ubuntu
Read from the orginal source of this answer
use \copy command from psql instead with this config:
sudo psql -U postgres -d <your-db> -c "\copy <your-query-or-table> TO '<pat-to-save-file>' WITH (FORMAT CSV)"

Accessing a Windows file folder from Oracle Forms 10g

I would like to have a block in an Oracle 10g form that would show all of the PDF files in a particular folder on the user's C drive. The user should at least be able to double-click on the file to open it, and ideally be able to delete and rename the files, too.
The list of files should show the filename (obviously) as well as the size and date of the file.
The forms are running on a Solaris 10 server, accessed via Internet Explorer.
Any thoughts on how, or even if, that's possible?
You need to get WebUtil. It is a Free Forms add-in product specifically designed to solve the problem you are having. And a few other.

Resources