Separated SQL
Sometimes I go to view log in session monitor, there are many separated SQL in one session, why?
For example, I drag one dimension column named division, and two fact tables to generate one report, but the SQL does not be combined as fellowing code.
-------------------- Sending query to database named JCPDB2SO (id: <<16369218>>):
select T132364."DIV_PROD_ID" as c1,
count(T140341."ITM_PROD_KY") as c2
from
"ZORPTDM"."DIM_SO_PROD" T132364,
"ZORPTDM"."FCT_POM_ITM" T140341
where ( T132364."PROD_KY" = T140341."ITM_PROD_KY" )
group by T132364."DIV_PROD_ID"
order by c1
+++zsun:39ec0000:39ec0003:----2012/02/13 00:20:31
-------------------- Sending query to database named JCPDB2SO (id: <<16369255>>):
select T132364."DIV_PROD_ID" as c1,
count(T140347."ITM_PROD_KY") as c2
from
"ZORPTDM"."DIM_SO_PROD" T132364,
"ZORPTDM"."FCT_SO_ITM" T140347
where ( T132364."PROD_KY" = T140347."ITM_PROD_KY" )
group by T132364."DIV_PROD_ID"
order by c1
For the first issue you can try the "prompt" command.
For the second issue you can add a "set pagesize 0" command in your sqlplus-file.
You can use "set trimspool on" to elimate blanks at the end of each line in your outputfile (if you want).
set termout off
set feedback off
set heading off
set echo off
set linesize 5000
set trimspool on
set pagesize 0
spool c:\temp\abc.txt
Prompt Error Code;Error Message
SELECT lookup_code||';'||description
FROM fnd_lookup_values
WHERE lookup_type = 'NLUS_AR_INT_ERROR_MSG'
ORDER BY TO_NUMBER(LTRIM(lookup_code,'E'));
spool offEdited by: hm on 31.03.2011 04:41
Similar Messages
-
Excel output issue from a semi colon separated sql file script
Hi,
I am executing a simple SQL script with back to back Select queries resulting in ; separated text output.
I save this output as a text file and open in excel specifying delimited with ;.
For example -
SQL script is as follows-
SET lines 5000
SELECT 'Error Code'||';'||'Error Message'
FROM dual
SELECT lookup_code||';'||description
FROM fnd_lookup_values
WHERE lookup_type = 'NLUS_AR_INT_ERROR_MSG'
ORDER BY TO_NUMBER(LTRIM(lookup_code,'E'))
The output retrieved has the following 2 issues -
1. A blank row is inserted after the "Error code Error message" row. I need to eliminate this blank row.
2. The 2nd issue I am facing is an empty row is inserted after every 62 rows in the excel.
Please let me know how I can eliminate these blank rows that are appearing after every 62 rows and in between each query's results.
Thanks,
AditiFor the first issue you can try the "prompt" command.
For the second issue you can add a "set pagesize 0" command in your sqlplus-file.
You can use "set trimspool on" to elimate blanks at the end of each line in your outputfile (if you want).
set termout off
set feedback off
set heading off
set echo off
set linesize 5000
set trimspool on
set pagesize 0
spool c:\temp\abc.txt
Prompt Error Code;Error Message
SELECT lookup_code||';'||description
FROM fnd_lookup_values
WHERE lookup_type = 'NLUS_AR_INT_ERROR_MSG'
ORDER BY TO_NUMBER(LTRIM(lookup_code,'E'));
spool offEdited by: hm on 31.03.2011 04:41 -
(8I) SQL*LOADER에서 | (PIPE LINE)을 RECORD SEPARATOR로 사용하기
제품 : ORACLE SERVER
작성날짜 : 2003-10-21
===============================================================
(8I) SQL*LOADER에서 | (PIPE LINE)을 RECORD SEPARATOR로 사용하기
===============================================================
PURPOSE
Oracle8i부터는 , SQL*Loader을 사용할때 record terminator을 지정할 수 있게
되었다.
Explanation
Oracle8i 이전에는 record seperator로 default로 linefeed(carriage return,
newline 등)였다. 이전에는 VAR 또는 FIX 등의 적당한 file을 다루기 위한 옵션을
주어야 하기 때문에 복잡한 감이 있었고 flexible하지 못했다.
Oracle8i부터는 , SQL*Loader을 사용할때 record terminator을 지정할 수 있게
되었다. newline 또는 carriage return 문자를 포함하는 data 또는 special 문자를
포함하는 data를 load하고자 할때 record terminator를 hexadecimal로 지정하여 활용할 수 있다.
Example
다음의 예제는 '|' (pipe line)을 record separator로 사용한다.
record separator를 사용하기 위해서 SQL*Loader의 control file에 'infile'절에 적당한 값을 지정하여야 한다.
아래의 예는 '|' (pipe line)을 사용하기 위해서
"str X'7c0a'"을 'infile'절에 지정하였다.
--controlfile : test.ctl
load data
infile 'test.dat' "str X'7c0a'"
into table test
fields terminated by ',' optionally enclosed by '"'
(col1, col2)
--datafile: test.dat
1,this is the first line of the first record
this is the second|
2,this is the first line of the second record
this is the second|
SQL> desc test
Name Null? Type
COL1 VARCHAR2(4)
COL2 VARCHAR2(100)
$ sqlldr scott/tiger control=test.ctl log=test.log
load된 data을 보면 아래와 같이 carriage return이 들어가 있는 data가 한 column에
제대로 들어간 것을 볼 수 있다.
SQL> select * from test;
COL1
COL2
1
this is the first line of the first record
this is the second
2
this is the first line of the second record
this is the second
RELATED DOCUMENT
<Note:74719.1> -
Decimal Separator in SELECT Clause
Hi
I have the following decimal format parameters:
SQL> select value
2 from v$nls_parameters
3 where parameter = 'NLS_NUMERIC_CHARACTERS';
VALUE
If I show a number with decimal I get a comma as the decimal separator
SQL> select 10/100 from dual;
10/100
,1
But if I use a decimal separator in the SELECT clause I get:
SQL> select 100 * 1,1 from dual;
100*1 1
100 1
It doesn't work. But using a period as the decimal separator works:
SQL> select 1.1 * 100 from dual;
1.1*100
110
Maybe this is something I've never had to deal with before but I thought that the numeric format applied to the sql results and also the numbers that you used in the sql clauses.
Regards,
Néstor BoscánHi,Néstor,
user594312 wrote:
... I thought that the numeric format applied to the sql results and also the numbers that you used in the sql clauses.No; it applies to results, and it can affect implicit conversions, but it doesn't apply to SQL code.
The period (or dot, '.') is always the decimal separator in numeric literals. There is no way to change that.
Think how confusing it would be if it did apply to SQL code! For example:
WHERE num_col IN (1,2)Are we comparing num_col to 1 value or 2 values? Whichever it is, what if we wanted to do the opposite?
If you really wanted to use comma as the decimal separator, you could have to use strings, not numbers, and that could be a lot less efficient.
For example:
SELECT 100 * TO_NUMBER ('1,1') -- This assumes your NLS settings are correct
FROM dual;Of course, efficiency won't be an issue when you're selecting 1 row from dual. -
Where do I look at UTLTZUV2.SQL output?
Dear gurus,
I'm in the process of applying Security Patch 16: 6637237(CPUJAN2008) on my Windows 32bit envs. In this process, I need to check the existing TSTZ data using this oracle provided script. I ran it and didn't see the result. Here in the info I got:
SQL> SET ECHO ON
SQL> @c:\C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utltzuv2.sql
SP2-0310: unable to open file "c:\C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utltzuv2.sql"
SQL> @c:\C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utltzuv2.sql
SP2-0310: unable to open file "c:\C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utltzuv2.sql"
SQL> @c:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utltzuv2.sql
SQL> Rem
SQL> Rem $Header: utltzuv2.sql 21-dec-2006.02:22:10 huagli Exp $
SQL> Rem
SQL> Rem utltzuv2.sql
SQL> Rem
SQL> Rem Copyright (c) 2003, 2006, Oracle. All rights reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem utltzuv2.sql - time zone file upgrade to a new version script
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem The contents of the files timezone.dat and timezlrg.dat
SQL> Rem are usually updated to a new version to reflect the transition rule
SQL> Rem changes for some time zone region names. The transition rule
SQL> Rem changes of some time zones might affect the column data of
SQL> Rem TIMESTAMP WITH TIME ZONE data type. For example, if users
SQL> Rem enter TIMESTAMP '2003-02-17 09:00:00 America/Sao_Paulo',
SQL> Rem we convert the data to UTC based on the transition rules in the
SQL> Rem time zone file and store them on the disk. So '2003-02-17 11:00:00'
SQL> Rem along with the time zone id for 'America/Sao_Paulo' is stored
SQL> Rem because the offset for this particular time is '-02:00' . Now the
SQL> Rem transition rules are modified and the offset for this particular
SQL> Rem time is changed to '-03:00'. when users retrieve the data,
SQL> Rem they will get '2003-02-17 08:00:00 America/Sao_Paulo'. There is
SQL> Rem one hour difference compared to the original value.
SQL> Rem
SQL> Rem Refer to $ORACLE_HOME/oracore/zoneinfo/readme.txt for detailed
SQL> Rem information about time zone file updates.
SQL> Rem
SQL> Rem This script should be run before you update your database's
SQL> Rem time zone file to the latest version. This is a pre-update script.
SQL> Rem
SQL> Rem This script first determines the time zone version currently in use
SQL> Rem before the upgrade. It then queries an external table to get all the
SQL> Rem affected timezone regions between the current version (version before
SQL> Rem the update) and the latest one. This external table points to the file
SQL> Rem timezdif.csv, which contains all the affected time zone names in each
SQL> Rem version. Please make sure that you have the latest version of the
SQL> Rem timezdif.csv (the one corresponding to the latest timezone data file),
SQL> Rem before you run the script.
SQL> Rem
SQL> Rem Then, this script scans the database to find out all columns
SQL> Rem of TIMESTAMP WITH TIME ZONE data type. If the column is
SQL> Rem in the regular table, the script also finds out how many
SQL> Rem rows might be affected by checking whether the column data
SQL> Rem contain the values for the affected time zone names.
SQL> Rem If the column is in the nested table's storage table, we
SQL> Rem don't scan the data to find out how many rows are affected but
SQL> Rem we still report the table and column info.
SQL> Rem
SQL> Rem The result is stored in the table sys.sys_tzuv2_temptab.
SQL> Rem Before running the script, make sure the table name doesn't
SQL> Rem conflict with any existing table object. It it does,
SQL> Rem change the table name sys.sys_tzuv2_temptab to some other name
SQL> Rem in the script. You can query the table to view the result:
SQL> Rem select * from sys.sys_tzuv2_temptab;
SQL> Rem
SQL> Rem If your database has column data that will be affected by the
SQL> Rem time zone file update, dump the data before you upgrade to the
SQL> Rem new version. After the upgrade, you need update the data
SQL> Rem to make sure the data is stored based on the new rules.
SQL> Rem
SQL> Rem For example, user scott has a table tztab:
SQL> Rem create table tztab(x number primary key, y timestamp with time zone);
SQL> Rem insert into tztab values(1, timestamp '');
SQL> Rem
SQL> Rem Before upgrade, you can create a table tztab_back, note
SQL> Rem column y here is defined as VARCHAR2 to preserve the original
SQL> Rem value.
SQL> Rem create table tztab_back(x number primary key, y varchar2(256));
SQL> Rem insert into tztab_back select x,
SQL> Rem to_char(y, 'YYYY-MM-DD HH24.MI.SSXFF TZR') from tztab;
SQL> Rem
SQL> Rem After upgrade, you need update the data in the table tztab using
SQL> Rem the value in tztab_back.
SQL> Rem update tztab t set t.y = (select to_timestamp_tz(t1.y,
SQL> Rem 'YYYY-MM-DD HH24.MI.SSXFF TZR') from tztab_back t1 where t.x=t1.x);
SQL> Rem
SQL> Rem Or you can use export utility to export your data before the upgrade
SQL> Rem and them import your data again after the upgrade.
SQL> Rem
SQL> Rem drop table sys.sys_tzuv2_temptab;
SQL> Rem once you are done with the time zone file upgrade.
SQL> Rem
SQL> Rem NOTES
SQL> Rem * This script needs to be run before upgrading to a new version time
SQL> Rem zone file. Also, before running this script, please make sure that
SQL> Rem you get the latest version of timezdif.csv file.
SQL> Rem * This script must be run using SQL*PLUS.
SQL> Rem * You must be connected AS SYSDBA to run this script.
SQL> Rem * This script is created only for Oracle 10.1 or higer. A separate
SQL> Rem script is provided for Oracle 9i.
SQL> Rem * Two files, tzuv2ext_*.log and tzuv2ext_*.bad will be created in
SQL> Rem the directory of $ORACLE_HOME/oracore/zoneinfo when using the
SQL> Rem external table for timezdif.csv file to get the affected time zones.
SQL> Rem After running the script, please refer to these two files to see if
SQL> Rem there are any rows in timezdif.csv, which are not loaded. If so,
SQL> Rem it might affect the correct selection of affected tables in the database.
SQL> Rem You can always delete tzuv2ext_*.log and tzuv2ext_*.bad.
SQL> Rem * A Java stored procedure is created to get the system file separator,
SQL> Rem e.g., Windows uses '\' and Unix uses '/'. Before you run this script,
SQL> Rem make sure that the Java source/class object does not conflict with
SQL> Rem any existing Java source/class object in the database. If it does, please
SQL> Rem change the Java source/class object name GetFileSeparator to some other
SQL> Rem name in the script. Also make sure that the Java stored procedure does not
SQL> Rem conflict with any existing function in the database. If it does, please
SQL> Rem change the function name GET_FILE_SEPARATOR to some other name in the script.
SQL> Rem If renaming is needed, please make sure that you change all the occurences
SQL> Rem to make them consistent.
SQL> Rem
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem huagli 12/21/06 - Backport huagli_bug-5126270 from main
SQL> Rem time zone update
SQL> Rem srsubram 05/12/05 - 4331865:Modify script to work with prior
SQL> Rem releases
SQL> Rem lkumar 05/11/04 - Fix lrg 1691434.
SQL> Rem rchennoj 12/02/03 - Fix query
SQL> Rem qyu 11/22/03 - qyu_bug-3236585
SQL> Rem qyu 11/17/03 - Created
SQL> Rem
SQL>
SQL> SET SERVEROUTPUT ON
SQL>
SQL> Rem=========================================================================
SQL> Rem Check any existing table with this name sys.sys_tzuv2_temptab
SQL> Rem=========================================================================
SQL> DROP TABLE sys.sys_tzuv2_temptab
2 /
DROP TABLE sys.sys_tzuv2_temptab
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> CREATE TABLE sys.sys_tzuv2_temptab
2 (
3 table_owner VARCHAR2(30),
4 table_name VARCHAR2(30),
5 column_name VARCHAR2(30),
6 rowcount NUMBER,
7 nested_tab VARCHAR2(3)
8 )
9 /
Table created.
SQL>
SQL> Rem========================================================================
SQL> Rem Check any existing table with this name sys.sys_tzuv2_temptab1
SQL> Rem========================================================================
SQL> DROP TABLE sys.sys_tzuv2_temptab1
2 /
DROP TABLE sys.sys_tzuv2_temptab1
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> CREATE TABLE sys.sys_tzuv2_temptab1
2 (
3 time_zone_name VARCHAR2(60)
4 )
5 /
Table created.
SQL>
SQL> DECLARE
2
3 dbv VARCHAR2(10);
4 dbtzv VARCHAR2(5);
5 numrows NUMBER;
6 TYPE cursor_t IS REF CURSOR;
7 cursor_tstz cursor_t;
8 tstz_owner VARCHAR2(30);
9 tstz_tname VARCHAR2(30);
10 tstz_qcname VARCHAR2(4000);
11 tz_version NUMBER;
12 oracle_home VARCHAR(4000);
13 tz_count INTEGER;
14 plsql_block VARCHAR2(200);
15 file_separator VARCHAR2(3);
16
17 BEGIN
18
19 --========================================================================
20 -- Make sure that only version 10 or higher uses this script
21 --========================================================================
22
23 SELECT substr(version,1,6) INTO dbv FROM v$instance;
24
25 IF dbv = '8.1.7.'
26 THEN
27 DBMS_OUTPUT.PUT_LINE('TIMEZONE data type was not supported in ' ||
28 'Release 8.1.7.');
29 DBMS_OUTPUT.PUT_LINE('No need to validate TIMEZONE data.');
30 RETURN;
31 END IF;
32
33 IF dbv in ('9.0.1.','9.2.0.')
34 THEN
35 DBMS_OUTPUT.PUT_LINE('Please contact Oracle support to get the script ' ||
36 'for Release 9.0.1 or 9.2.0.');
37 RETURN;
38 END IF;
39
40 --========================================================================
41 -- Get $ORACLE_HOME
42 --========================================================================
43
44 plsql_block := 'BEGIN SYS.DBMS_SYSTEM.GET_ENV(:1, :2); END;';
45 EXECUTE IMMEDIATE plsql_block USING 'ORACLE_HOME', OUT oracle_home;
46
47 --========================================================================
48 -- Use an external table created on timezdif.csv file to get the
49 -- affected time zones. In this way, every time when time zone information
50 -- changes, we only need to provide user with the updated timezdif.csv file
51 -- without changing utltzuv2.sql.
52 --
53 -- 1. Setup the directory for timezdif.csv and log files(log, bad log)
54 -- 2. Check any existing external table with this name
55 -- sys.sys_tzuv2_affected_regions
56 -- 3. Setup the parameters of the external table
57 --========================================================================
58
59 --========================================================================
60 -- Create a Java stored procedure to get the file separator
61 --========================================================================
62
63 EXECUTE IMMEDIATE 'CREATE OR REPLACE AND COMPILE JAVA SOURCE
64 NAMED "GetFileSeparator" AS
65 public class GetFileSeparator {
66 public static String get() {
67 return System.getProperty("file.separator");
68 }
69 }';
70
71 EXECUTE IMMEDIATE 'CREATE OR REPLACE FUNCTION GET_FILE_SEPARATOR
72 RETURN VARCHAR2
73 AS LANGUAGE JAVA
74 NAME ''GetFileSeparator.get() return java.lang.String'';';
75
76
77 plsql_block := 'BEGIN :1 := GET_FILE_SEPARATOR(); END;';
78 EXECUTE IMMEDIATE plsql_block USING OUT file_separator;
79
80 EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY timezdif_dir AS ''' ||
81 oracle_home || file_separator || 'oracore' ||
82 file_separator || 'zoneinfo''';
83
84
85 EXECUTE IMMEDIATE
86 'SELECT count(*)
87 FROM all_tables
88 WHERE owner = ''SYS'' and table_name = ''SYS_TZUV2_AFFECTED_REGIONS'''
89 INTO tz_count;
90
91 IF tz_count <> 0
92 THEN
93 EXECUTE IMMEDIATE 'DROP TABLE sys.sys_tzuv2_affected_regions';
94 END IF;
95
96
97 EXECUTE IMMEDIATE 'CREATE TABLE sys.sys_tzuv2_affected_regions
98 (
99 version NUMBER,
100 time_zone_name VARCHAR2(40),
101 from_year NUMBER,
102 to_year NUMBER
103 )
104 ORGANIZATION EXTERNAL
105 (
106 TYPE ORACLE_LOADER
107 DEFAULT DIRECTORY timezdif_dir
108 ACCESS PARAMETERS
109 (
110 records delimited by newline
111 badfile timezdif_dir:''tzuvext%a_%p.bad''
112 logfile timezdif_dir:''tzuvext%a_%p.log''
113 fields terminated by '',''
114 lrtrim
115 missing field values are null
116 (
117 version, time_zone_name, from_year, to_year
118 )
119 )
120 LOCATION (''timezdif.csv'')
121 )
122 REJECT LIMIT UNLIMITED';
123
124 --======================================================================
125 -- Check if the TIMEZONE data is consistent with the latest version.
126 --======================================================================
127
128 EXECUTE IMMEDIATE 'SELECT version FROM v$timezone_file' INTO tz_version;
129 EXECUTE IMMEDIATE 'SELECT MAX(version) FROM sys_tzuv2_affected_regions' INTO dbtzv;
130
131 IF tz_version = dbtzv
132 THEN
133 DBMS_OUTPUT.PUT_LINE('TIMEZONE data is consistent with the latest version ' ||
134 dbtzv || ' transition rules');
135 DBMS_OUTPUT.PUT_LINE('No need to validate TIMEZONE data');
136 RETURN;
137 END IF;
138
139 --======================================================================
140 -- Get tables with columns defined as type TIMESTAMP WITH TIME ZONE.
141 --======================================================================
142
143 OPEN cursor_tstz FOR
144 'SELECT atc.owner, atc.table_name, atc.qualified_col_name ' ||
145 'FROM "ALL_TAB_COLS" atc, "ALL_TABLES" at ' ||
146 'WHERE data_type LIKE ''TIMESTAMP%WITH TIME ZONE''' ||
147 ' AND atc.owner = at.owner AND atc.table_name = at.table_name ' ||
148 'ORDER BY atc.owner, atc.table_name, atc.column_name';
149
150 --======================================================================
151 -- Query the external table to get all the affected time zones based
152 -- on the current database time zone version, and then put them into
153 -- a temporary table, sys_tzuv2_temptab1.
154 --======================================================================
155
156 EXECUTE IMMEDIATE
157 'INSERT INTO sys.sys_tzuv2_temptab1
158 SELECT DISTINCT time_zone_name
159 FROM sys.sys_tzuv2_affected_regions t
160 WHERE t.version > ' || tz_version;
161
162 EXECUTE IMMEDIATE 'ANALYZE TABLE sys.sys_tzuv2_temptab1 ' ||
163 'COMPUTE STATISTICS';
164
165 --======================================================================
166 -- Check regular table columns.
167 --======================================================================
168 LOOP
169 BEGIN
170 FETCH cursor_tstz INTO tstz_owner, tstz_tname, tstz_qcname;
171 EXIT WHEN cursor_tstz%NOTFOUND;
172
173 EXECUTE IMMEDIATE
174 'SELECT COUNT(1) FROM ' ||
175 tstz_owner || '."' || tstz_tname || '" t_alias, ' ||
176 ' sys.sys_tzuv2_temptab1 r ' ||
177 ' WHERE UPPER(r.time_zone_name) = ' ||
178 ' UPPER(TO_CHAR(t_alias.' || tstz_qcname || ', ''TZR'')) ' INTO numrows;
179
180 IF numrows > 0 THEN
181 EXECUTE IMMEDIATE ' INSERT INTO sys.sys_tzuv2_temptab VALUES (''' ||
182 tstz_owner || ''',''' || tstz_tname || ''',''' ||
183 tstz_qcname || ''',' || numrows || ', ''NO'')';
184 END IF;
185
186 EXCEPTION
187 WHEN OTHERS THEN
188 DBMS_OUTPUT.PUT_LINE('OWNER : ' || tstz_owner);
189 DBMS_OUTPUT.PUT_LINE('TABLE : ' || tstz_tname);
190 DBMS_OUTPUT.PUT_LINE('COLUMN : ' || tstz_qcname);
191 DBMS_OUTPUT.PUT_LINE(SQLERRM);
192 END;
193 END LOOP;
194
195 --======================================================================
196 -- Check nested table columns.
197 --======================================================================
198
199 EXECUTE IMMEDIATE
200 'INSERT INTO sys.sys_tzuv2_temptab
201 SELECT owner, table_name, qualified_col_name, NULL, ''YES''
202 FROM ALL_NESTED_TABLE_COLS
203 WHERE data_type like ''TIMESTAMP%WITH TIME ZONE''';
204
205
206 DBMS_OUTPUT.PUT_LINE('Query sys.sys_tzuv2_temptab table to see ' ||
207 'if any TIMEZONE data is affected by version ' || dbtzv ||
208 ' transition rules');
209
210 EXCEPTION
211 WHEN OTHERS THEN
212 IF INSTR(SQLERRM, 'KUP-04063') != 0
213 THEN
214 DBMS_OUTPUT.PUT_LINE('Directory for file timezdif.csv is not correctly specified!');
215 DBMS_OUTPUT.PUT_LINE(sqlerrm);
216 ELSIF INSTR(SQLERRM, 'KUP-04040') != 0
217 THEN
218 DBMS_OUTPUT.PUT_LINE('File timezdif.csv in TIMEZDIF_DIR not found!');
219 ELSE
220 DBMS_OUTPUT.PUT_LINE(SQLERRM);
221 END IF;
222
223 END;
224 /
ORA-25153: Temporary Tablespace is Empty
PL/SQL procedure successfully completed.
SQL>
SQL> COMMIT
2 /
Commit complete.
SQL>
SQL> DECLARE
2 tz_count NUMBER;
3
4 BEGIN
5
6 --========================================================================
7 -- After obtaining the file separator, drop the Java stored procedure
8 --========================================================================
9
10 EXECUTE IMMEDIATE
11 'SELECT count(*)
12 FROM user_objects
13 WHERE object_name = ''GetFileSeparator'' and UPPER(object_type) like ''JAVA%'''
14 INTO tz_count;
15
16 IF tz_count > 0
17 THEN
18 EXECUTE IMMEDIATE 'DROP JAVA SOURCE "GetFileSeparator"';
19 END IF;
20
21 EXECUTE IMMEDIATE
22 'SELECT count(*)
23 FROM user_objects
24 WHERE object_name = ''GET_FILE_SEPARATOR'' and UPPER(object_type) = ''FUNCTION'''
25 INTO tz_count;
26
27 IF tz_count > 0
28 THEN
29 EXECUTE IMMEDIATE 'DROP FUNCTION GET_FILE_SEPARATOR';
30 END IF;
31
32 END;
33 /
PL/SQL procedure successfully completed.
SQL>
SQL> COMMIT
2 /
Commit complete.
SQL>
SQL> Rem=========================================================================
SQL> SET SERVEROUTPUT OFF
SQL> Rem=========================================================================
SQL> spool off
Could you help me find the TSTZ data if there are any? Thank you in advance.Ok, I found out that I need to apply the patch 5746875 to have that. But there only instruction to apply this patch on unix env. I need on Windows. Can any body help me?
-
i have a scenario like
bank_division sum(amount) total_percentage(calculated by : / total sum of adjacent amounts i.e(10000+2000+3000+4000) *100
aaaa 10000
bbb 2000
ccc 3000
dddd 40000
for above thing i have written sql like
select bank_division,sum(amount) from bank group by bank;
but i am unable to calculate percentage for each bank_division..........
.its like for aaaa correspoding percentage will be
10000/ total sum of adjacent amounts i.e(10000+2000+3000+4000) *100
and for bbb it will be
2000/ total sum of adjacent amounts i.e(10000+2000+3000+4000) *100
so on...
can any one help me how to write in single sqluser632733 wrote:
in your sql you are using lag to display from existing total_sal....which cant be possible in above scenario..??? Where did you see existing total_sal? EMP table:
SQL> select deptno,ename,sal from emp
2 /
DEPTNO ENAME SAL
20 SMITH 800
30 ALLEN 1600
30 WARD 1250
20 JONES 2975
30 MARTIN 1250
30 BLAKE 2850
10 CLARK 2450
20 SCOTT 3000
10 KING 5000
30 TURNER 1500
20 ADAMS 1100
DEPTNO ENAME SAL
30 JAMES 950
20 FORD 3000
10 MILLER 1300
14 rows selected.
SQL> As you can see, there are multiple employees in each department. Now look at mu solution. Inner select:
select deptno,
sum(sal) total_sal
from emp
group by deptnosummarizes sal for each department. If you run it separately:
SQL> select deptno,
2 sum(sal) total_sal
3 from emp
4 group by deptno
5 /
DEPTNO TOTAL_SAL
30 9400
20 10875
10 8750
SQL> Outer select calculates previous department total salary and its ratio to report.
SY.
P.S. And if you want to display individual employees along with department level summarization:
select deptno,
ename,
total_sal,
prev_deptno,
last_value(total_sal) over(order by deptno range between unbounded preceding and 1 preceding) prev_dept_total_sal,
ratio_to_report(total_sal) over () * 100
from (
select deptno,
ename,
sum(sal) over(partition by deptno) total_sal,
max(deptno) over(order by deptno range between unbounded preceding and 1 preceding) prev_deptno
from emp
order by deptno
DEPTNO ENAME TOTAL_SAL PREV_DEPTNO PREV_DEPT_TOTAL_SAL RATIO_TO_REPORT(TOTAL_SAL)OVER()*100
10 MILLER 8750 6.38569604
10 KING 8750 6.38569604
10 CLARK 8750 6.38569604
20 ADAMS 10875 10 8750 7.93650794
20 FORD 10875 10 8750 7.93650794
20 JONES 10875 10 8750 7.93650794
20 SMITH 10875 10 8750 7.93650794
20 SCOTT 10875 10 8750 7.93650794
30 WARD 9400 20 10875 6.86006203
30 TURNER 9400 20 10875 6.86006203
30 ALLEN 9400 20 10875 6.86006203
DEPTNO ENAME TOTAL_SAL PREV_DEPTNO PREV_DEPT_TOTAL_SAL RATIO_TO_REPORT(TOTAL_SAL)OVER()*100
30 JAMES 9400 20 10875 6.86006203
30 BLAKE 9400 20 10875 6.86006203
30 MARTIN 9400 20 10875 6.86006203
14 rows selected.
SQL> -
Lync 2013 and SQL 2012 on the same server
Hi,
I'm in the process of migrating Lync 2010 to Lync 2013. I have a clean install of Windows Server 2012 R2. Is it possible to install Lync 2013 and SQL 2012 on the same server or does it have to be on separate servers.
Thanks
PConfigure Separated SQL Server to use in an Enterprise deployment of Lync Server. Standard Edition servers use a collocated SQL Server Express version of SQL Server that is right sized for the workloads of a Standard Edition server.
Also you can refer below link
http://technet.microsoft.com/en-us/library/gg425848.aspx
Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer" -
Problem in querying synonym using cachedRowSet & cachedDataProvider
Hi....
I have some trouble using cachedRowSet and cachedDataProvider combination. The problem was occured when I refreshed chachedDataProvider, my table component in pages show "No items found.", whereas... i'm sure there is nothing wrong with my query.
here the detail
i have cachedRowSet in my SessionBeans1 named globalRowSet
globalRowSet.setDataSourceName("java:comp/env/jdbc/MIMSOE_Oracle");
globalRowSet.setCommand("SELECT EQUIP_NO, ORIGINATOR_ID FROM ELLIPSE.MSF620 WHERE EQUIP_NO LIKE ?");
globalRowSet.setFetchSize(100);
globalRowSet.setMaxRows(100);
globalRowSet.setPageSize(100);and then i have data provider in my pages (TestPage.jsp), linked to globalRowSet, named cachedRowSetDataProvider1
cachedRowSetDataProvider1.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.globalRowSet}"));Note that in globalRowSet SQL command, there is a parameter (marked by '?'), so i put this code in init() method.
getSessionBean1().getGlobalRowSet().setObject(1, "%MUA21%");that code replace '?' in my query with '%MUA21%'. so in the first time i open the page, my table in TestPage.jsp dont display empty data. this code was worked.
then i put a button and a textfield in TestPage.jsp. I put them for dynamically changes my query parameter.
public String button1_action() {
try {
getSessionBean1().getGlobalRowSet().setObject(1, this.textField1.getText().toString());
this.cachedRowSetDataProvider1.refresh();
} catch (SQLException ex) {
Logger.getLogger(TestPage.class.getName()).log(Level.SEVERE, null, ex);
return null;
}I ran my webpages, i hit the button, and i saw anomalies.
before i hit the button, my table shows a lot of records. but after i hit, my table shows nothing but "No items found." displayed in table body.
I debugged my code, and found nothing wrong with my query. I executed my query in separated sql editor and it works flawlessly,
I truncated my code line by line for debugging, and found this line of code was the main reason for that problem
this.cachedRowSetDataProvider1.refresh();I'm not sure why this line of code didnt work in my project. maybe this is because of my globalRowSet querying data from ORACLE synonym. please note that 'MSF620' in my query (SELECT EQUIP_NO, ORIGINATOR_ID FROM ELLIPSE.MSF620) is not a table, but synonym. I made same version but use oracle table (not synonym) and work fine...
can anyone help give me a solution for this issue? ...
please help..
i have no progression for last 2 weeks because of this issue.......Hi Tushar,
In your SELECT you select only record for record and you put the result into the header line of the table.
Try:
SELECT posnr
FROM RESB
INTO TABLE IRESB
WHERE VORNR = '0010'
AND AUFNR = '720000100'.
Then you can loop over your internal table!.
Regards,
John. -
Jet Express connect to Microsoft Dynamics NAV 2013 R2
I meet some problem when I use Jet Express to show report in excel.
The message error is below:
The ulr 'http://navap:7047/DynamicsNAV71/WS/SystemService' is not valid.
The remote server returned an error: (401) Unauthorized.
Why are we get this message?
How can I do to fix this error?
Many Thanks,If you use Microsoft Dynamics NAV 2013 (or 2013R2), you need to use Perpetual license model. If you use it, you need 'Starter Pack'+'Extended Pack' and you will get all manufacturing modules.
You can use only Microsoft SQL, no Oracle.
You can buy separately SQL and NAV, but you also van buy SQL together with NAV in first buying (you will pay only SQL CALs).
You cannot use Oracle for NAV, but if you have some application on Oracle, you can integrate it with NAV, e.g. using web-services.
If you have additional questions about NAV, I suggest you to write on Dynamics Community forum:
https://community.dynamics.com/nav/f/34.aspx -
SMS_OUTBOX_MONITOR failed
Hi everyone,
I'm running SCCM 2012 R2 within a separated SQL instance on another server. A state of the component SMS Outbox Monitor on this SQL Server changes constantly to failed. The error text is:
Component Status Summarizer detected that the availability of component "SMS_OUTBOX_MONITOR" on computer "SQL1" has changed to Failed.
Possible cause: This component has failed to generate a heartbeat within its heartbeat interval or has reported with its heartbeat that it is in a failure state.
Solution: Verify that the condition persists by examining compmon.log and then check the component's log file.
I've examined compmon log files both on CM and SQL servers, but there are no errors.
How I can investigate this issue? Which log files can give me more information?You can look at outboxmon.log for details on the error.
There's a post on the 2007 forum about the same error.
http://social.technet.microsoft.com/Forums/en-US/68befcb2-2a07-4fe6-9ba2-52aa004a0ae1/smsoutboxmonitor-status-is-critical?forum=configmgrgeneral -
High availability - minimum requirements
Hi,
We currently have TFS2012 installed with SQL2008 on a single server. After a recent outage that required a server rebuild I'm looking to lower the risk of further outages and I've been reading about high availability options for TFS. I'm quite interested
in the SQL AlwaysOn feature which allows you to run 2 mirrors of your TFS SQL database across 2 servers. My question is can I have TFS on the same servers? I.e.:
Node A: TFS and SQL
Node B: TFS and SQL
I could then NLB the TFS front ends and have SQL in a HA AlwaysOn availability group. Is this possible? I would use the opportunity to upgrade to SQL2012/2014 and TFS 2013.
Most articles I've read talk about separating SQL out onto it's own hardware - this would require 2 additional servers minimum to run SQL and most likely a 3rd to have an additional TFS front end.
Other options would be to virtualise the above (perhaps in the future) or to use TFS online - although we have customised our TFS quite a bit so online may not be an option for us.
Thanks in advance.Hi Ceefla,
Thanks for your post.
According the information in this
document, you need install SQL Server 2012 for TFS Server if you want use SQL Server Always On Availability Groups feature.
What’s the “have TFS on the same servers” mean? Install TFS and SQL Server on the same server machine? We suggest you install the TFS and SQL Server on the different server machines.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
iam trying to take input at the prompt in one statement only...
but unable to do it..
so plz correct my query
accept var prompt "enter deptno=>" select * from emp where deptno=&var;
error:
SQL> accept var prompt "enter deptno=>" select * from emp where deptno=&var;
Enter value for var: 20
SP2-0003: Ill-formed ACCEPT command starting as select * from emp where deptno=2
0
SQL>
thank u
rajivThese are two statements you need to exceute separately
SQL> accept var prompt "enter deptno=>"
enter deptno=>10
SQL> select * from emp where deptno=&var;
old 1: select * from emp where deptno=&var
new 1: select * from emp where deptno=10
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450
10
7839 KING PRESIDENT 17-NOV-81 5000
10
7934 MILLER CLERK 7782 23-JAN-82 1300
10
SQL> -
SQL Loader: specify position for pipe separated file
Hi,
I have a problem with sql loader. i need to load 5 columns in a table and my file only contains 3 fields (pipe separated file) i need to add a sequenced id and a loading date. When i try to run the below, the sequence and the sysdate is populated correctly, but column3 is inserted into column1. If i add my file two more null columns, then it works properly:
||column1|column2|column3
also if i put my variables in the end it also works, but i cannot restructure the table so this solution doesnt work. Do u have any idea how to specify positions in pipe separated files? i should load file in the below format:
column1|column2|column3
it onlz works properly if i add the two pipe in the beginning
my control file:
LOAD DATA
INFILE 'test201001.csv'
APPEND
INTO TABLE test_load
FIELDS TERMINATED BY '|'
id "seq.nextval",
sys_creation_date "sysdate",
column_1,
column_2,
column_3
Thanx your help in advance
Edited by: user9013593 on 2010.01.19. 6:18
Edited by: user9013593 on 2010.01.19. 6:19user9013593 wrote:
Hi,
I have a problem with sql loader. i need to load 5 columns in a table and my file only contains 3 fields (pipe separated file) i need to add a sequenced id and a loading date. When i try to run the below, the sequence and the sysdate is populated correctly, but column3 is inserted into column1. If i add my file two more null columns, then it works properly:I hope someone provides a better solution below, but since no one has yet ...
Can you load the data "as is" into a work table, then use a PL/SQL program to process the work table correctly according to the data you have? -
Filters separated by OR not applying to SQL
I am having a problem where I have two prompts that need to apply either separately, or together. One is a text entry box and the other is a multi-select.
I have a Filter set up in the report that looks like this:
A is Prompted
B is Prompted
C is Prompted
OR D is Prompted
Where C and D are the fields in the prompt that is causing issues. I have a filter view set up on the report so that I can see what is being applied to the reports via the prompts. What I am finding is that if a user enters a value for C and not D, then the filter view in the report shows the value for C but it doesn't apply it to the SQL. If a user goes and enters values for both the fields it works fine.
To me, it seems like a bug, because logic would state that if there is an OR statement, either of the two values being populated should be applied to the WHERE clause in the filter.
I've tried hard coding the values so that C <> 9999999 OR D<> 999999 (999999 being a false value) and that didn't change the behavior. It's like OBIEE is requiring that there be entries by both the prompts before it will apply anything from the OR clause.
Anyone out there have any suggestions? FYI, we're using 10g.Update: I've found that if I set a default value to the prompts, and both are filled in, it works fine. Even if the entry is something like 'No Values Selected'. OBIEE is just really needing to have something passed from both prompts in order to apply the OR statement.
-
SQL - Multiple Fetch into Single Column with Comma Separator
Hello Experts,
Good Day to all...
I need your help on following scenarios. The below query returns set of titleID strings. Instead of printing them one below the other as query output, I want the output to be in batch of 25 values.i.e each row should have 25 values separated by comma. i.e If there are 100 titles satisfying the output, then there should be only four rows with and each row having 25 titles in comma separated manner.
SELECT DISTINCT title_id
FROM pack_relation
WHERE package_id IN ( SELECT DISTINCT fa.package_id
FROM annotation fa
GROUP BY fa.package_id
HAVING COUNT
(fa.package_id) <100);I tried with the PL/SQL block; whereas it is printing all the values continously :(
I need to stop with 25 values and display.
If its possible with SQL block alone; then it would be of great help
DECLARE
v_str VARCHAR2 (32767) := NULL;
CURSOR c1
IS
SELECT DISTINCT title_id
FROM pack_relation
WHERE package_id IN ( SELECT DISTINCT fa.package_id
FROM annotation fa
GROUP BY fa.package_id
HAVING COUNT
(fa.package_id) <100);
BEGIN
FOR i IN c1
LOOP
v_str := v_str || ',' || i.title_id;
END LOOP;
v_str := SUBSTR (v_str, 2);
DBMS_OUTPUT.put_line (v_str);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error-->' || SQLERRM);
END;Thanks...You can use CEIL
Sample code
SELECT
nt,
LTRIM(MAX(SYS_CONNECT_BY_PATH(val,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
FROM
SELECT
val,
nt,
ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) AS curr,
ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) -1 AS prev
FROM
SELECT
level AS val,
ceil(rownum/3) as nt /* Grouped in batches of 3 */
FROM
dual
CONNECT BY level <= 10
GROUP BY
nt
CONNECT BY prev = PRIOR curr
AND nt = PRIOR nt
START WITH curr = 1;
NT CONCAT_VAL
1 1,2,3
2 4,5,6
3 7,8,9
4 10Your code
SELECT
nt,
LTRIM(MAX(SYS_CONNECT_BY_PATH(title_id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
FROM
SELECT
title_id,
nt,
ROW_NUMBER () OVER (PARTITion BY nt ORDER BY title_id) AS curr,
ROW_NUMBER() OVER (PARTITION BY nt ORDER BY title_id) -1 AS prev
FROM
SELECT
title_id,
ceil(rownum/25) AS nt /* Grouped in batches of 25 */
FROM
pack_relation tdpr
JOIN annotation fa
ON
tdpr.package_id = fa.package_id
GROUP BY
title_id,
fa.package_id
HAVING
COUNT (fa.package_id) < 500
GROUP BY
nt
CONNECT BY prev = PRIOR curr
AND nt = PRIOR nt
START WITH curr = 1;
Maybe you are looking for
-
Samsung S4 Will not work with ANGOLA (UNITEL) SIM Card
I have a Verizon Galaxy S4 that I cannot get to work with a local SIM card in ANGOLA. I was told my phone would work with an overseas sim card. I need HELP. My phone will not use an ANGOLA UNITEL sim card for data. I believe my phone is still loc
-
Gated check-in dialog box will not be displayed
Hi I created a Gated check-in build process. I would like the gated check-in dialog box that informs the developer that he needs to build his changes for validation will not appear and will be automatically approved. Is it possible? Thanks Rachel
-
Header/Footer sizing not constant
Hi, I'm trying to output Acrobat 9 pro pdf's with header/footer text at a constant size relative to the paper (letter) . I have found the appearance options screen where I've set the "Keep position and size of header/footer text constant when printin
-
UWL-version management and Workflow
Hi all I have a UWL which opens a WD Java application when any work-item is clicked. This leaded to some changes in the workflow in the back-end. Its working fine. But the problem is for the tasks which are built from the old workflow because the tas
-
Function Module 'DATE_TO_PERIOD_CONVERT' for 0FISCPER
hello All, I have a date field / infoobject ST_UP_DTE in the Transfer Rules of 2LIS_11_VAITM. I want write a routine for 0FISCPER to get the data from this Date Field, i have written code below , CALL FUNCTION 'DATE_TO_PERIOD_CONVERT' EXPORTING