sqlplus

Why rlwrap echos “redundantly” what I type from the keyboard?

让人想犯罪 __ 提交于 2019-12-02 06:23:22
I am using the rlwrap utility under linux for command line editing while using sql*plus. Everything is fine except that the utility echoes every command I enter from the keyboard. For example suppose that I typed this statement in the prompt: SQL> select last_name from employees the same statement would be echoed again in the terminal making the output looks like: SQL> select last_name from employees select last_name from employees then when I complete the select statement on the next line, the output would look like: SQL> select last_name from employees select last_name from employees 2 where

DateDiff Function

喜你入骨 提交于 2019-12-02 05:46:14
I am trying some examples for DateDiff Function SELECT DATEDIFF(day,'2008-06-05','2008-08-05') AS DiffDate This statement gives me an error From keyword not found where expected. Why do I get this error and how can I solve it? Also, when I try this : SELECT DATEDIFF(day,datebegin,datestop) From table; I get this error "datediff" invalid identifier . How can I get day difference? What database are you using? A google search gave me this: http://www.mssqltips.com/sqlservertip/2508/sql-server-datediff-example/ DAY SELECT DATEDIFF(DD,'09/23/2011 15:00:00','08/02/2011 14:00:00') where 'DD' is used

How copy data from one database to another on different server?

旧时模样 提交于 2019-12-02 05:32:08
I have 2 DB with the same schema on different servers. I need to copy data from table T to the same table T in test database in different server and network. What is the easiest way to do it? I heard that data can be dumped to flat file and than inserted into database. How does it works? Can this be achieved using sqlplus and oracle database? Thank you! Use Oracle export to export a whole table to a file, copy the file to serverB and import. http://www.orafaq.com/wiki/Import_Export_FAQ You can use rsync to sync an oracle .dbf file or files to another server. This has problems and syncing all

Why do C-style comments make insert statement run twice?

余生长醉 提交于 2019-12-02 05:10:59
To make a long story short, I started getting ORA-00001 primary key violations and I tracked down the issue to the fact that some of my INSERT INTO statements were running twice. I then discovered that the offending commands had a C-style comment afterwards: WHENEVER SQLERROR EXIT FAILURE SET ECHO OFF SET HEADING OFF SET PAGESIZE 0 SET FEEDBACK OFF SET TIMING OFF SET TIME OFF SET TRIMSPOOL ON SET TRIMOUT ON SET LINESIZE 120 SET SQLBLANKLINES ON SET SERVEROUTPUT ON [...] INSERT INTO INF_FIELD (FIELD_ID, CATEGORY_ID, COLUMN_EXPRESSION, DISPLAY_NAME, SORT_ORDER) VALUES (17, 1, 'FOO.NAME', 'Name

CRON and SQLPLUS

徘徊边缘 提交于 2019-12-02 05:02:06
I want to run a script, which contains some sqlplus commands, in cron. The problem is, that the sqlplus command won't be executed for some reason, when executed in cron. If I execute it by myself, the script runs fine. I've checked some forums, even the topics here on stackoverflow.com and found some tips regarding the correct setting of environment variables. But even after double checking this, the script doesn't work. Here is my script: echo $ORACLE_HOME|grep "oracle" > /dev/null if [ $? = 1 ] ; then echo "Setting environment variable" # Setting oracle environmet . /usr/oracle/product/10.2

Column name repeating in query results

偶尔善良 提交于 2019-12-02 04:49:54
I am giving a select statement in SQL*Plus. It is retreiving the data but the column name is displayed every time after certain number of rows. I want the column name to be displayed only once. For example: select emp_name from employee. currently gets output: emp_name ======== raman sunil rajesh dilip emp_name ======== rahul pramod ankita I want output like this: emp_name ======== pankaj ruchi amar rakesh dilip raju rahul all under single column heading. How can I do that? You get this effect because the page size is less than the number of rows returned. The default is 14. If you set it to a

Remove Unwanted/Extra Data in SQLPLUS

喜夏-厌秋 提交于 2019-12-02 04:43:05
I am running a file via batch file Batch File: sqlplus admin/admin@SERVER @abc.sql > output.txt SQL File abc.sql: set PAGESIZE 1000 set LINESIZE 550 set echo off set head off set FEEDBACK OFF select * from S_ABC exit; Output.txt: Connected To: Oracle Database 11g................................ . . . DATA . . Disconnected from Oracle Database 11g ....... . . Please help me remove the extra data, in the starting and end of output.txt file. Joachim Isaksson -S seems to be what you're looking for; sqlplus -S admin/admin@SERVER @abc.sql > output.txt -S[ILENT] Suppresses all SQL*Plus information

When executing a script on SQLPlus, it prints a sequence of numbers instead of output

梦想与她 提交于 2019-12-02 02:39:56
问题 I'm trying to execute a script on SQL PLus, it's simple. SET serveroutput ON; DECLARE mode NUMBER(1) := 1; IF (mode = 1) THEN prompt 'HERE' END IF; prompt 'fim' I call the script from SQLPlus using sqlplus user/pw@db and @myscript.sql after a successful connection. But the output is strange for me: Conectado a: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> @myscript.sql 9 10 11 And it continues to print this

SQLPlus is trying to drop package twice

大兔子大兔子 提交于 2019-12-02 02:19:57
While executing scripts in SQLPlus I've encountered a problem: script.sql contains the following lines @some_pkg.pks @some_pkg.pkb drop package some_pkg; / After calling > sqlplus user/password@dbname @script.sql the following messages are in console: Package created. Package body created. Package dropped. drop package some_pkg; * ERROR at line 1: ORA-04043: object SOME_PKG does not exist Please, explain what's happening here. Looks like the package is being dropped twice. Is it possible to avoid the error? The rules of SQLplus command execution basically are: Execute the current text when you

subprocess gives an error. “The system cannot find the file specified”

限于喜欢 提交于 2019-12-01 23:56:53
问题 This is my code: import urllib import requests from bs4 import * from subprocess import Popen,PIPE import os connectString = 'SYSTEM/mediadot123' def runSqlQuery(sqlCommand, connectString): session = Popen(['sqlplus', '-S', connectString], stdin=PIPE, stdout=PIPE, stderr=PIPE) session.stdin.write(sqlCommand) return session.communicate() session = Popen(['sqlplus','-S','hr/hr'], stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = session.communicate() sqlCommand = "insert into food(title,