Difference in query output after using cursor
can any one help out why the differences are in output, especially the bold and italic ?
SQL> alter session set cursor_sharing='EXACT';
Session altered.
SQL> select '2' from dual;
2
SQL> select 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaa' from dual;
'AAAAAAAAAAAAAAAAAAAAAAAAAAAA
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SQL> alter session set cursor_sharing='SIMILAR';
Session altered.
SQL> select '8' from dual;
'8'
8
SQL> select TRIM('8') from dual;
TRIM('8')
8
SQL> select 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' from dual;
'BBBBBBBBBBBBBBBBBBBBBBBBBBBBB
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
SQL> select TRIM('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') from dual;
TRIM('BBBBBBBBBBBBBBBBBBBBBBBB
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
SQL> select TRIM('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') from dual;
TRIM('BBBBBBBBBBBBBBBBBBBBBBBB
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
oracle support says it best:
When cursor_sharing = exact,
we don't convert the literal into binds and hence we know the actual size of the
format mask. So buffer length is computed and known.
When cursor_sharing = similar / force, the intention is to reuse the cursor for similar types of statements to avoid re-parsing. So the server converts the literal (format mask) into a bind. At this stage we don't know the actual size of the data, and set buffer length to be maximum, however this affects the display of the column header length in SQLPLUS; not the actual data .
Similar Messages
-
Exporting Query Output after expanding manually,
Hi Experts,
we have some troubles making work some buttons on one of our queries.
When trying to export the query information after expanding it manually, we just get the excel and the csv with the first displayed information. I mean we just got the query collapsed as it was initially displayed before expanding.
Seems to be a rookie problem, but we do not know how to solve it.
Hope you can help us.
Regards,
RobertoHello,
Currently I'm using a more or less stable combination of SQLPlus, spool-command, html-format and batch-file but I would like to get more stable results, preferrably in xls / csv format.
If you have only SQL*PLUS, then your options are quite limited. Which part of your combination do you think is "unstable"? Except the HTML format it is a very common stack to generate reports. Other possibilities:
Re: Create a CSV file
Re: DBMS result in exel
For further questions you should open your own thread, preferrably in another forum space -> PL/SQL
Regards
Marcus -
Exporting Web Query Output after expanding manually
Hi Experts,
we have some troubles making work some buttons on one of our queries.
When trying to export the query information after expanding it manually, we just get the excel and the csv with the first displayed information. I mean we just got the query collapsed as it was initially displayed before expanding.
Seems to be a rookie problem, but we do not know how to solve it.
Hope you can help us.
Regards,
RobertoWell, you could make sure you never have costs > $10,000 and that would solve it!
8-)
Okay, couldn't resist.
What about trying to change the default formatting for that folder's item in Disco Admin against the EUL directly (ie: setting the format to none like you found, or setting it to 2 digit accuracy, etc.) and see if that works.
Russ -
Help needed in mapping BI query output to use as input for BAPI
Hi,
After wrestling with it for quite some time I choose to ask yet another question here. I want to use the output of a BI query I use as input for a BAPI. I just can not get the mapping correctly:
The query delivers: 104908BA092F7501F5E1008000829000AC
I need: 104908BA092F7501F5E1008000829000AC
How can I lose the two first digits? Thanks in advance!
Best regards,
JanNevermind. I found out myself. I am now using the statement MID(@GUID,2,32) in the connection.
-
Cannot export query output when using UNION ALL
Hi
I can run a query in SQL Developer 1.5.5 and if it's a SELECT statement it works fine, but if I output the result of several SELECT statements using UNION ALL after some 10,000 records the SQL Developer crashes and it generates a file whose size is 0 kb
Is there a workaround for this??
Thanks and Regards!
IsaacShould be fixed in the upcoming 2.1... you can try the RC1 also...
Regards,
K. -
Is there a way to stop a query just after the cursor/plan is produced by CBO?
Following suggestions of Kerry Osborne’s Oracle Blog » Blog Archive » Explain Plan Lies – Kerry Osborn…
on the lies of "Explain plan" (and of "set autotrace on" too) I'd like to try to stop a query/DML before actually it starts, just after the plan was produced and sql_id assigned.
Is there any CLEAN way (other than trying CTRL-C) to do that?
Thanks
PaoloHi
PaolFili wrote:
Thanks rp.
I think my question is a little dofferent, but your reply give me an idea.(which has clear disadvantages , but can do the work).
The problem is obtain in Lybrary Cache a plan,a SLQ_ID,PLAN_HASH for a query ( i.e. a 10days running query) that I cannot start-up.
So my (suggested from your reply) idea is:
1) to LOCK EXCLUSIVE (a table level) , **if it's possible** every table accessed in the query ( Yes, it can be really expansive in some production environment, but sometimes can be necessary ..)
using : LOCK TABLE table IN EXCLUSIVE MODE
for each table accessed from query
2) Startup the query that will be suspended form the lock on tables accessed + kill the sid,serial#,@Inst_id for the query.
3) UNLOCK tables from EXCLUSIVE using "ROLLBACK" in the session where LOCK TABLE.... was send.(to remake tables to work for other queries)
Any other ideas?
Thanks
Paolo
you're planning on using locks to stop a query and you think in order to do so you need exclusive locks on every table accessed in the query? And you are prepared to do that on a production system?
And all of this is needed to troubleshoot a query that was running for 10 days -- i.e. a query that was available for all kinds of diagnostics during 10 days?
Sorry, I think it wasn't a good idea for you to read that Osborne's blog post -- you should've started with more basic things. Way more basic.
Best regards,
Nikolay -
Dear All,
We have two query Z and Y in production,Y Query is directly developed in the production
but Z query is transported from Qulaity.I have checked both the query and found that
structure restriction fiilter is same .But Output is different.
In some case Z query is giving more data and vice versa.
In some query some of the Hirerchy node are missing.
Please guide me.
Thanks is advance.
Regards,
Saveen KumarI once had a similar situation.
Turned out the technical name of hierarchy i was using in the query created in dev and moved to production was slightly different from the one i used in the query created directly in production.
I later found that version of hierarchy was not maintained in production and so my report was inconsistent between the two reports.
Check the technical names of hierarchies and other objects to make sure they are all consistent.
Good Luck.
MP. -
No Query Result After Using Hierarchy Node Variable (Customer Exit)
Hi
I have problem at my query. It doesn't show anything in BEx but when i check the data in BW using tcode LISTCUBE i can display the data.
This problem happen when i change the restrictions for one of characteristic in filter value.
The characteristic is custom Infoobject (ZCPARTNER), which like Infoobject Partner Unit.
Previously I set the restriction with constant value, example : A500,A700,A710,A720,A730,A740 and it worked before.
But when I change it using hierarchy node variable (customer exit), this problem is arise.
Here is my code at ZXRSRU01
WHEN 'ZHIEPART'. --> hierarchy node variable
BREAK-POINT.
IF i_step = 2.
Read from ZZCONSGR information
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = 'ZZCONSGR' OR vnam = 'ZOCONSGR'. --> read input value from consolidation group variable
CLEAR l_s_range.
CLEAR l_s_range-low.
IF loc_var_range-low EQ '000000000000030000'
OR loc_var_range-low EQ '000000000000010130'.
l_s_range-low = 'MEZBUNITMDI'.
l_s_range-high = '0HIER_NODE'.
ELSEIF loc_var_range-low EQ '000000000000040000'
OR loc_var_range-low EQ '000000000000010160'.
l_s_range-low = 'MEZBUNITMPI'.
l_s_range-high = '0HIER_NODE'.
ENDIF.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
ENDIF.
Here the hierarchy in BW system:
XXX Cons Unit Hierarchy Set; InfoObject ; Node Name
- XXX Cons Unit Hierarchy Set; 0HIER_NODE; ZBUNITALL
- XXX DownStream ... ; OHIER_NODE; MEZBUNITMDI
- ME/A730; 0CS_UNIT; MEA730
- ME/A740; 0CS_UNIT; MEA740
- XXX Power ; OHIER_NODE; MEZBUNITMPI
- ME A800 - A808; OHIER_NODE; MEZBUNITMPI
- PT Mitra xxx; 0CS_UNIT; MEA820
Anyone can help my problem? Thank you
Regards,
Satria B TandyonoHi Satria,
Instead of following code ---
CLEAR l_s_range-low.
IF loc_var_range-low EQ '000000000000030000'
OR loc_var_range-low EQ '000000000000010130'.
l_s_range-low = 'MEZBUNITMDI'.
l_s_range-high = '0HIER_NODE'.
ELSEIF loc_var_range-low EQ '000000000000040000'
OR loc_var_range-low EQ '000000000000010160'.
l_s_range-low = 'MEZBUNITMPI'.
l_s_range-high = '0HIER_NODE'.
ENDIF.
try this ---
IF loc_var_range-low EQ '000000000000030000'
OR loc_var_range-low EQ '000000000000010130'.
l_s_range-low = 'MEZBUNITMDI'.
ELSEIF loc_var_range-low EQ '000000000000040000'
OR loc_var_range-low EQ '000000000000010160'.
l_s_range-low = 'MEZBUNITMPI'.
ENDIF.
Note : whenver the option is EQ, the system takes only low value. -
DRG-51030: wildcard query expansion after using @
The following query returns one row:
select * from userinterface where contains (searchtx, 'Mustermann within name and %gmx.de within email')>0;
returns one row.
If I add @ (=> %@gmx.de within email) the following error occurs:
select * from userinterface where contains (searchtx, 'Mustermann within name and %@gmx.de within email')>0;
returns
ERROR at line 1:
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-51030: wildcard query expansion resulted in too many terms
Is the character @ a special character causing the wildcard query expansion? "@gmx.de" is more restictive compared to "gmx.de" (Oracle 10.2.0.4)
select * from userinterface where contains (searchtx, 'Mustermann within name and %de within email')>0;
is also working and returns three rows.Like Roger said, you could include the @ in your printjoins attribute of your basic_lexer and use a substring_index, then that might allow you to search for '%@gmx.de' and find '[email protected]' without encountering the wildcard expansion error. Increasing the wildcard_maxterms would also make the error less likely. However, I believe that is using Oracle Text in a manner other than it is intended and will cause more problems than it will solve, like increasing the size of your domain index tables by storing substrings and making your searches slower.
If you just leave things the way they are, then @ and . are treated as spaces and '[email protected]' is seen as 'somebody gmx de' and indexed as three separate words, so searching for '@gmx.de' will search for 'gmx de' and will find it, so there is no need for a leading wildcard. If you want to avoid problems with errors due to users entering unnecessary leading wildcards with such special characters, then you can replace them in the string before searching. I usually find it convenient to create a cleanup function and include any such problems, then include that in my code that uses a bind variable for the search string. Please see the example below.
SCOTT@orcl_11gR2> -- table:
SCOTT@orcl_11gR2> create table userinterface
2 (id number,
3 searchtx xmltype)
4 /
Table created.
SCOTT@orcl_11gR2> -- lexer:
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference('german_lexer','basic_lexer');
3 ctx_ddl.set_attribute('german_lexer','composite','german');
4 ctx_ddl.set_attribute('german_lexer','mixed_case','yes');
5 ctx_ddl.set_attribute('german_lexer','alternate_spelling','german');
6 end;
7 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- index:
SCOTT@orcl_11gR2> CREATE INDEX ui_t_ind on userinterface (searchtx)
2 indextype is ctxsys.context
3 PARAMETERS ('
4 SECTION GROUP ctxsys.auto_section_group
5 LEXER german_lexer
6 MEMORY 100000000
7 SYNC (MANUAL)'
8 )
9 /
Index created.
SCOTT@orcl_11gR2> -- insert data:
SCOTT@orcl_11gR2> insert /*+ APPEND */ into userinterface (id, searchtx)
2 values (1, xmltype (
3 '<?xml version="1.0"?>
4 <data>
5 <name>Mustermann</name>
6 <email>[email protected]</email>
7 </data>'))
8 /
1 row created.
SCOTT@orcl_11gR2> insert /*+ APPEND */ into userinterface (id, searchtx)
2 values (2, xmltype (
3 '<?xml version="1.0"?>
4 <data>
5 <name>Hans Haeberle</name>
6 <email>[email protected]</email>
7 </data>'))
8 /
1 row created.
SCOTT@orcl_11gR2> -- synchronize, then optimize with rebiuld:
SCOTT@orcl_11gR2> begin
2 ctx_ddl.sync_index ('ui_t_ind');
3 ctx_ddl.optimize_index ('ui_t_ind', 'rebuild');
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- what is tokenized, indexed, and searchable:
SCOTT@orcl_11gR2> select token_text from dr$ui_t_ind$i
2 /
TOKEN_TEXT
DATA
EMAIL
Haeberle
Hans
Häberle
Mann
Muster
Mustermann
NAME
com
de
gmx
somebody
unknown
whatever
15 rows selected.
SCOTT@orcl_11gR2> -- function to clean up search strings:
SCOTT@orcl_11gR2> create or replace function cleanup
2 (p_string in varchar2)
3 return varchar2
4 as
5 v_string varchar2 (100);
6 begin
7 v_string := p_string;
8 v_string := replace (p_string, '%@', ' ');
9 return v_string;
10 end cleanup;
11 /
Function created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> -- example search strings, queries, and results:
SCOTT@orcl_11gR2> column name format a15
SCOTT@orcl_11gR2> column email format a20
SCOTT@orcl_11gR2> variable search_string varchar2 (100)
SCOTT@orcl_11gR2> begin
2 :search_string :=
3 'Mustermann within name and %@gmx.de within email';
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> select id,
2 extractvalue (u.searchtx, '//name') name,
3 extractvalue (u.searchtx, '//email') email
4 from userinterface u
5 where contains (searchtx, cleanup (:search_string)) > 0
6 /
ID NAME EMAIL
1 Mustermann [email protected]
1 row selected.
SCOTT@orcl_11gR2> begin
2 :search_string :=
3 'Häberle within name and unknown@whatever within email';
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> select id,
2 extractvalue (u.searchtx, '//name') name,
3 extractvalue (u.searchtx, '//email') email
4 from userinterface u
5 where contains (searchtx, cleanup (:search_string)) > 0
6 /
ID NAME EMAIL
2 Hans Haeberle [email protected]
1 row selected.
SCOTT@orcl_11gR2> -
How to Execute sql query in PL/SQL ( a variable) with out using Cursor or REF cursor
Hi
I am building a dynamic query based on some conditions
as an example
v_query varchar2(2000);
x1 varchar2(20);
y1 varchar2(20);
z1 varchar2(20);
v_query := ' Select x,y,z into x1,y1,z1 From ... ';
Is there any way to execute the query with out using cursor or ref cursor..
Thanks
ArunBoth Tod and Eric provided valid responses given the format of the queory you supplied. Howver, if you want to use dynamic sql in either way, you need to be absolutely certain that your query will always only return a single row (e.g. SELECT COUNT(*) FROM mytable), because if it retuns more than one, your procedure will break unless you have an exception handler to handle either TOO_MANY_ROWS or OTHERS.
If you want to pull in a lot of data without walking a cursor, you should look at the BULK COLLECT options. -
Hi all,
can anybody tell me how to get the result of the following query by using cursor?
SELECT (SUBSTR(' ', 1,LEVEL*2)
|| t1.label) AS t1_label,
amount
FROM
(SELECT t1.label,
t1.ID,
t1.parent_id,
SUM(t2.turnover) AS amount
FROM t1,
t2
WHERE t2.t1_id = t1.id
AND t2.t1_id IN
(SELECT id
FROM t1
START WITH t1.ID = 2
CONNECT BY PRIOR t1.ID = t1.parent_id
GROUP BY t1.label, t1.ID, t1.parent_id
) t1
START WITH t1.ID = 2
CONNECT BY PRIOR t1.ID = t1.parent_id;...and the result:
t1_label amount
B11 11778.54
B121 19980.28
B1211 18842.77
B1212 25480.56
B122 18339.07
B12 23455.9
B13 20876.52Thanks,
Alex
Edited by: 860003 on Jun 9, 2011 1:30 AM
Edited by: 860003 on Jun 9, 2011 1:31 AM
Edited by: 860003 on Jun 9, 2011 1:31 AM860003 wrote:
Is not that i don't want to use hierarchy queries, but find others ways, tricks to reach the result needed. I just want to explore different ways that Oracle provides to resolve issues.Not a problem with that in principle.
Maybe using "loop, if-else, for" will provide us with an elegant way to get the result. However, a problem in principle with this. SQL and PL/SQL are not the same thing. Two separate and very different languages.
In PL/SQL, you can code both PL and SQL - so you can write source code of 2 different language and mix these. The PL/SQL parser is clever enough to figure out what is what and glues the code seamlessly and transparently together.
SQL is used to crunch SQL data. PL/SQL sucks at this in comparison (and Java/.Net sucks a heck of a lot worse at this). Cursor fetch loops? Bulk processing. Neat. But will always be slower than running that data crunching in SQL only.
That is why there is a simple maxim for performance in Oracle: Maximise SQL. Minimise PL/SQL.
Do not use PL/SQL to do what the SQL is perfectly able and capable of doing. The exception is when the processing is too complex for SQL to handle and you need the programming logic part of the PL/SQL language.
My question is how to use this cursor to get the value, fetch it and then get another value(ofc only for the children) and fetch it again so i can output it? I thing this can be achieve but don't know how.All SQLs (and anonymous PL/SQL) are parsed and cursors are created. A cursor is a basically a set of instructions (as seen via execution plans) of how to get the job done. Think of cursors as programs that are executed and output data.
So do you want t create a bunch of cursors (programs) and then call these from PL/SQL, consume their output, create/call new cursor programs and repeat?
Or do you want to create a single cursor program that does the job and outputs the required results?
Maximise SQL. Minimise PL/SQL. -
How to get the query result of improvement (Before and After ) using sql de
how to get the query result of improvement (Before and After ) using sql developer.
Check
http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html -
Ad hoc query - Infoset, after selection it is giving two different output
Hi All,
We are facing problem in ad hoc query, after PQAH Ad hoc query, when we go to one infoset, so after making some selection and putting some output field,
When we click on refresh data button(in lower pane) so it gives only one record, which is incorrect, but when we click on u2018Start Outputu2019 button it gives 3 records those are correct.
Can anyone tell me, why this is giving different output.(first time 1 record, and second time 3 records) record 3 output is correct.
Regards,
Kumar
Edited by: kumar r12 on Mar 18, 2011 9:00 AMHi Kumar,
Are you looking at the "Hit List" or the output of the results in the lower pane? The hit list will only give you the number of persons who will be in your output. The refresh button should give you a preview of the output.
What persons or fields are different or not shown in the preview area vs. the output? Also, what are the dates for the data? Are you looking at current data or looking for history? The output may be showing you history and the preview only current data. Most concerns with Ad Hoc Query output are related to dates - for the selection and the output.
Paul -
BEx Query output in Enterprise Portal using "Information Broadcasting"
Dear Experts,
I am having BEx Query output in Enterprise Portal
EP 6.0 and BW 3.5 version
I am trying to send email attachments from
Portal Query directly
using "Information Broadcasting" tab button
==================================
Email gets triggered Okay,
but Portal URL link is not showing correctly
Here is an Online Link to the BI Document: http://mtv01spbw01.businesssap.com:8100/sap/bw/BEx?CMD=LDOC&INFOCUBE=0CRM_OPPH&QUERY=0CRM_C04_TESTQ001
<b>The URL above is coming wrongly,
I want it to point to
http://mtv01spbw01.businesstree.com:8000/sap/bw/BEx?CMD=LDOC&INFOCUBE=0CRM_OPPH&QUERY=0CRM_C04_TESTQ001</b>
Please help me to correct this error / wrong configuration
any help links would also be appreciated
Thanks,
Aby JacobHi Jacob,
Here, p/s refer to this links.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ca6de811-0c01-0010-43b2-c64584eef943">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ca6de811-0c01-0010-43b2-c64584eef943</a>
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/84/30984076b84063e10000000a1550b0/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/84/30984076b84063e10000000a1550b0/frameset.htm</a>
<a href="http://help.sap.com/saphelp_nw04s/helpdata/en/84/30984076b84063e10000000a1550b0/frameset.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/84/30984076b84063e10000000a1550b0/frameset.htm</a>
OSS Notes : 760775
Hopefully it can helps you a lot.
Many thanks.
Regards,
Niel.
(Many thanks for any points you choose to assign). -
Query: how to use structure and selection and what's the difference between
Query: how to use structure and selection and what's the difference between these two?
Would be appreciated if some experts here give examples to demenstrate on how to use structure and selection in query and what's the difference between these two?
Thanks in advance!Hi Kevin,
1. Well by default all the KF that you include in your query go into a Key Figure Structure. You can additionally have another structure for defining how your chars are laid out. A common example is a Calmonth structure where you have selections for 12 months, quarers and YTD values. This would be a char structure with different selections (for each month, qtr etc)
2. Yes, a selection with a KF is the same as restricting a KF. You can use am RKF is you have one on the left hand side, or if you need to do this locally in the query, right click the structure and choose New Selection, then proceed to choose your KF and reqd char values.
Hope this helps...
Maybe you are looking for
-
Help!!! Error while trying to Deploy on JRun 3.1
Hello I'm trying to deploy my Ejbs for JRun 3.1. I have my deploy script as below: rem The base directory in which JRun is installed set JRUN_HOME=c:\JRun\3.1 rem The Oracle JDBC Drivers set JDBC_DRIVER=%JRUN_HOME%\servers\lib\ojdbc14.jar set ECLIPSE
-
White Screen Of Doom. Someone save me .
If someone can help me immediately, I would greatly appreciate it. When I turned on my computer after work tonight, everything seemed fine. The logo came up with the progress wheel and everything. However it was taking an unusual amount of time to lo
-
Greetings everyone! I am really new to the Adobe world, but I love everything about it!! I am designing a form that has a list of products, I have already put them in a table. But I need it to add according to the quanity the enter and at the end of
-
Anyone else have flickering/ghosting keyboard on iphone 5?
Is anyone has the same problem with me? I type the password on app store, and suddenly would flickering on your keybord. It happened so many times.
-
Print document titles in folder
I have a folder full of recipes, 500 of them, and I want to just print the titles out. How?