sqlplus

I want to pass a variable argument to external SQL file (PL/SQL with SQL*Plus)

帅比萌擦擦* 提交于 2019-12-20 01:38:10
问题 I have search this forum and via google for an answer for my question, but I can't find a specific answer for my challenge. That is why I am asking it here to hope to receive an answer from one of you guys. I want to work with multiple SQL files, whereas one SQL file is the control file that executes the other SQL files with parameters. That file is called: startup.sql I have a table with all my values (don't mind the names of the columns, I changed them for my post). create table control ( S

Max column width in Oracle spool to file

眉间皱痕 提交于 2019-12-19 05:49:37
问题 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

Max column width in Oracle spool to file

为君一笑 提交于 2019-12-19 05:49:08
问题 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

oracle sqlplus wrapping results

99封情书 提交于 2019-12-19 04:55:58
问题 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? 回答1: Had the same problem, even after changing set lines to a big number: select * from dba_directories; OWNER DIRECTORY_NAME ------------------------------ ------------------------------ DIRECTORY_PATH --------------------------------------------------------------------------------------------------------------------------

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

谁说我不能喝 提交于 2019-12-19 04:14:52
问题 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

sqlplus spooling: How to get rid of first, empty line?

北慕城南 提交于 2019-12-18 12:59:14
问题 I'm doing the following spooling statement: SET VERIFY OFF SET FEEDBACK OFF SET HEADING OFF SET TRIMSPOOL ON SET TERM OFF SPOOL &pathRelations START scripts/relations.sql &parent SPOOL OFF SET TERM ON The scripts/relations.sql file contains a simple select statement. Unfortunately, the spooled file contains an empty line as the first one in the file. This line causes trouble in our framework. Of course I could get rid of these line through sed but ain't there a way to suppress its creation in

how to pass variable from shell script to sqlplus

混江龙づ霸主 提交于 2019-12-18 12:02:35
问题 I have a shell script that calls file.sql I am looking for a way to pass some parameters to my file.sql. If I don't pass a variable with some value to the sql script, I will have to create multiple .sql files with SELECT statement and all that would change is few words. My shell script calls file.sql: sqlplus -S user/pass@localhost echo " Processing triples" ./load_triples.sh BUILDING/Mapping_File BUILDING Y >> load_semantic.log @/opt/D2RQ/file.sql exit; EOF And this is how my file.sql looks

How to show errors in sqlplus

岁酱吖の 提交于 2019-12-18 09:34:16
问题 I would like to know how to show errors in sqlplus. try to compile a view alter view SYS.DBA_XML_SCHEMAS compile; I have the message : ERROR at line 1: ORA-04063 : view altered with compilation errors. I try : show errors; it says : No errors I try : show errors view SYS.DBA_XML_SCHEMAS it says : LINE/COL ERROR 0/0 ORA-00942 : table or view does not exist If I could compile with errors, the view must exist or it would tell me that the view does not exist. I dont know how to display the

How can I export an Oracle table to tab separated values?

喜夏-厌秋 提交于 2019-12-18 09:06:16
问题 I need to export a table in the database to a tab separated values file. I am using DBI on Perl and SQL Plus. Does it support (DBI or SQL Plus) exporting and importing to or from TSV files? I can write a code to do my need, But I would like to use a ready made solution if it is available. 回答1: It should be relatively simple to dump a table to a file with tab-separated values. For example: open(my $outputFile, '>', 'myTable.tsv'); my $sth = $dbh->prepare('SELECT * FROM myTable'); $sth->execute

How to create a menu in SQLPlus or PL/SQL

人走茶凉 提交于 2019-12-17 20:54:51
问题 I have several scripts that I would like to start from a menu presented to the SQLPlus user. Something like: Please make a selection: 1: Do script a 2: Do script b 3: Do script c I just need a point in the right direction, not a quick answer. 回答1: Here is a SQL Plus script to do that: prompt Please make a selection: prompt 1: Do script a prompt 2: Do script b prompt 3: Do script c accept selection prompt "Enter option 1-3: " set term off column script new_value v_script select case '