Saving SQL files into specific folders in Oracle - oracle

I am using Oracle 11g. When I open a new SQL file writing the command
ed filename.sql
A new file is created in my bin folder with the name as filename but, I want them to be in separate folders for my convenience. I am developing 3 application(well for my practice only). I want them to store in different folders for each project. I tried all of the following none of them worked please tell me how can I save the files into specific folders.
ed erp/logindetails.sql
ed 'erp/logindetails.sql'
ed "erp/logindetails.sql"
ed 'erp\logindetails.sql'
ed erp\logindetails.sql
These commands except where I used "" worked and opened the default text editor with the name afiedt.buf which I am getting when I enter only edit. No files are created with any of the above command.

You're giving EDIT a relative path to the file; since your current working directory seems to be the bin directory that the SQL*Plus directory is in (is this Windows, and are you running a shortcut that sets the working directory, maybe?) it will try to create a file like %ORACLE_HOME%\bin\erp\logindetails.sql, and you're unlikely to have created an erp directory there. Giving the full path to the directory will work:
edit c:\users\dibya\projects\erp\logindetails.sql
for example.
As noted in the documentation, EDIT will search for existing files, but that involves setting an environment variable - which you'd have to change as you move between the projects. You might find it easier to edit the files in the OS and just run them from SQL*Plus.
You might also be able to use separate shortcuts to launch SQL*Plus for each project, each setting the 'start in' directory to a project-specific location - then just edit logindetails.sql would be looking in the right place by default. Or, from a command prompt cd into the relevant project-specific directory and launch SQL*Plus from there, which is effectively what a shortcut would do.

Related

Stata can't open file saved in local cloud storage folder on Mac

I am using Stata on a Mac. I updated the OS to Monterey today. If I try to open a .dta file---that is saved on my local computer in a folder that syncs to OneDrive---from code in the Do File Editor/Command prompt (where I refer to the file using its full file path), it doesn't open. The error is r(601) - File ... cannot be found.
But if I click on it in Finder, it opens in Stata just fine. After I have done this, I can then open this file in Stata by running the exact same Stata code that didn't work before. Somehow it seems like Stata can't see the file/folder initially, but then it can. I am not sure if this has to do with the OneDrive file/folder permissions or something else.
If, in Stata, I change the directory to the correct directory using cd and then load the file (without referring to the path), it works. However, I would like to be able to refer to the file using the entire file path and not have to change the directory each time.
Interestingly, if I change the directory to the correct directory using Change working directory in the File drop down and then try to load the file using the file path, it also works. But if I do not do the drop down and write out the cd using code, and try accessing the file using the path it doesn't work!
Somehow Stata has to initially "see"/"access" the correct folder (in a very particular way) before being able to access it with the file path. Very strange. (Just to be clear, if I do not change the directory to the correct directory and then try to load the file using its file path, it doesn't work.)
I also tried creating a file using texdoc init... (in a folder that already exists, but that has not been used by Stata before) and get this error:
could not create directory .....
mkdir(): 693 could not create directory
texdoc_mkdir(): - function returned error
texdoc_init(): - function returned error
<istmt>: - function returned error
I do not get this error if I instead use another folder in the same directory that I have previously used.
I think that the error I am encountering is the same or similar to this one (with no acceptable answer): https://answers.microsoft.com/en-us/msoffice/forum/all/onedrive-folder-doesnt-exist/e6b97d47-3f6a-4863-bf68-d3a02832f2bb

"You must type a file name" error thrown, when I create a .gitignore file on Windows

When I try to do this, I get the following error:
Obviously, Windows Explorer doesn't allow me to create this type of file patterns. How can I overcome this problem?
In the File Explorer, the trick is to call your file .gitignore. and it will remove the ending .
A strange behavior but, hey!, it works 😅
Or create it from a text editor...
Windows Explorer doesn't allow you to create files that consist essentially of a file extension only. This is because Windows Explorer has the option to hide file extensions, leaving you with a file you cannot see (see Why doesn’t Explorer let you create a file whose name begins with a dot?). This is not a restriction of Windows itself, or the file system in use, though.
To create a file named .gitignore, you will have to use another tool to create it. A common solution is to create a text file (e.g. test.txt), open it in Notepad, and select Save As... to rename the file to .gitignore.
The Windows command interpreter also allows you to create files without imposing the additional restrictions of Windows Explorer. A more direct solution would then be to create the file from the command line. This can be done using the following command:
copy NUL .gitignore
Note: When dealing with files that don't have a name, it's helpful to disable the option "Hide extensions for known file types" in Windows Explorer. Otherwise Windows Explorer might show files with no names, or hide them altogether.
In cmd, just type
echo. 2>.name_you_want
or
. 2>.name_you_want
to create a file.
If creating a directory, just type
mkdir .folder_name_you_want
Use command line instead.
I was also having the same error. The problem was . at the start of file or folder name.
So I created it by command line.
You can do this with command prompt for folder creation:
mkdir .folder_name

Set global working directory alias in Git bash (Windows)

I've been trying for literally hours to set a global alias that I can use when I open Git bash on my Windows machine to cd to a specific location.
I want to be able to simply type the alias to get to the location. I've tried every which way. The attempt that got me closest was based on this: https://superuser.com/questions/602872/how-do-i-modify-my-git-bash-profile-in-windows
...but it seems that to get it to work upon relaunching of bash, I have to use source .bashrc, which I don't want to do. Help appreciated.
I just jury rigged a solution with a simple shell script that acts like a global alias. If someone has a better solution, please do tell.
Opened text editor and wrote the following two lines:
#!/bin/bash
cd blah/blep/directory_of_choice
Saved it as a text file with a descriptive name (like dirjump) somewhere and copied it.
In file explorer, navigated to the bin folder in the MinGW64 installation, e.g. "C:\Program Files\Git\mingw64\bin"
Pasted the file into this bin folder.
While viewing the contents of the bin folder referenced above in Windows file explorer, from the menu bar selected "view > options", which opened the "folder options" dialog. Selected the "view" tab here and unchecked "Hide extensions for known file types" and clicked ok.
Deleted the ".txt" extension from the file copied into the bin folder.
To call this shell script that has the same result as a global alias, typed the following in Git bash:
. dirjump (the space between the dot and the dirjump MUST be included)

.sh files default to read-only on OS X Yosemite

I am learning my way through shell scripts and just created one with vim.
Every file I create with .sh extension seems to be defaulting to read-only mode for every group in the ls -l command. I have tried creating files with several editors and in several locations and always get the same result.
So my question is, I know i can chmod the files so i can execute them, but is there something i can do to create them executable already and not change every single one of them?
As with any UNIX-like system, file creation is affected by the umask, which masks out file access bits when files are created.
You can change the default umask by editing the shell start-up configuration files, however I wouldn't recommend doing that.
If you want to change it so that all files you create have the executable bit set by default, then what about files that are not executable? I have always worked on shell scripts with the edit, chmod, run cycle and I don't feel it's a big problem.

Executing binary files with a shebang

I created a simple program that takes the path of a directory as an input, creates an archive of that directory (converting it into a single file), adds a shebang to that file (so that the contents of the file can be easily extracted), and writes the file to the base directory of the specified path.
The problem is that the file does not extract itself when I double click on it. Instead the operating system (I'm using Ubuntu 11.10) tries to open it with gedit. This obviously shows the shebang, random gibberish, and the contents of the archived files.
I made the file executable, first by using chmod +x; and when it still didn't work I tried chmod 777. However it still refuses to execute the file with the shebang when I double click on it. Perhaps this is because it's not a pure text file.
Interestingly when I try to execute the file directly from command line it reads the shebang and extracts the contents of the archive properly. So there's nothing wrong with my file format. I don't know much about what operating systems do when you double click on a file but I would sure like to understand.
It surely makes no sense to add a shebang to a file if you still need to manually execute it from the command line. One advantage could be that you don't need to specify the program to open it with but I believe that's hardly an advantage. Any help will be greatly appreciated.
Update 1:
The program that creates the archive is called opm. It can be installed via the node package manager using the following command:
npm install opm
After that you simply use opm to pack and unpack directories for you. For example if I have a directory called test in my home directory then I can open a terminal and execute the following command to pack it:
opm test
This will create an archive of the directory called test.pack in the home directory. The .pack file has the shebang #!/usr/bin/opm. Opening a file with the extension .pack with opm tells it that it's an archive and opm unpacks it in the same directory.
Note: Change the name of the test.pack file if you do not want it to overwrite your existing test directory.
I added the shebang to the .pack file so that it would extract itself when I opened it. However that doesn't seem to work. Nevertheless if I run one of the following command then it works:
./test.pack
You may check my source code and make any modifications to the program as you may wish to.
Update 2:
Alright I created the following .desktop file for opm and stored it in the $HOME/.local/share/applications/ directory:
[Desktop Entry]
Type=Application
Version=1.0
Encoding=UTF-8
Name=OPM
GenericName=Object Packer and Minifier
NoDisplay=true
Comment=JavaScript Package Manager
TryExec=opm
Exec=opm %f
Terminal=false
MimeType=application/opm
Now I was able to associate .pack files with opm by right clicking on a .pack file, going to the Properties window, the Open With tab, and setting opm.desktop as the default application. Now I am able to unpack a .pack file by simply opening it.
However I would like to know how to associate .pack files with the mime type application/opm. Currently the .pack files are associated with application/x-java-pack200. How do I do so? Is it better if I use a different extension (e.g. .opm)? By associating the packed archives with the mime type application/opm will the OS open them with opm by default without having to explicitly set a default application from Properties > Open With?
If there's already a MIME-type associated with .pack then you'll want to use a different extension (.opm) to associate with your MIME-type (application/opm). The way you automatically associate a program that opens files of a specific MIME-type is with xdg-mime .
Alternatively,
Edit ~/.local/share/applications/mimeapps.list and put your MIME/application combo under [Default Applications] like so:
[Default Applications]
application/opm=opm.desktop;
Place your opm.desktop file in ~/.local/share/applications/ folder. (You've already done this)

Resources