sqlplus

How to pass a variable from a Windows Batch File to SQL*Plus

廉价感情. 提交于 2019-12-04 16:35:54
I want to pass a variable from a Windows Batch File to SQLPLUS, while displaying sql result batch variable should print along with the sql result. Result should be stored in csv file. How can I do that. This is possible in Unix(shell script) how can I do that in Windows(batch script). I want to pass a variable from a Windows Batch File to SQLPLUS Just pass it as an argument to the SQL script. And use substitution variables in the same order that of the arguments list &1 &2... For example, mybatchfile.BAT: sqlplus -S username/password@sid @c:\sql\mysqlfile.sql 1000 7369 mysqlfile.SQL: update

How to check the privileges (DDL,DML,DCL) on objects assigned to Schema, Roles in oracle Database?

陌路散爱 提交于 2019-12-04 16:16:54
Most of the time we struggle with silly things to get the detail of privileges on Schema, Role and their Objects and try to find some easy way to get all the detail about it along with there pseudo queries code to generate grant statements in bulk for further execution. So here we are to get it. A little brief about data dictionary view prefix: ALL_ -Describes PUBLIC Object grants. USER_ -Describes current user Object grants. DBA_ -Describes all object grants in the database. Useful views information: ROLE_ROLE_PRIVS -describes the roles granted to other roles. ROLE_SYS_PRIVS -describes system

“set -o noglob” in bash shell script

元气小坏坏 提交于 2019-12-04 14:30:21
问题 I would usually write SQL statements inline in a Bash shell script to be executed in SQLPlus as- #! /bin/sh sqlplus user/pwd@dbname<<EOF insert into dummy1 select * from dummy2; commit; exit; EOF This would work just fine and will insert rows into dummy1 when executed. A colleague of mine came to me the other day with a script like below (simplified) #! /bin/sh sqlvar="insert into dummy1 select * from dummy2;commit;" echo $sqlvar|sqlplus user/pwd@dbname The issue with this is when executed

Getting ORA-01033: ORACLE initialization or shutdown in progress

别等时光非礼了梦想. 提交于 2019-12-04 13:57:03
问题 Yesterday I installed Oracle 12c Enterprise edition on my laptop. When I tried to connect to DB via SQLPLUS i got the below error C:\Users\USER>sqlplus SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 28 14:12:46 2016 Copyright (c) 1982, 2014, Oracle. All rights reserved. Enter user-name: userdb Enter password: ERROR: ORA-01033: ORACLE initialization or shutdown in progress Process ID: 0 Session ID: 0 Serial number: 0 I tried all the tricks mentioned on internet but couldn't get rid of this

EXECUTE recognizes a stored procedure, CALL does not

馋奶兔 提交于 2019-12-04 12:31:06
When I try to run a stored procedure using EXECUTE, the proc runs fine. When I use CALL, I get "ORA-06576: not a valid function or procedure name" . I am connecting directly via toad. Why can't I use call? I have tried both of these Calls: CALL(BPMS_OWNER.DAILY_PARTITION_NOROTATE('MIP_TEST',5,5,'MIP_TEST_',5,FALSE,TRUE)); CALL BPMS_OWNER.DAILY_PARTITION_NOROTATE('MIP_TEST',5,5,'MIP_TEST_',5,FALSE,TRUE); The reason I need to use CALL is that our platform parses SQL before we send it to Oracle, which for whatever reason does not support EXECUTE. Simply because call requires that you add

Preventing sqlplus truncation of column names, without individual column formatting

别等时光非礼了梦想. 提交于 2019-12-04 12:18:15
问题 By default sqlplus truncates column names to the length of the underlying data type. Many of the column names in our database are prefixed by the table name, and therefore look identical when truncated. I need to specify select * queries to remote DBAs in a locked down production environment, and drag back spooled results for diagnosis. There are too many columns to specify individual column formatting. Does sqlplus offer any option to uniformly defeat column name truncation? (I am using SET

SqlPlus query issue (Package Spec and Body)

 ̄綄美尐妖づ 提交于 2019-12-04 09:24:54
I am trying to get package spec and body from sqlplus by doing so.. select text from all_source where name = 'PACK_JACK' order by line; but I am only getting its body not the spec.. what I have to change to get both of them as one file.. Thank you There is a TYPE column in all_source view. The type can have 2 values - 'PACKAGE' and 'PACKAGE BODY'. So to get the spec, select text from all_source where name = 'PACK_JACK' and type = 'PACKAGE' order by line; and to get the body select text from all_source where name = 'PACK_JACK' and type = 'PACKAGE BODY' order by line; Additionally, instead of

How do you get the next value in a sequence into a variable?

我是研究僧i 提交于 2019-12-04 05:06:49
So I'm writing a stored procedure and am having trouble getting the next value of a sequence into a variable. The sequence name is passed into the function and is stored as a varchar2 variable. How can you get the next value in that sequence into a local variable. Something like this? create or replace procedure next_val (p_sequence_name varchar2) as v_nextval integer; v_select varchar2(100); begin v_select := 'select '||p_sequence_name||'.nextval from dual'; execute immediate v_select into v_nextval; dbms_output.put_line('Nextval is: '||TO_CHAR(v_nextval)); end; 来源: https://stackoverflow.com

How to store result from SQLPlus to a shell variable

我只是一个虾纸丫 提交于 2019-12-04 04:39:30
My requirement is to store the result of an sqlplus operation into a variable in my shell script. I need the result of the following operation which is in my .sh file sqlplus 'user/pwd' @test.sql I have already tried testvar = 'sqlplus 'user/pwd' @test.sql' but that doesn't work. EDIT:: I changed it to testvar=sqlplus foo/bar@SCHM @test.sql and it says SQL*Plus:: not found [No such file or directory] I tried with testvar=$(sqlplus foo/bar@SCHM @test.sql) and it gives the same error. When I try without the variable assignment like below sqlplus foo/bar@schm @test.sql it works fine Employ

Mac OS 安装配置 instant client

人走茶凉 提交于 2019-12-04 03:03:30
1. 下载资源 下载三个文件(oracle 官网) instantclient-basic-macos.x64-18.1.0.0.0.zip instantclient-sdk-macos.x64-18.1.0.0.0-2.zip instantclient-sqlplus-macos.x64-18.1.0.0.0.zip 2. 创建目录 解压缩文件 sudo mkdir -p /opt/oracle 将下载文件复制到刚刚创建的目录下(/opt/oracle/) sudo cp ****.zip /opt/oracle/ 按上面顺序解压缩zip unzip instantclient-basic-macos.x64-18.1.0.0.0.zip unzip instantclient-sdk-macos.x64-18.1.0.0.0-2.zip unzip instantclient-sqlplus-macos.x64-18.1.0.0.0.zip 解压第一个以后会产生一个 instantclient_18_1目录(版本不同产生的目录不同),然后解压 sdk和sqlplus 执行命令以后会自动解压到instantclient_18_1,里面会创建一个sdk和sqlplus的目录。 然后我们将sdk里的文件全部copy到instantclient_18_1目录