SQL*Plus two fetches for getting one row.
Hi all.
I have tested following script.
alter session set events '10046 trace name context forever, level 12';
select * from dual;And achieved such results (extract from .trc file).
SQL*Plus: Release 11.2.0.1.0; (Oracle Version 10.2.0.4.0, 11.2.0.1.0)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 0 0 1
total 4 0.00 0.00 0 0 0 1SQL*Plus: Release 8.1.7.0.0; (Oracle Version 8.1.7.0.0)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 4 1
total 5 0.00 0.00 0 1 4 1Allround Automations PL/SQL Developer 8.0.4; (Oracle Version 10.2.0.4.0, 11.2.0.1.0)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.00 0.00 0 0 0 1Allround Automations PL/SQL Developer 8.0.4; (Oracle Version 8.1.7.0.0)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 1 4 1
total 3 0.00 0.00 0 1 4 11) I can't figure out why sqlplus does TWO fetches for getting ONE row (instead of pl/sql developer).
8i raw trace
PARSING IN CURSOR #1 len=31 dep=0 uid=0 oct=3 lid=0 tim=0 hv=3549852361 ad='4a0155c'
select 'hello world' from dual
END OF STMT
PARSE #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
BINDS #1:
EXEC #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
WAIT #1: nam='SQL*Net message to client' ela= 0 p1=1111838976 p2=1 p3=0
FETCH #1:c=0,e=0,p=0,cr=1,cu=4,mis=0,r=1,dep=0,og=4,tim=0
WAIT #1: nam='SQL*Net message from client' ela= 0 p1=1111838976 p2=1 p3=0
FETCH #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=0
WAIT #1: nam='SQL*Net message to client' ela= 0 p1=1111838976 p2=1 p3=0
WAIT #1: nam='SQL*Net message from client' ela= 0 p1=1111838976 p2=1 p3=0
STAT #1 id=1 cnt=1 pid=0 pos=0 obj=195 op='TABLE ACCESS FULL DUAL '11g raw trace
PARSING IN CURSOR #3 len=30 dep=0 uid=96 oct=3 lid=96 tim=1581355246985 hv=1158622143 ad='b8a1bcdc' sqlid='5h2yvx92hyaxz'
select 'hello world' from dual
END OF STMT
PARSE #3:c=0,e=130,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=1388734953,tim=1581355246984
EXEC #3:c=0,e=40,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=1388734953,tim=1581355247154
WAIT #3: nam='SQL*Net message to client' ela= 7 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=1581355247252
FETCH #3:c=0,e=18,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,plh=1388734953,tim=1581355247324
STAT #3 id=1 cnt=1 pid=0 pos=1 obj=0 op='FAST DUAL (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)'
WAIT #3: nam='SQL*Net message from client' ela= 193 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=1581355247735
FETCH #3:c=0,e=2,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=1388734953,tim=1581355247800
WAIT #3: nam='SQL*Net message to client' ela= 5 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=15813552478552) Is there any possibility to view data provided by each fetch?
Thanks in advance!
P.S.
SQL> sho arraysize
arraysize 15
Thanks.
I have tested two statements.
select 'hello world' from dual where 1=1;
select 'hello world' from dual where 1=0;When query returns no data, there is only one SQL*Net roundtrip (and one fetch)
SQL> set autot on statistics
SQL> select 'hello world' from dual where 1=1;
'HELLOWORLD
hello world
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
528 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select 'hello world' from dual where 1=0;
no rows selected
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
329 bytes sent via SQL*Net to client
481 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processedBut in both cases i found in client trace this sequence of bytes:
] nsprecv: 00 00 36 01 00 00 00 00 |..6.....|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 90 19 43 13 00 00 |....C...|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 00 00 00 00 00 00 |........|
] nsprecv: 00 00 19 4F 52 41 2D 30 |...ORA-0|
] nsprecv: 31 34 30 33 3A 20 6E 6F |1403:.no|
] nsprecv: 20 64 61 74 61 20 66 6F |.data.fo|
] nsprecv: 75 6E 64 0A |und. |In first case - it was in 2nd packet and in second case (query returns no data) - part of 1st packet.
Similar Messages
-
Fetching more than one row from a table after selecting one value from the dropdown
Hi Experts,
How can we fetch more than one row from a table after selecting one value from the dropdown.
The scenario is that I have some entries in the dropdown like below
A B C
11256 VID 911256
11256 VID 811256
11256 SONY 11256
The 'B' values are there in the dropdown. I have removed the duplicate entries from the dropdown so now the dropdownlist has only two values.for eg- 'VID' and'SONY'. So now, after selecting 'VID' from the dropdown I should get all the 'C' values. After this the "C' values are to be passed to other methods to fetch some data from other tables.
Request your help on this.
Thanks,
Preeetam Narkhede.Hi Preetam!
I hope I understand your request proberly, since this is more about Java and less about WebDynpro, but if I'm wrong, just follow up on this.
Supposed you have some collection of your original table data stored in variable "origin". Populate a Hashtable using the values from column "B" (let's assume it's Strings) as keys and an ArrayList of whatever "C" is (let's assume String instances, too) as value (there's a lot of ways to iterate over whatever your datasource is, and since we do not know what your datasource is, maybe you'll have to follow another approach to get b and c vaues,but the principle should remain the same):
// Declare a private variable for your Data at the appropriate place in your code
private Hashtable temp = new Hashtable<String, ArrayList<String>>();
// Then, in the method you use to retrieve backend data and populate the dropdown,
// populate the Hashtable, too
Iterator<TableData> a = origin.iterator();
while (a.hasNext()) {
TableData current = a.next();
String b = current.getB();
String c = current.getC();
ArrayList<String> values = this.temp.get(b);
if (values == null) {
values = new ArrayList<String>();
values.add(c);
this.temp.put(b, values);
So after this, you'll have a Hashtable with the B values als keys and collections of C values of this particular B as value:
VID --> (911256, 811256)
SONY --> (11256)
Use
temp.keySet()
to populate your dropdown.
After the user selects an entry from the dropdown (let's say stored in variable selectedB), you will be able to retrieve the collection of c's from your Hashtable
// In the metod you handle the selection event with, get the c value collection
//and use it to select from your other table
ArrayList<String> selectedCs = this.temp.get(selectedB);
// now iterate over the selectedCs items and use each of these
//to continue retrieving whatever data you need...
for (String oneC : selectedCs) {
// Select Data from backend using oneC in the where-Clause or whatever...
Hope that helps
Michael -
[ASK] Get One Row of Property Value From Dimension in Script Logic
Hello, i need help about how to get one row of property value from dimension in script logic.
Let say there is CATEGORY dimension and the members are like this :
ID YEAR Status
PLAN_2011 2011 A
PLAN_2011_V1 2011 I
ACTUAL_2011 2011 I
FORECAST_2011 2011 I
FORECAST_2011_V1 2011 A
PLAN_2012 2012 A
PLAN_2012_V1 2012 I
ACTUAL_2012 2012 I
FORECAST_2012 2012 I
FORECAST_2012_V1 2012 A
If i scope CATEGORY like this :
*XDIM_MEMBERSET CATEGORY = [CATEGORY].PROPERTIES("YEAR") = "2011"
Then i will get member scope like this :
PLAN_2011 2011 A
PLAN_2011_V1 2011 I
ACTUAL_2011 2011 I
FORECAST_2011 2011 I
FORECAST_2011_V1 2011 A
Question :
In script logic, how can i read the second record of scope and move it to variable ?
Ex. : I read second record, so i can get the data of second record (PLAN_2011_V1, 2011, A).
Is there any function to read all record that had been scope ? So i can read all those 5 records.
Is there any substring or offset function in script logic ? How to use it ?
Thank you.Hi,
Firstly, when we scope the logic, it doesnt fetch the entire record from the member sheet. It just fetches the ID.
Secondly, we dont have the feasibility to read only the second ID and skip the others. However, one alternative is that you use the SELECT statement to store all the IDs in a variable, and then use a FOR loop. But this will loop through all the 5 IDs, as per your example. If you want to skip all the IDs except one, you should maintain some property, so that all the IDs are neglected which doesnt have a particular property value.
Hope you got the idea. -
OCI - Array-Fetch vs. One-row-per-fetch
Hello guys,
i have a question about the OCI and the possibilities about fetches.
Is it possible to get only one row per fetch without setting the array size to 1?
I have a third party application that shows this behaviour which i have rebuild in sqlplus.
SQL> create table mytest (a number);
SQL> begin
2 for i in 1 .. 1500 loop
3 insert into mytest values (i);
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> set autotrace traceonly;
-- Now with the default array size of 15 with sqlplus
SQL> select * from mytest;
118 consistent gets
101 SQL*Net roundtrips to/from client
1500 rows processed
-- Now with a bigger array size (150)
SQL> set arraysize 150
SQL> select * from mytest;
17 consistent gets
11 SQL*Net roundtrips to/from client
1500 rows processed
-- Now the behaviour of the third party application
SQL> set arraysize 1
SQL> select * from mytest;
757 consistent gets
751 SQL*Net roundtrips to/from client
1500 rows processed
SQL> set arraysize 2
SQL> select * from mytest;
757 consistent gets
751 SQL*Net roundtrips to/from client
1500 rows processedThe third party application is a c program and i can not take a look at the code.
So as you can see the consistent gets are the same with arraysize 1 and 2. The sql statement which is executed of the c-program is returning a huge amount of data and it seems like it is run with arraysize 1 or 2 or it is executing a different OCI call.
So now is my question:
Which methods does the OCI interface provide to recieve (fetch) data?
- Is it only array fetching (like sqlplus do) or is it possible to return only one row per fetch with a specific call.
I can speed up the query by setting the bigger array-size in sqlplus .. but i want to point the programers to the possibilities with the OCI.
Thanks and Regards
StefanThe following call in OCI can be used to control the fetched rows
MAX_PREFETCH_ROWS is number of rows you want to fetch in one round trip.
(void) OCIAttrSet((dvoid *)DBctx->stmthp, (ub4) OCI_HTYPE_STMT,
(dvoid *)&MAX_PREFETCH_ROWS,(ub4)sizeof(MAX_PREFETCH_ROWS),(ub4) OCI_ATTR_PREFETCH_ROWS, DBctx->errhp); -
SQL*Plus assignment works for 8i but not 9i
We have scripts that connect to each database on the box and perform database tasks nightly. The scripts first set the environment then connects to each database with SQL*Plus. This works for 8i but fails in the recently created 9i environment.
Because the SQL*Plus connection appears in many areas in the scripts, we assign the following connection string to a variable:
SQLPLUS="/usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba'"
Export SQLPLUS
echo "$SQLPLUS"
(This echo out correctly: /usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba')
It fails when the script calls the assigned variable:
$SQLPLUS <<-EOF
with the following error:
Usage: SQLPLUS [ [<option>] [<logon>] [<start>] ]
where <option> ::= -H | -V | [ [-L] [-M <o>] [-R <n>] [-S] ]
<logon> ::= <username>[<password>][@<connect_string>] | / | /NOLOG
<start> ::= @<URI>|<filename>[.<ext>] [<parameter> ...]
"-H" displays the SQL*Plus version banner and usage syntax
"-V" displays the SQL*Plus version banner
"-L" attempts log on just once
"-M <o>" uses HTML markup options <o>
"-R <n>" uses restricted mode <n>
"-S" uses silent mode
However, if I remove the SQLPLUS variable assignment and changed all occurrence of
$SQLPLUS <<-EOF to
/usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba' <<-EOF
Then the script runs successfully. But this solution is cumbersome.
Any ideas as to how to have the script work with assigning the SQLPLUS variable????
Any help is appreciatedI has an immediate suspicion it might be related to the issue
mentioned in
http://otn.oracle.com/support/tech/sql_plus/htdocs/sub_var2.html#2_7
but this proved wrong: the SP2-306 still occurs in the latest
SQL*Plus.
I wonder what version of 8i you had working? With an old SQL*Plus
8.1.7.0 my connection failed the same as in 9.2 and 10i.
My solution was to do:
SQLPLUS='sqlplus -s'
UNPW='/ as sysdba'
$SQLPLUS "$UNPW" <<EOF
EOFThis worked in 9.2.0.5, 10.1.0.2 and 8.1.7.0.
One common security risk on UNIX remains: putting the username and
password on the command line. On some systems a "ps" command will
show the password to any user. If OS authentication cannot be used
for connection, perhaps putting the username/password in the SQL
script may be more secure?
A final note is that in SQL*Plus 10g, no quotes are needed around
AS SYSDBA, i.e.
sqlplus / as sysdba works from the OS prompt, whereas in 9.2 you need to do
sqlplus "/ as sysdba"This makes a solution easy:
SQLPLUS="/usr/oracle/product/10.1.0/bin/sqlplus -s xxx/xxxxxx@xxxx as sysdba"-- CJ -
Do we need two ports for establishing one connection to EJB from swing clie
Hi all,
I have an application which uses Java Swing client and accesses an EJB to connect to the server.
I am connecting to the EJB using iiop://server-ipaddress:port.
It is required for me to open the firewall to access the above specified ip address and port number. Even though, I am able to access the specific ip address and port number, I am not able to establish the connection.
I tried out to check the porblem and I came to know that, this aplication is trying to open another port also on the same IP address.
I am just wondering whether we need two ports for one connection.
Does anybody face this type of problem?If you need to access on two ports, you would have to open both :)
-
SQL*Plus add-on for Instant Client Package on Solaris-SPARC 32bits ???
Hi,
I need sqlplus for a solaris 32bits platform, but following this page
http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html, if I choose Solaris 32-bit (SPARC), it doesn't give a link to download Instant Client Package - SQL*Plus (as it does if I choose Solaris 64-bit (SPARC) or Windows 32-bit).
I don't understand why... :(SQL*Plus is not supported on the 32-bit versions of 64-bit platforms. Please use the 64-bit version of SQL*Plus. Thanks!
-
Please excuse my ridiculous question,
But I still can4t use mySQL. After installing Oracle 8i and setting all environment path variables, I tried to use SQL plus. But it asked me for an username, password and hostname.
I4ve Win2000 on a stand-alone PC. How can I tell SQL plus the needed parameters???
please help me, because I need mySQL for my examen!!!
mail to: [email protected]I don4t exactly know what you mean, but if you installed the Oracle Server on your Windows 2000 box you can log in to Oracle using useracount SYSTEM with password MANAGER or SYS and CHANGE_ON_INSTALL.
This has nothing to do with mySQL though -
Two clicks for getting focus in h:inputtext ?
Hello.
I have a JSF page whose three first components are *<h:inputText ...*
When I press Tab for get focus on the next inputText, the cursor pass to the next field and disappear. I need click mouse on the field for getting focus again. Why?
Thank you.Then I don't know. It's certainly a matter of the webbrowser/client environment. All I can suggest is to test in different browsers/environments and to doublecheck all the generated HTML/JS output.
-
Problem to get one row from multiple rows
Hi,
i have master detail form.
for one entry in master, i have multiple in detail table.
and in report i want to join both to get the single row.
is it possible in D2k forms(Oracle)
Eg.
I have table hotel
id name location
101 taj delhi
and another table hoteldetail
id roomtype price
101 single 1000
101 double 2000 etc
now in d2k report i want to show data as
id 101
name taj
location delhi
single 1000
double 2000
please help if there is any way
Thanks
kammy
Edited by: user629129 on Dec 16, 2009 5:03 AM
Edited by: user629129 on Dec 16, 2009 5:05 AMhi
if i got u then
try something like this.
SQL> select emp.empno,emp.ename,dept.deptno,dept.loc from emp,dept where emp.deptno=dept.deptno;
EMPNO ENAME DEPTNO LOC
7369 SMITH 20 DALLAS
7499 ALLEN 30 CHICAGO
7521 WARD 30 CHICAGO
7566 JONES 20 DALLAS
7654 MARTIN 30 CHICAGO
7698 BLAKE 30 CHICAGO
7782 CLARK 10 NEW YORK
7788 SCOTT 20 DALLAS
7839 KING 10 NEW YORK
7844 TURNER 30 CHICAGO
7876 ADAMS 20 DALLAS
EMPNO ENAME DEPTNO LOC
7900 JAMES 30 CHICAGO
7902 FORD 20 DALLAS
7934 MILLER 10 NEW YORK
14 rows selected.sarah -
How do I blend two feeds to get one good sound track
Hi,
Thanx in advance for your help. My good camera was in for repairs so I had to shoot a Johnny Cash / Patsy Cline tribute concert with my smaller camera (no sound meters). I balanced the feeds by jacking ear buds into the camera and balancing there. It sounded great in the camera monitor but not so good in the recorded video. The left channel was live mic and the right channel was a feed from the board. I ended up with a mic feed so strong it got clipped and a board feed much weaker but not clipped. I opened the video in Preimiere CS4 and chose "edit in Soundbooth".
I wasn't able to manipulate the tracks invididually until I converted the stereo channels to seperate audio channels. I manipulated things until I could balance them. The end result was OK but I'm sure it could be better. I would appreciate any pointers or help I can get.
I can upload the tracks if anyone was interested in taking a look.
Thanx,
mYes, you would use a router. You can get them very cheaply, for as little as $10 or $15 dollars, but there are expensive ones with more features like Apple Airport Base Stations. My wireless router was $15 and works great.
-
Hi there, is it possible to replicate the content of one iphone on a UK sim card to anotehr iphone with a Spanish sim card and carry both devices, actice, for my work purposes?
certainly. Synch one of your phones to iTunes. Then restore the other phone from the first phone's backup.
-
When trying to log into SQL*Plus it asks for host string, which I don'
Pls can any one tell me the host string
Regards,
AshokLook the Host String is the Information which tells about the Machine where the dataBase is Located and the SID name and the PORT .
So when we connect to the data base via JDBC the URL which we supply is the Host String .
If the database is not installed in ur machine and u access it remotely then u need a Host String which ur DBA will be able to tell U . -
Has anyone successfully implemented fetching more than one row at a time?
I ask, since I'm having problems even with the simplest of scenarios. I went all the way back to the sample code given in the documentation (listed below) and it doesn't even work! I throws a data truncated exception on the employee number (even though the field is only 4 digits!) Help?
int empno[5];
char ename[5][11];
ub2 enameLen[5];
ResultSet *resultSet = stmt->executeQuery("select empno, ename from emp");
resultSet->setDataBuffer(1, &empno, OCCIINT);
resultSet->setDataBuffer(2, ename, OCCI_SQLT_STR, sizeof(ename[0]), enameLen);
rs->next(5); // throws ORA-01406!pass the size of the number field too.
resultSet->setDataBuffer(1, empno, OCCIINT, sizeof(empno[0]));
... -
Need a report column to hold data for one row only
Hey Guys,
I have a report which has a column that links to another page in my APEX application.
There is a requirement where only one of the rows in this report needs to have a link so I need the column to show the page link for one row and one row only.
The report will have about 5 rows at a time so is there a way to just make this link appear for the one row(it will be the top row) in the column attirbute in APEX? or can this be done in the SQL for the report?
Any help is much appreciated
Thanks
-MarkHi
The only way (I believe) to do this is within the SQL. Then you just wrap the column in a CASE statement and if it meets your criteria then build up the link and if not then display normally.
Something like this...
SELECT ename,
CASE WHEN empno = 7839
THEN '<a href="f?p='||:APP_ID||':4:'||:APP_SESSION||'::NO::P4_TARGET_ITEM:'||empno||'" >'||empno||'</a>'
ELSE TO_CHAR(empno)
END empno
FROM empCheers
Ben
Maybe you are looking for
-
I am printing Black & white prints on my HP7110 wide format printer with HP advanced printer glossy paper and original HP inks. The prints have a definte magenta cast to them. Is there a solution. I have also used hp premium plus paper ( satin) an
-
Payload XML DOM Object Update using Java Embedding
Hi, I have a Java Embedding activity which updates the payload after making a call to a local EJB. The EJB sends back updated information. In my Java Embedding activity i try to update the payload nodes with the new information. It get's really cumbe
-
Centering a Page within the browser
My page is centered with in the brower however depending on how long vertically the page is the center move. So when you change to certian pages some are positioned in one spot the others are positioned slightly to the left and its pretty noticable w
-
What is Unsychronized Backup Recovery in BW System ?
What is Unsychronized Backup Recovery in BW System Iam using 2LIS_06_INV Data Source ...in that I see that this data source's extractor Logic is Unsychronized Backup Recovery in BW System.. Thanks
-
Why does the "Computer Name" sometimes change?
Not a big deal, just curious, why does the "computer name" sometimes change? The name will be the same, but it will add a number....2,3,4...I always change it back so it doesn't have a numeric value next to it, but ju