sqlplus

Formatting of SQL*Plus to CSV output format issues

狂风中的少年 提交于 2019-12-25 08:23:03
问题 I am trying to export the result of my SQL query to a .csv file using column formatting as below. SET head OFF SET feedback OFF SET pagesize 500 SET linesize 2000; SET colsep , set trimspool on set trimout on set trims on column c1 heading POSTING_DATE Format date column c2 heading COMPANY_CODE Format a6 column c3 heading PHYSICAL_ACCOUNT Format a8 column c4 heading DEBIT_AMOUNT Format 99999.99 column c5 heading CREDIT_AMOUNT Format 99999.99 select POSTING_DATE c1, COMPANY_CODE c2, PHYSICAL

Put select result in a ksh variable

折月煮酒 提交于 2019-12-25 07:58:08
问题 using sql loader, I know I can reference a ksh variable in my ctl file. For example I can write LOAD DATA INFILE '$PATH_IN_KSH/my_file.dat' ... I would like to add a WHEN clause like this WHEN (125:125) = '$P_NUMBER' P_NUMBER would have the value of a column in a table that I would retrieve with a select query. Is it possible to do that ? retrieve a value from a column with a select and somehow put it in the ksh variable so the ctl file can see it. (something with sql plus?) Thank you 回答1: As

Put select result in a ksh variable

允我心安 提交于 2019-12-25 07:57:12
问题 using sql loader, I know I can reference a ksh variable in my ctl file. For example I can write LOAD DATA INFILE '$PATH_IN_KSH/my_file.dat' ... I would like to add a WHEN clause like this WHEN (125:125) = '$P_NUMBER' P_NUMBER would have the value of a column in a table that I would retrieve with a select query. Is it possible to do that ? retrieve a value from a column with a select and somehow put it in the ksh variable so the ctl file can see it. (something with sql plus?) Thank you 回答1: As

trouble creating headers using spool in sqlplus

我的未来我决定 提交于 2019-12-25 06:58:59
问题 I have a lot of data that I want to spool to a csv file. I need to set heading off so the heading will not repeat every page. However, I still need my produced file to contain headers. Is there a way to add a row of headers (not to the table itself) into the query that won't actually be considered a header when spooling? This is my code which works, it just doesn't contain headers when I set heading off . select a.col1 as name1, a.col2 as name2, b.col3 as name3 from tab1 a, tab2 b Thanks in

How to know whether the created view is valid or not

杀马特。学长 韩版系。学妹 提交于 2019-12-25 06:54:55
问题 I am new db. Lets say I have created a view with force. So how can I get know whether the view created is invalid or not? I mean are there any queries from which I can get to know the validity status of the view? Thanks. 回答1: You can use Oracle dictionary view user_objects : select object_name, status from user_objects where object_type = 'VIEW' and object_name = 'YOUR_VIEW'; If the table on which the view is based is altered for any reason, you may have to recompile the view. For example, if

Vietnamese characters are garbled after export and import

扶醉桌前 提交于 2019-12-25 06:44:12
问题 I exported a table in Oracle (which has Vietnamese text) from computer A with:: exp system/***** BUFFER=64000 FILE=/tmp/export.dmp TABLES=(USERS.AREA) GRANTS=N INDEXES=NO ROWS=Y Then I imported that dump file on computer B (Centos same as A) imp system/***** file="/tmp/export_table.dmp" But when I query in SQL*Plus I see question marks instead of Vietnamese characters: SELECT AREA_ID,AREA_NAME,COMMENTS FROM USERS.AREA WHERE ROWNUM<2; I tried setting NLS_LANG="American_Amarica.VN8VN3" on

Getting sqlresult into bash variable without oracle header/footer

非 Y 不嫁゛ 提交于 2019-12-25 06:20:58
问题 #!/bin/bash -x x=`sqlplus scott/tiger@xe<<endl set heading off select sysdate from dual; exit endl` echo the answer is $x is outputting the answer is SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 27 09:01:25 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> SQL> 27-MAR-13 SQL> Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Productiong All I want is the result of

Getting sqlresult into bash variable without oracle header/footer

ぐ巨炮叔叔 提交于 2019-12-25 06:19:05
问题 #!/bin/bash -x x=`sqlplus scott/tiger@xe<<endl set heading off select sysdate from dual; exit endl` echo the answer is $x is outputting the answer is SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 27 09:01:25 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> SQL> 27-MAR-13 SQL> Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Productiong All I want is the result of

Create a query to select two columns; (Company, No. of Films) from the database

﹥>﹥吖頭↗ 提交于 2019-12-25 06:12:29
问题 I have created a database as part of university assignment and I have hit a snag with the question in the title. More likely I am being asked to find out how many films each company has made. Which suggests to me a group by query. But I have no idea where to begin. It is only a two mark question but the syntax is not clicking in my head. My schema is: CREATE TABLE Movie (movieID CHAR(3) , title CHAR(36), year NUMBER, company CHAR(50), totalNoms NUMBER, awardsWon NUMBER, DVDPrice NUMBER(5,2),

Oracle SQLPlus setting environment variable based on variable

倖福魔咒の 提交于 2019-12-25 05:26:12
问题 I want to set the environment variable long based on the size of the XML data I'm trying to retrieve. The idea is something like this: var XML_DATA_SIZE number; SELECT TRIM(LENGTH(xmltype.getClobVal(xml_data))) INTO :XML_data_size FROM xml_tab WHERE key = '1234'; print XML_DATA_SIZE set long XML_DATA_SIZE set pagesize 0 set line 2000 set termout off spool XMLDATA.xml select xml_data from xml_tab where key = '1234'; spool off This yields an error: SP2-0268: long option not a valid number , and