sqlplus

Is there a .Net interface to Oracle SQLPLUS?

跟風遠走 提交于 2019-12-01 04:49:14
I'm developing some automation to control the execution of SQL scripts. The scripts are run through SQL*PLUS and contain PL/SQL calls in them (hence I can't run them through ODP.NET ). I was wondering if there was a .NET interface to SQL*PLUS ? If so has anyone used it? You can do it in C# with this piece of code: public int execString(string scriptFileName) { int exitCode; ProcessStartInfo processInfo; Process process; int timeout = 5000; processInfo = new ProcessStartInfo("sqlplus.exe", "@" + scriptFileName); processInfo.CreateNoWindow = true; processInfo.UseShellExecute = false; process =

Can SQL*Plus read environment variables from the machine is it running on?

感情迁移 提交于 2019-12-01 04:14:42
I'm aware that the database engine itself is (often) on another machine and that SQL*Plus has no direct way of reading those environment variables, but I'm in a tricky situation where I merely need the environment variables from the machine the client itself is running on. Is there a way to cheat these values into the SQL*Plus client from within a single script that will be run in SQL*Plus? The script consists of a single begin/end PL/SQL block, but if I need to use SQL*Plus directives of the set/define/variable sort that shouldn't be a problem either. What I can't do is alter the way that the

How to verify sqlplus can connect?

浪子不回头ぞ 提交于 2019-12-01 03:46:01
I'd like to know if its possible to get sqlplus output in some way to discover if my database is up. I want to run a list of scripts on a database, but before I do that, I want to know if the database is up and running with my script. Here is what I tried: sqlplus /@DB1 << EOF > select 1 from dual; > EOF It cannot connect, but the return code of sqlplus still says "everything OK"! SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 28 10:06:41 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

Displaying the constraints in a table

南笙酒味 提交于 2019-12-01 03:24:44
Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created. Create table Teams ( TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key, TeamName VARCHAR2(40) ); This is the code I am using to show my constraints. SELECT constraint_name, constraint_type, search_condition FROM USER_CONSTRAINTS WHERE table_name = 'Teams'; I am a rookie so I want to make sure I understand what is wrong. I have tried to drop the table thinking that my constraints did not take - I did not, nor did I receive any

Max column width in Oracle spool to file

痞子三分冷 提交于 2019-12-01 03:22:21
I have a script like this: SET ECHO OFF SET FEEDBACK OFF SET VERIFY OFF SET HEADING OFF SET TERMOUT OFF SET TRIMOUT ON SET TRIMSPOOL ON SET WRAP OFF SET LINESIZE 32000 SET LONG 32000 SET LONGCHUNKSIZE 32000 SET SERVEROUT ON SPOOL C:\Export.txt SELECT XMLELEMENT("element1",xmlelement("element2",xmlattributes(.....))) FROM --TABLENAME-- WHERE --CONDITIONS-- The output should be a file containing a list of rows with the complex xml inside, but when the length of the XML generated is longer than 2000, SQLPlus trims to 2000 and go to the next line. There is a way to force SQLPlus to write all the

oracle sqlplus wrapping results

烈酒焚心 提交于 2019-12-01 01:46:26
When I run a query like: SELECT * FROM CAR; the results appear but each row wraps to several lines. How can I stop this wrapping so that each row appears on a single line? Had the same problem, even after changing set lines to a big number: select * from dba_directories; OWNER DIRECTORY_NAME ------------------------------ ------------------------------ DIRECTORY_PATH --------------------------------------------------------------------------------------------------------------------------------------------------------------- SYS DPUMP_DIR C:\xxx SYS CLEAN_PUMP_DIR D:\yyy SYS TCMCLEAN_DPUMP_DIR

Can SQL*Plus read environment variables from the machine is it running on?

前提是你 提交于 2019-12-01 00:52:03
问题 I'm aware that the database engine itself is (often) on another machine and that SQL*Plus has no direct way of reading those environment variables, but I'm in a tricky situation where I merely need the environment variables from the machine the client itself is running on. Is there a way to cheat these values into the SQL*Plus client from within a single script that will be run in SQL*Plus? The script consists of a single begin/end PL/SQL block, but if I need to use SQL*Plus directives of the

Can Sqlplus read the contents of a file into a variable?

不羁岁月 提交于 2019-12-01 00:23:57
I've been tinkering with sqlplus for awhile now, and I've managed to get sqlplus to read the contents of a file into a substitution variable as such: exit | sqlplus -s login/pass@db @script.sql "`cat file.txt`" This mostly works as my script requires... even newlines in the file are preserved. However, I was only using a sample file which was 50 or 60 bytes in size. The actual files I'll end up using will be at least a few kilobytes. So it was at this point I decided to check the max size of a substitution variable: 240 characters. Is there a way within my sqlplus script to read a file's

Displaying the constraints in a table

谁都会走 提交于 2019-12-01 00:01:17
问题 Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created. Create table Teams ( TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key, TeamName VARCHAR2(40) ); This is the code I am using to show my constraints. SELECT constraint_name, constraint_type, search_condition FROM USER_CONSTRAINTS WHERE table_name = 'Teams'; I am a rookie so I want to make sure I understand what is wrong. I

How to override >2499 character error in Oracle DB?

夙愿已清 提交于 2019-11-30 22:50:46
I have a Oracle query which I'm executing through shell script and in that my query is getting exceeded the maximum length of 2499. I'm getting error SP2-0027: INPUT IS TOO LONG(> 2499 CHARACTERS) - LINE IGNORED Here are some options for working around SQL*Plus line length limitations: Upgrade to 12.2(?) client. On 12.2 the client allows up to 4999 characters. Which is infuriating in a way - if Oracle finally admits that 2499 is not enough, why did they only increase the limit to 4999? Add line breaks. Split the results into multiple lines. If using Windows make sure to use both carriage