Variable linesize
Is there a way to set the linesize to a variable length? I'm creating a pipe delimited data file that would have a max linesize of 700, but a majority of the records use only about 60% of that. I'd like to limit the size of the file so I'm looking for a way to have the linesize vary per record.
Assuming you want each record to take a single line, you can minimize the length of lines by making sure that SET TRIM and TRIMSPOOL are ON.
- CJ
Similar Messages
-
How to remove \r\n in clob
ORACLE 10
PL/SQL
buffer := UTL_RAW.cast_to_raw (DBMS_LOB.SUBSTR (pa_inout_clob_data, 16000, lv_begin_pos_zonder_doctag));
for example:
UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0VUtP20AQviP1P1h7rewNPVRVFYcDj2OL1FTluqzH
ycK+tDMB8u8764AVwMSBiIsle/d7zLc74+
MUST BE
UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0VUtP20AQviP1P1h7rewNPVRVFYcDj2OL1FTluqzHycK+tDMB8u8764AVwMSBiIsle/d7zLc74+Hi,
since Oracle 10g REPLACE works also with CLOB.
To remove new line characters you can do:
pa_inout_clob_data := REPLACE(pa_inout_clob_data, CHR(10));
But is the output diplayed CLOB or RAW?
I have the impression that your problem is just an SQL output display problem.
By default variable linesize and long are set to 80
If this is the problem in sqlplus just set:
SET LINESIZE xxx
SET LONG yyy
replace xxx and yyy with the lenght you need.
Regards.
Al -
HOW TO SET DEFAULT LINESIZE ENVOIRMENT VARIABLE
when i logon to oracle my linsize setting is
currrent linesize 100
i would like to change it to 1000 as default not session
specific
Actualy when i am saving some data (narration/Desc) from d2k
forms it get saved properly but when i query it after sometime
narration get truncated to 100 characters Please help me.You can add the line: set linesize 1000 in a login.sql script.
1. In sql*plus type: get login.sql
2a. If file exists and you get some output then type: ed
2b. add the line: set linesize 1000
3a. if the file doesn't exists then type: set linesize 1000
4. type: save login.sql replace
replace will replace the login.sql file if already exists. -
OPEN DATASET FOR INPUT IN TEXT MODE - linesize issue
Hi,
I faced a problem when opened ANSI file with CYRILLIC in ECC 6.0 Unicode system - the system cuts the line to 250 characters. Below is snip of code:
REPORT Z_TEST_01 LINE-SIZE 1023.
DATA:
file TYPE char40 VALUE 'ansi_file.txt',
line TYPE char1024, len TYPE i.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
WHILE sy-subrc = 0.
READ DATASET file INTO line ACTUAL LENGTH len.
WRITE: / len, line.
ENDWHILE.
CLOSE DATASET file.
In this case, variable LEN always get value 250. File-content is correctly converted from ANSI and all CYRILLIC is displayed to the screen. I changed type for LINE - initialy the type was STRING, actially.
Further, tried to open it in BINARY - like this:
DATA:
file TYPE char40 VALUE 'ansi_file.txt',
line TYPE char1024, len TYPE i.
FIELD-SYMBOLS <hex_container> TYPE x.
OPEN DATASET file FOR INPUT IN BINARY MODE.
ASSIGN line TO <hex_container> CASTING.
DO.
READ DATASET file INTO <hex_container>.
IF sy-subrc = 0.
WRITE: / line.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
WRITE: / line.
In this case I got bigger linesize (obviously 1024), but faced conversion issues - the file contains some CYRILLIC and it is messed. Played for few hours with conversions - using additions: IN LEGACY BINARY MODE... BIG/LITTLE ENDIAN, CODE PAGE... without success. So decided to ask...
Well, I searched SDN for a similar issue, but didn't found, except this one:
Re: OPEN DATASET STRING Problem
Could someone points me what am I doing wrong? How can I read my ANSI file with line-size more than 250 chars? Actually, in my case line size may vary up to 1800 chars. Further, afrer conversion and some validation, I should save it back to the AS.
Many thans in advance.
Regards,
Ivaylo MutafchievSorry for the noise - it is not an issue anymore.
-
How to get the current values of LINESIZE and WRAP in SQLplus ?
How do I get the current values for the SQLplus environment variables
e.g. LINESIZE, WRAP, PAGESIZE ?
When I type
SQL> show parameter LINESIZE
nothing is displayed.
Is there a command to show ALL existing current paramter values at once ?SQL> show linesize
linesize 134
SQL> show wrap
wrap : regels zullen omgeslagen worden
SQL> show pagesize
pagesize 50000And you can issue a "show all" to see all settings at once.
Regards,
Rob. -
How do I get the datatype of a variable or a field in table?
Dear Friends,
In Pl/SQL, How do I determine the datatype of a variable or a field in a table?
While writing pl/sql code, I need to determine the datatype. Is there any option or function in pl/sql or in d2k.
waiting for your response...
Sanjaiwrite a function based on this code with column_name and table_name
as parameter and you get the data type as output.
SQL> create table mytable(empno number, ename varchar2(32))
2 /
Table created.
SQL>
SQL> set linesize 100
SQL> column table_name format a32
SQL> column data_type format a32
SQL>
SQL> select table_name, data_type
2 from user_tab_columns
3 where table_name='MYTABLE'
4 /
TABLE_NAME DATA_TYPE
MYTABLE NUMBER
MYTABLE VARCHAR2 -
Using Bind variables in SQL PLUS Report
using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
error: Bind Variable "ENDING_DATE" not declared
Report Date and Time:
26-OCT-2010 15:44:13
List of Unapproved Adjustments
Bind Variable 'ENDING_DATE" not declared
Please see below the code for the sql plus report:
define p_org_id = '&1'
define p_fy_begin_date = '&2'
define p_start_date = '&3'
define p_end_date = '&4'
define p_conversion = '&5'
declare
variable begin_date date;
exec :begin_date := p_start_date;
variable ending_date date;
exec :ending_date := p_end_date;
/* Begin
:begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
:ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
End; */
set newpage none
set termout off
set pagesize 55
set linesize 180
set heading on
set feedback off
set wrap off
set space 1
set heading on
begin
dbms_application_info.set_client_info('&p_org_id');
end;
prompt
prompt Report Date and Time:
prompt ----------------------
select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
from dual ;
prompt
prompt List of Unapproved Adjustments
prompt -------------------------------
select b.trx_number,
a.adjustment_number,
f.user_name created_by
from apps.ar_adjustments a,
apps.ra_customer_trx b,
apps.fnd_user f
where a.customer_trx_id = b.customer_trx_id
and a.status <> 'A'
and a.created_by = f.user_id
and a.creation_date between :begin_date
and :ending_date
-- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
-- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
order by
b.trx_number ;Hi
Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
vishnu
null -
How to Use SPOOL Command with Bind Variables
For the Following SPOOL I want the GEN_DATE to be entered by the User at the time of execution of the SQL Script. Is it possible in SPOOL Command.
set colsep , -- separate columns with a comma
set pagesize 1000 -- get rid of disturbing ---- between pages
set heading on -- Print column heading
set trimspool on -- remove trailing blanks. eliminating the spaces up to eol
set linesize 700 -- line size should be the sum of the column widths
spool spool_results.csv
SELECT *
FROM GUI_SITE_JOURNAL
WHERE GENDATE_ BETWEEN '2012-11-01 00:00:00:00000' AND '2012-11-02 00:00:00:00000'* ORDER BY GEN_DATE;
spool off;
The reason is to give the ability to user so that he can enter any range without modifying the code of the script.
Can Any one help me please.
Edited by: user10903866 on Feb 18, 2013 7:44 PMHi,
user10903866 wrote:
For the Following SPOOL I want the GEN_DATE to be entered by the User at the time of execution of the SQL Script. Is it possible in SPOOL Command.Do you want the user input in the SPOOL command, or do you want it in the query?
set colsep , -- separate columns with a comma
set pagesize 1000 -- get rid of disturbing ---- between pages
set heading on -- Print column heading
set trimspool on -- remove trailing blanks. eliminating the spaces up to eol
set linesize 700 -- line size should be the sum of the column widths
spool spool_results.csv
SELECT *
FROM GUI_SITE_JOURNAL
WHERE GENDATE_ BETWEEN '2012-11-01 00:00:00:00000' AND '2012-11-02 00:00:00:00000'* ORDER BY GEN_DATE;What is the data type oif gen_date?
If it's a string, that's a big mistake. Information about dates belongs in DATE columns.
If it's a DATE, then don't try to compare it to strings, such as '2012-11-01 00:00:00:00000' .
spool off;
The reason is to give the ability to user so that he can enter any range without modifying the code of the script.
Can Any one help me please.One way to do that is with substitution variables:
SET VERIFY OFF
ACCEPT start_gen_date PROMPT "Starting date (e.g., 2013-02-18 23:00:00.00000): "
ACCEPT end_gen_date PROMPT "Ending date (e.g., 2013-02-18 23:59:59.99999): "
SPOOL spool_results.csv
SELECT *
FROM gui_site_journal
WHERE gen_date BETWEEN '&start_gen_date'
AND '&end_gen_date'
ORDER BY gen_date;
SPOOL OFFThere are security considerations. Substitution variables give devious users the power to issue any SQL command, such as DROP TABLE. Users that have SQL*Plus access already have that power, anyway. -
Trace files showing bind variables value=""
10g on solaris
Hi All,
We have an issue with an informatica workflow issuing an update statment to Oracle in trems of performace.
I switched the tracing on using DBMS_SUPPORT with binds set to TRUE. It has captured the trace files accordingly against a controlled set of data. Twot trace files were produced.
The first trace files shows the SELECT statment being issues that identifies the records that will be updated.
The 2nd trace file shows the actual UPDATE statment being issued as a PL/SQL loop to do the update.
There were 20 records that the users have rigged to updated and the update statment shows 20 cases where updates took place. All updates took place succesfully after checking the post results. However my issue is why the trace files are showing the bind vaules as being set to ""?..any ideas appreciated!
an extract of the trace file...
PARSING IN CURSOR #1 len=123 dep=0 uid=1482 oct=6 lid=1482 tim=994827916280 hv=3649357857 ad='8b5b98f0'
UPDATE /*+ index(FCT_TASK IDX_FCT_TASK_CASE_SBL_ROW_ID)*/ FCT_TASK SET DWH_LAST_UPD_DT = SYSDATE WHERE CASE_SBL_ROW_ID = :1
END OF STMT
PARSE #1:c=10000,e=980,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=994827916264
=====================
PARSING IN CURSOR #5 len=227 dep=1 uid=0 oct=3 lid=0 tim=994827919231 hv=2190775527 ad='8e622670'
select u.name,o.name, t.update$, t.insert$, t.delete$, t.enabled from obj$ o,user$ u,trigger$ t where t.baseobject=:1 and t.obj#=o.obj# and o.owner#=u.user# and bitand(property,16)=0 and bitand(property,8
)=0 order by o.obj#
END OF STMT
PARSE #5:c=0,e=1310,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=1,tim=994827919223
BINDS #5:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=0001 size=24 offset=0
bfp=ffffffff7c058d98 bln=22 avl=04 flg=05
value=425212
EXEC #5:c=10000,e=9476,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=994827928883
FETCH #5:c=0,e=104,p=0,cr=1,cu=0,mis=0,r=0,dep=1,og=4,tim=994827929051
STAT #5 id=1 cnt=0 pid=0 pos=1 obj=0 op='SORT ORDER BY (cr=1 pr=0 pw=0 time=172 us)'
STAT #5 id=2 cnt=0 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=1 pr=0 pw=0 time=110 us)'
STAT #5 id=3 cnt=0 pid=2 pos=1 obj=0 op='NESTED LOOPS (cr=1 pr=0 pw=0 time=105 us)'
STAT #5 id=4 cnt=0 pid=3 pos=1 obj=79 op='TABLE ACCESS BY INDEX ROWID TRIGGER$ (cr=1 pr=0 pw=0 time=103 us)'
STAT #5 id=5 cnt=0 pid=4 pos=1 obj=123 op='INDEX RANGE SCAN I_TRIGGER1 (cr=1 pr=0 pw=0 time=78 us)'
STAT #5 id=6 cnt=0 pid=3 pos=2 obj=18 op='TABLE ACCESS BY INDEX ROWID OBJ$ (cr=0 pr=0 pw=0 time=0 us)'
STAT #5 id=7 cnt=0 pid=6 pos=1 obj=36 op='INDEX UNIQUE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=0 us)'
STAT #5 id=8 cnt=0 pid=2 pos=2 obj=22 op='TABLE ACCESS CLUSTER USER$ (cr=0 pr=0 pw=0 time=0 us)'
STAT #5 id=9 cnt=0 pid=8 pos=1 obj=11 op='INDEX UNIQUE SCAN I_USER# (cr=0 pr=0 pw=0 time=0 us)'
BINDS #1:
bind 0: dty=1 mxl=32(30) mal=00 scl=00 pre=00 oacflg=01 oacfl2=800000 size=32 offset=0
bfp=ffffffff7c17b0a0 bln=32 avl=04 flg=05
value=""
EXEC #1:c=8390000,e=8740989,p=55593,cr=55610,cu=3,mis=1,r=1,dep=0,og=1,tim=994836657483
BINDS #1:
bind 0: dty=1 mxl=32(30) mal=00 scl=00 pre=00 oacflg=01 oacfl2=800000 size=32 offset=0
bfp=ffffffff7c17b0a0 bln=32 avl=04 flg=05
value=""
EXEC #1:c=7980000,e=7962369,p=55591,cr=55608,cu=1,mis=0,r=1,dep=0,og=1,tim=994844621479
BINDS #1:
bind 0: dty=1 mxl=32(30) mal=00 scl=00 pre=00 oacflg=01 oacfl2=800000 size=32 offset=0
bfp=ffffffff7c17b0a0 bln=32 avl=04 flg=05
value=""
ect ect ect...
Regards
Satnamspliffer wrote:
Having investigated on the comment of NVARCHAR2 not allowing bind variables to be displayed in the trace file... I checked the datatype of the table/column being used in the index and its is defined as VARCHAR2(15)... ? so Im still not sure as to why we are still getting this.. could it be to do with the clinet application and the way in which it passes the bind vlaues to the oracle update statment?
any ideas appreciated?
regards
SatnamHere is a very brief demonstration.
The script:
VARIABLE V1 VARCHAR2
VARIABLE V2 NVARCHAR2
EXEC :V1:='A'
EXEC :V2:='A'
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'FIND_ME';
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
SELECT
FROM
(SELECT
ROWNUM COUNTER,
CHR(MOD(ROWNUM-1,26)+65) CHARACTER
FROM
DUAL
CONNECT BY
LEVEL<=100)
WHERE
CHARACTER= :V1;
SELECT
FROM
(SELECT
ROWNUM COUNTER,
CHR(MOD(ROWNUM-1,26)+65) CHARACTER
FROM
DUAL
CONNECT BY
LEVEL<=100)
WHERE
CHARACTER= :V2;
SELECT SYSDATE FROM DUAL;
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT OFF';In the script we have two bind variables defined, the first a VARCHAR2 and the second a NVARCHAR2. The output of the script looks like this in both cases:
COUNTER C
1 A
27 A
53 A
79 AThe 10046 trace file looks like this:
PARSING IN CURSOR #3 len=152 dep=0 uid=31 oct=3 lid=31 tim=2874162497 hv=2898495116 ad='a5259590'
SELECT
FROM
(SELECT
ROWNUM COUNTER,
CHR(MOD(ROWNUM-1,26)+65) CHARACTER
FROM
DUAL
CONNECT BY
LEVEL<=100)
WHERE
CHARACTER= :V1
END OF STMT
PARSE #3:c=0,e=128,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=2874162493
BINDS #3:
kkscoacd
Bind#0
oacdty=01 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00
oacflg=03 fl2=1000000 frm=01 csi=178 siz=32 off=0
kxsbbbfp=0f176c88 bln=32 avl=01 flg=05
value="A"
EXEC #3:c=0,e=498,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=2874163947
WAIT #3: nam='SQL*Net message to client' ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874164058
FETCH #3:c=0,e=68,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,tim=2874164215
WAIT #3: nam='SQL*Net message from client' ela= 299 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874164657
WAIT #3: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874164903
FETCH #3:c=15625,e=359,p=0,cr=0,cu=0,mis=0,r=3,dep=0,og=1,tim=2874165155
WAIT #3: nam='SQL*Net message from client' ela= 1162 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874166774
STAT #3 id=1 cnt=4 pid=0 pos=1 obj=0 op='VIEW (cr=0 pr=0 pw=0 time=76 us)'
STAT #3 id=2 cnt=100 pid=1 pos=1 obj=0 op='COUNT (cr=0 pr=0 pw=0 time=50 us)'
STAT #3 id=3 cnt=100 pid=2 pos=1 obj=0 op='CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=47 us)'
STAT #3 id=4 cnt=1 pid=3 pos=1 obj=0 op='FAST DUAL (cr=0 pr=0 pw=0 time=4 us)'
WAIT #0: nam='SQL*Net message to client' ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874167438
WAIT #0: nam='SQL*Net message from client' ela= 3939 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874171452
=====================
PARSING IN CURSOR #2 len=152 dep=0 uid=31 oct=3 lid=31 tim=2874171761 hv=2346424803 ad='a597e190'
SELECT
FROM
(SELECT
ROWNUM COUNTER,
CHR(MOD(ROWNUM-1,26)+65) CHARACTER
FROM
DUAL
CONNECT BY
LEVEL<=100)
WHERE
CHARACTER= :V2
END OF STMT
PARSE #2:c=0,e=155,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=2874171757
BINDS #2:
kkscoacd
Bind#0
oacdty=01 mxl=32(02) mxlc=01 mal=00 scl=00 pre=00
oacflg=03 fl2=1000010 frm=02 csi=2000 siz=32 off=0
kxsbbbfp=0f176c88 bln=32 avl=02 flg=05
value=""
EXEC #2:c=0,e=489,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=2874173190
WAIT #2: nam='SQL*Net message to client' ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874173300
FETCH #2:c=0,e=68,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,tim=2874173453
WAIT #2: nam='SQL*Net message from client' ela= 326 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874173906
WAIT #2: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874174137
FETCH #2:c=0,e=334,p=0,cr=0,cu=0,mis=0,r=3,dep=0,og=1,tim=2874174398
WAIT #2: nam='SQL*Net message from client' ela= 1052 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874175570
STAT #2 id=1 cnt=4 pid=0 pos=1 obj=0 op='VIEW (cr=0 pr=0 pw=0 time=76 us)'
STAT #2 id=2 cnt=100 pid=1 pos=1 obj=0 op='COUNT (cr=0 pr=0 pw=0 time=46 us)'
STAT #2 id=3 cnt=100 pid=2 pos=1 obj=0 op='CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=43 us)'
STAT #2 id=4 cnt=1 pid=3 pos=1 obj=0 op='FAST DUAL (cr=0 pr=0 pw=0 time=4 us)'
WAIT #0: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874176119
WAIT #0: nam='SQL*Net message from client' ela= 998 driver id=1413697536 #bytes=1 p3=0 obj#=10192 tim=2874177197
...Notice that the value for the bind variable defined as VARCHAR2 printed in the trace file, while the value for the bind variable defined as NVARCHAR2 did not print in the trace file.
If I had set the STATISTICS_LEVEL to ALL (or used a GATHER_PLAN_STATISTICS hint) I could retrieve the actual execution plan for the above SQL statements like this (if not, replace ALLSTATS LAST with TYPICAL):
SET PAGESIZE 1000
SET LINESIZE 160
SELECT /*+ LEADING(S) */
T.PLAN_TABLE_OUTPUT
FROM
(SELECT
SQL_ID,
CHILD_NUMBER
FROM
V$SQL
WHERE
SQL_TEXT LIKE '% CHARACTER= :V_') S,
TABLE(DBMS_XPLAN.DISPLAY_CURSOR(S.SQL_ID,S.CHILD_NUMBER,'ALLSTATS LAST +COST')) T;The output of the above looks like this:
SQL_ID 33wwr3kqc71nc, child number 0
SELECT * FROM (SELECT ROWNUM COUNTER, CHR(MOD(ROWNUM-1,26)+65) CHARACTER FROM
DUAL CONNECT BY LEVEL<=100) WHERE CHARACTER= :V1
Plan hash value: 761049541
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time |
|* 1 | VIEW | | 1 | 1 | 2 (0)| 4 |00:00:00.01 |
| 2 | COUNT | | 1 | | | 100 |00:00:00.01 |
| 3 | CONNECT BY WITHOUT FILTERING| | 1 | | | 100 |00:00:00.01 |
| 4 | FAST DUAL | | 1 | 1 | 2 (0)| 1 |00:00:00.01 |
Predicate Information (identified by operation id):
1 - filter("CHARACTER"=:V1)
SQL_ID 7qzd4aq5xr6g3, child number 0
SELECT * FROM (SELECT ROWNUM COUNTER, CHR(MOD(ROWNUM-1,26)+65) CHARACTER FROM
DUAL CONNECT BY LEVEL<=100) WHERE CHARACTER= :V2
Plan hash value: 761049541
| Id | Operation | Name | Starts | E-Rows | Cost (%CPU)| A-Rows | A-Time |
|* 1 | VIEW | | 1 | 1 | 2 (0)| 4 |00:00:00.01 |
| 2 | COUNT | | 1 | | | 100 |00:00:00.01 |
| 3 | CONNECT BY WITHOUT FILTERING| | 1 | | | 100 |00:00:00.01 |
| 4 | FAST DUAL | | 1 | 1 | 2 (0)| 1 |00:00:00.01 |
Predicate Information (identified by operation id):
1 - filter(SYS_OP_C2C("CHARACTER")=:V2)Notice in the Predicate Information section of the second execution plan, a function is applied to the column - that SYS_OP_C2C function will likely prevent a normal (non-function based) index from helping to improve the execution performance.
To answer your question, it is the client application that must correctly define the bind variable types.
Charles Hooper
Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Hi
I Must to execute a PL/SQL if work fine then I execute other, But if first not work I want out without to execute of the second
SET LINESIZE 1000
SET SERVEROUTPUT ON
SET TERM ON
SET HEAD OFF
SET ECHO OFF
VAR V_FLAG number
SPOOL C:\TEMP\MYLOG.TXT
----FIRST PL/SQL
BEGIN
EXCEPTION
WHEN OTHER THEN
BLA BLA
:v_flag :=1;
END;
------- SECOND PL/SQL
BEGIN
IF :V_FLAG = 1 THEN
RETURN;
END IF;
EXCEPTION
WHEN OTHERS THEN
BLA BLA
END;But when I execut script It show me
V_FLAG
1Is there some way for no to show , or Other way for to do same thing (Continue second PL/SQL if First work fine )
thanksDo these have to be two separate PL/SQL blocks within
a SQL*Plus script? If so, the SQL*Plus
[url=http://download-uk.oracle.com/docs/cd/B19306_01/s
erver.102/b14357/ch12052.htm]WHENEVER SQLERRORsetting can exit SQL*Plus when an unhandled PL/SQL
exception occurs. You would need to remove the
exception handler or re-raise the exception in it,
otherwise the block completes successfully and
SQL*Plus has no way of knowing anything ever went
wrong.
If you place both blocks within one enclosing PL/SQL
block you can have all the procedural control you
need using PL/SQL.
Thank you
In First BLOCK If number records inserted in Table is not Equal 17 then It do not must to continue second block , then I used a variable
IF SQL%ROWCOUNT =17THEN
DBMS_OUTPUT.PUT_LINE('RECORDS '|| SQL%ROWCOUNT);
-- COMMIT;
ELSE
DBMS_OUTPUT.PUT_LINE('RECORDS NOT EQUAL==>');
ROLLBACK;
:V_FLAG :=1;
RETURN;
END IF;Then When :V_FLAG =1 I use Return in Second Block, but it Show me
V_FLAG
1 -
how do I pull a sequence number from the database and use it in a sqlplus spool filename...
this is running as: sqlplus user/pass@sid@c:\file.sql
example of the file:
BEGIN
declare
V_E_NUMBER varchar2(7);
begin
SeLECT 'E'||lpad(RWP.E_NUMBER_seq.NEXTVAL,6,'0') INTO V_E_NUMBER FROM DUAL ;
end;
end;
SeLECT 'E'||lpad(RWP.E_NUMBER_seq.CURRVAL,6,'0') INTO V_E_NUMBER FROM DUAL ;
set echo off
SET HEADING OFF
SET LINESIZE 430
set verify off
SET PAGESIZE 0
SET TRIMSPOOL ON
SET timing OFF
SET termout ON
SET feedback OFF
spool d:\securedASP\CORE.BU34500.AR.'||:V_E_NUMBER||'.RECEIVD
select * from table;
spool offHi,
Use a substitution variable for that:
COLUMN v_e_number NEW_VALUE v_e
SELECT 'E' || lpad ( RWP.E_NUMBER_seq.NEXTVAL
, 6
, '0'
) AS V_E_NUMBER
FROM DUAL;
SPOOL d:\securedASP\CORE.BU34500.AR.&v_e..RECEIVD Note that this does not use PL/SQL at all.
The variable can be used without quoting or concatenation.
That may lead to situations where it's ambiguous regarding what is part of the variable name (the variable is named v_e in this example), and what is literal text that happens to come right after it. To resolve such questions, use a period to mark the end of the variable name.
In your case, you want a literal period right after the variable name, so use two: the first one marks the end of the name, and the second one is taken literally.
Look up the SQL*Plus commands
COLUMN,
SET CONCAT, and
SET DEFINE
for details. -
Dear Guru's,
Is it possible to perform a variable time based operation like:
SQL> alter standby database recover standby database until time "to_date(sysdate-3)"
SQL> alter standby database recover standby database until time sysdate-3
Thanx in advance.This solution works fine:
$ sqlplus -s "/as sysdba"
set pagesize 0
set linesize 50
set feedback off
set sqlprompt ''
set time off
set pause off
spool recoverstdby.sql
select 'recover standby database until time ' || to_char('''') || to_char(sysdate-3, 'yyyy-mm-dd') || to_char('''') || ';' from dual;
spool off
@recoverstdby -
_global _root variable problems
I am creating an interactive whiteboard which uses action
script to trace the useers mouse movements and draw a line. Which
works perfectly, the line coulour is set using a variable which is
initialised at the beginning of the code:
if (count != true){
_global.linesize = 6;
_global.linecolour = 0x000000;
_global.line = false;
count = true;
However in order to allow the user to change the colour of
their lines, i have created a simple bit of code which changes the
value of the _global.linecolour variable to Red for example
(0xFF0000).
on(press){
_global.linecolour = 0xFF0000;
*Please do not comment on the use of (press) instead of
(release) it is meant to be that way*
The variable is being changed, but for some reason the change
does not affect the code on the timeline.
The code on the timeline and on the button is as follows:I have tried defining the _global variables outside of the
functions, to no avail.
However there is one confusing aspect in that the line is
being drawn in the colour selected, but is then changing to the
colour defined in the
if(count != true) statement. I cannot understand why, as
there can only be one instance of each variable, and they all refer
to _global. -
SP2-0552: Bind variable not declared error. Any help please?
Hi Experts,
I have a question regarding the error that I am getting: SP2-0552: Bind variable "V_COUNT_TOT_BAL" not declared.
I have 'out' parameters declared in my procedure and executing the same from sql script as shown below:
set ver off
set serverout on
set linesize 8000
Declare
Variable v_count_dtl_bal NUMBER(10);
Variable v_updat_dtl_bal NUMBER(10);
Variable v_count_tot_bal NUMBER(10);
Begin
execute load_abc.insert_abc_bal(:v_count_dtl_bal,:v_updat_dtl_bal,:v_count_tot_bal);
End;
exit;
So, when this sql script runs it given me the above error. However, all the result looks good and there's no problem with the data or anything else that might be impacted. I suspect this error stems from the code in the sql script above.
Any idea what am I doing wrong?
Thanks in advance for any inputs.Thanks Frank. I still receive the same error if I follow your example or any of the ones explained above. This is what I am getting and still an error underneath:
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]
SP2-0552: Bind variable "V_COUNT_TOT_BAL" not declared. -
How to explain plan with bind variable
I want to explain plan for query which contains bind variables. I try to execute the query "explain plan for <query>" using PreparedStatement. If I set the bind variable using setXxx method, I get "ORA-01006: bind variable does not exist" error, if I don't bind, I get "java.sql.SQLException: Missing IN or OUT parameter at index:: 1". First error seems to be generated by JDBC driver, the second by the database. Problem is, that database does not require the bind variables to be bound, but the drivers does. Is there any way to do it?
I use JDBC 10.1.0.5.0, database is Oracle9i Enterprise Edition Release 9.2.0.6.0.
Thanks in advance,
Viliamhope this helps;
SQL> set pagesize 25
SQL> set linesize 141
SQL> explain plan for
2 select ename from emp where ename = :x ;
Explained.
SQL> SELECT * FROM table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 6 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 1 | 6 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("ENAME"=:X)
13 rows selected.
http://psoug.org/reference/explain_plan.html
http://psoug.org/reference/dbms_xplan.html
Maybe you are looking for
-
OSX 10.8.4 and Quicktime 10.2
I just downloaded a .mov file. When I try to open it I get the error message "the file could not be opened. The movies file format isn't recognized" . Any suggestions?
-
How do I get a larger font in the Tabs and Adress bar?
I have poor eyesight and when I open Firefox the Tabs Bar and the address bars is to small for me to read. I have to use a magnifying Glass to read them and than up close.
-
My startup HD always appeared in desktop. But since I formatted it and installed Leopard again it doesn't mount automatically in desktop. How do I do to mount it in desktop?
-
Lockbox Cash app not applying correct
Here is an example of an issue I am having. On 4/4 check # 15093 (Doc # 140008734 and # 100014472) created one deduction for $3,076.77 and two overpayments ($167.53 and $704.34). On 4/19 check # 15194 (Doc # 1400010705) was system applied. This appl
-
I have installed WAS 6.20 and J2EE server (90 days trial edition) on my machine. After starting J2EE server, I opened Netweaver studio and created a web dynpro application. In the window->preferences option of Studio, I have defined J2EE server setti