sqlplus

SQL*Plus does not execute SQL scripts that SQL Developer does

醉酒当歌 提交于 2019-11-27 06:47:17
问题 I am facing a very annoying problem. I have written (in Notepad++) some SQL scripts. Now when I try to execute them by SQL*Plus (through the command line, on Windows 7), I am getting errors like ORA-00933: SQL command not properly ended . Then I copy & paste the script into the SQL Developer worksheet window, hit the Run button, and the script executes without any problem/errors. After a long investigation, I came to think that SQL*Plus has a problem with some whitespaces (including newline

Declare bind variables in SQL*Plus

依然范特西╮ 提交于 2019-11-27 06:31:45
问题 I am using SQL*Plus. When I am using the below query, it is giving error Error report: ORA-06550: line 4, column 1: PLS-00428: an INTO clause is expected in this SELECT statement Query declare id varchar2(80) :='test123'; begin select test_quote,test_id from order_link where id = 'test123'; end; 回答1: Not sure why you're using a PL/SQL block for that. You aren't using the id you declare, and it would be better to give it a name different to the column name to avoid confusion. You can declare a

SQL*Plus how to accept text variable from prompt?

雨燕双飞 提交于 2019-11-27 05:28:57
Im very beginner in psql and i have a question. Here is the code: SET serveroutput ON ACCEPT myVariable PROMPT "Input value: "; BEGIN dbms_output.put_line('My input variable is: '||&myVariable); END; Question is very simple: How can i pass text to my variable? If i input a number it is works correctly and i can read in the log my number, but if i pass a text like "mytext" instead of a number, i got an error: old:BEGIN dbms_output.put_line('My input variable is: '||&myVariable); END; new:BEGIN dbms_output.put_line('My input variable is: '||mytext); END; Error starting at line 5 in command:

How to get Oracle create table statement in SQL*Plus

烂漫一生 提交于 2019-11-27 04:37:32
I have a table that exists in an Oracle database, but doesn't show on my list of tables in the tool SQL Developer. However, if I go to SQL*Plus, and do a select table_name from user_tables; I get the table listed. If I type desc snp_clearinghouse; it shows me the fields. I'd like to get the create statement, because I need to add a field. I can modify the table to add the field, but I still need the create statement to put into our source control. What pl/sql statement is used to get the create statement for a table? From Get table and index DDL the easy way : set heading off; set echo off;

PL/SQL ORA-01422: exact fetch returns more than requested number of rows

倖福魔咒の 提交于 2019-11-27 04:15:25
I get keep getting this error I can't figure out what is wrong. DECLARE * ERROR at line 1: ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 11 Here is my code. DECLARE rec_ENAME EMPLOYEE.ENAME%TYPE; rec_JOB EMPLOYEE.DESIGNATION%TYPE; rec_SAL EMPLOYEE.SALARY%TYPE; rec_DEP DEPARTMENT.DEPT_NAME%TYPE; BEGIN SELECT EMPLOYEE.EMPID, EMPLOYEE.ENAME, EMPLOYEE.DESIGNATION, EMPLOYEE.SALARY, DEPARTMENT.DEPT_NAME INTO rec_EMPID, rec_ENAME, rec_JOB, rec_SAL, rec_DEP FROM EMPLOYEE, DEPARTMENT WHERE EMPLOYEE.SALARY > 3000; DBMS_OUTPUT.PUT_LINE ('Employee Nnumber: ' || rec

Oracle SqlPlus - saving output in a file but don't show on screen

大兔子大兔子 提交于 2019-11-27 03:43:58
问题 Using SqlPlus for Oracle, how do I save the output of a query in a file but not show it on the terminal/prompt. 回答1: Right from the SQL*Plus manual http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch8.htm#sthref1597 SET TERMOUT SET TERMOUT OFF suppresses the display so that you can spool output from a script without seeing it on the screen. If both spooling to file and writing to terminal are not required, use SET TERMOUT OFF in >SQL scripts to disable terminal output. SET

How do I capture a SQLPlus exit code within a shell script?

青春壹個敷衍的年華 提交于 2019-11-27 03:28:22
问题 I have a KornShell (ksh) script that logins into SQL*Plus and executing a script. Within the shell script I would like to capture the status code of the SQL statement that was executed. Currently there is an error with SQL and I am unable to capture it by checking $?. How would I capture the success or error code from the sql statement and pass it to the shell script. Snippet of ksh script: sqlplus $JDBC_FBUID_U/$JDBC_FBPWD_U@$JDBC_FBDB @${FBC_HOME}/FBCS003.sql ${outputfile} if [ $? != 0 ]

How to kill a running SELECT statement

强颜欢笑 提交于 2019-11-27 00:17:52
How can I stop a running SELECT statement by killing the session? The command is continuously giving me output based on the SELECT statement, I want to stop it in between. Ben As you keep getting pages of results I'm assuming you started the session in SQL*Plus. If so, the easy thing to do is to bash ctrl + break many, many times until it stops. The more complicated and the more generic way(s) I detail below in order of increasing ferocity / evil. The first one will probably work for you but if it doesn't you can keep moving down the list. Most of these are not recommended and can have

How to display table data more clearly in oracle sqlplus

会有一股神秘感。 提交于 2019-11-27 00:15:16
I want to be able to display the resulting data from a select in a pretty way, not all columns under others. Here is the way sqlplus displays my table data: But I want to show them as: Name | Address | Phone | -------+---------------+-------------+ name1 | address1 | phone1 | name2 | address2 | phone2 | name3 | address3 | phone3 | Not each column under the other I usually start with something like: set lines 256 set trimout on set tab off Have a look at help set if you have the help information installed. And then select name,address rather than select * if you really only want those two

Why does SQL*Plus commit on exit?

ぃ、小莉子 提交于 2019-11-26 23:27:14
问题 Surely this should be the same as a termination of a session and cause a rollback? It seems to me to be the most un-Oracle thing possible. I was actually shocked when I found out that it did this More importantly - would anyone object if Oracle changed it to rollback on exit? 回答1: Funnily enough, with the 11gR2 release this week (2009-09-03), SQL*Plus now has an option to COMMIT or ROLLBACK on EXIT. Doc here I'd guess in the next few weeks/months, there'll be an 11gR2 Instant Client which you