Strange behaviour of JDBC query for CHAR column
Hi,
I have a simple table with char type and several records in the table.
create table char_test(str char(50));
insert into char_test values ('abc');
insert into char_test values ('abc ');
insert into char_test values ('abc ');
In JDBC, if I have a query like
PreparedStatement st = conn.prepareStatement("select str from char_test where str = 'abc'");
ResultSet rs = st.executeQuery();
All three rows will be returned.
However, If I use parameter for the PreparedStatment, nothing will be returned if the value of the parameter is passed as "abc".
PreparedStatement st = conn.prepareStatement("select str from char_test where str = ?");
st.setString(1, "abc");
ResultSet rs = st.executeQuery();
Personally, I think this is a bug of Oracle JDBC driver. Could anybody please give me any explanation?
Thanks,
Bill
PS. I'm using Oracle 10g Release 2 DB and ojdbc14.jar under jdk 1.5.
Hello Bill,
Have you solved your problem ?
I have encountered a similar one and found a strange behavior of JDBC driver for PrepareStatement : in some cases, deep in JDBC driver, the parameter values could'nt be convert and are send as null values to the server.
Here are partial driver logs, the first for a program which works fine and the second for one which turns on error.
============================
<record>
<date>2006-09-06T16:27:43</date>
<millis>1157552863218</millis>
<sequence>335</sequence>
<logger>oracle.jdbc.conversion</logger>
<level>FINE</level>
<class>oracle.jdbc.driver.DBConversion</class>
<method>javaCharsToCHARBytes</method>
<thread>10</thread>
<message>DBConversion.javaCharsToCHARBytes(chars[]= (26 bytes):
00 0c 00 65 00 78 00 70 00 73 00 74 00 6f 00 0a 00 73 00 6c
00 65 00 65 00 70 , charOffset=1, bytes[]= (7 bytes):
00 00 00 00 00 00 00 , byteOffset=0, cs=178, nchars=6)</message>
</record>
<record>
<date>2006-09-06T16:27:43</date>
<millis>1157552863218</millis>
<sequence>336</sequence>
<logger>oracle.jdbc.conversion</logger>
<level>FINE</level>
<class>oracle.jdbc.driver.DBConversion</class>
<method>javaCharsToCHARBytes</method>
<thread>10</thread>
<message>DBConversion.javaCharsToCHARBytes(chars, nchars, bytes[], cs): returned 6</message>
</record>
=============================
javaCharsToCHARBytes gets 6 characters OK
=============================
<record>
<date>2006-09-06T16:12:32</date>
<millis>1157551952843</millis>
<sequence>333</sequence>
<logger>oracle.jdbc.conversion</logger>
<level>FINE</level>
<class>oracle.jdbc.driver.DBConversion</class>
<method>javaCharsToCHARBytes</method>
<thread>10</thread>
<message>DBConversion.javaCharsToCHARBytes(chars[]= (40 bytes):
00 26 00 73 00 74 00 6f 00 72 00 61 00 67 00 65 00 5f 00 53
00 74 00 6f 00 72 00 65 00 2e 00 71 00 75 00 65 00 72 00 79 , charOffset=1, bytes[]= (20 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 , byteOffset=0, cs=178, nchars=19)</message>
</record>
<record>
<date>2006-09-06T16:12:32</date>
<millis>1157551952843</millis>
<sequence>334</sequence>
<logger>oracle.jdbc.conversion</logger>
<level>FINE</level>
<class>oracle.jdbc.driver.DBConversion</class>
<method>javaCharsToCHARBytes</method>
<thread>10</thread>
<message>DBConversion.javaCharsToCHARBytes(chars, nchars, bytes[], cs): returned 0</message>
</record>
=============================
javaCharsToCHARBytes gets 0 characters instead of 19
But I am unable to discover the differences between the 2 programs in the JDBC driver usage.
Does this sounds familiar to someone ?
François
Similar Messages
-
Strange behaviour of jdbc-mysql driver
I am trying to store japanese characters in mysql and display also after reading from the database using JSP. I am using the following code.
<%@ page contentType="text/html; charset=UTF-8"%>
....... some code ......
<%
Class.forName( "org.gjt.mm.mysql.Driver" );
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8", "user", "pass" );
Statement st = con.createStatement();
st.executeUpdate( "insert into test values('" + request.getParameter( "imgname" ) + "')" );
ResultSet rs = st.executeQuery( "select * from test" );
while( rs.next() ) {
%> DB Value: <%= rs.getString( "imgname" ) %>
<% } %>
I found one strange behaviour. I have to change the DriverManger.getConnection line to the following, to write the data correctly in the database.
DriverManager.getConnection("jdbc:mysql://localhost:3306/DB","user","pass")
If I read from the database using the same parameters as above, I am getting garbled data.
To retrieve the data correctly from the database I have to use the following line instead of the previous one.
DriverManager.getConnection("jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8", "user", "pass" );
In short, I have to pass different parameters to DriverManager.getConnection() for writing and reading from the database. But it is not possible practically. I am using mm.mysql-2.0.8 jdbc-mysql driver, mysql is 3.23.47 and english windows 2000.
I have tried the string.getBytes("UTF-8") and new String( getBytes(string), "UTF-8") methods, but not getting the correct data.
Can anybody guide me how can I store and display the japanese character correctly?
Thanks to all,
gaurang.I downloaded the latese driver from sourceforge, but still the same thing is happening. Is there any other thing which I should do?
Thanks
gaurang. -
Need help with query for converting columns to rows
Hello,
I know this is a very common question asked in the forum. I have searched regading this, i did find some threads, but i was not able to achieve what i require from the answers posted. So anybody please help me.
I have a table which is having multiple columns as follows:
Insert into table_1 (X,Y,Z,A,B,C,D,E,F,G,H,I) values (0,0,2,0,0,1,3,0,0,0,0,0);I want to convert the result into a two column, multiple rows i.e., I want the result as follows:
Col1 Col2
X 0
Y 0
Z 2
A 0
B 0
C 1
D 3
E 0
F 0
G 0
H 0
I 0Please anybody help me in writing the query for this..Is this what you are expecting:
SQL> WITH T AS
2 (
3 SELECT 0 X, 0 Y, 2 Z, 0 A, 0 B, 1 C, 3 D, 0 E, 0 F, 0 G, 0 H, 0 I FROM DUAL
4 )
5 SELECT 'X' col1, X col2 FROM T
6 UNION ALL
7 SELECT 'Y' col1, Y col2 FROM T
8 UNION ALL
9 SELECT 'Z' col1, Z col2 FROM T
10 UNION ALL
11 SELECT 'A' col1, A col2 FROM T
12 UNION ALL
13 SELECT 'B' col1, B col2 FROM T
14 UNION ALL
15 SELECT 'C' col1, C col2 FROM T
16 UNION ALL
17 SELECT 'D' col1, D col2 FROM T
18 UNION ALL
19 SELECT 'E' col1, E col2 FROM T
20 UNION ALL
21 SELECT 'F' col1, F col2 FROM T
22 UNION ALL
23 SELECT 'G' col1, G col2 FROM T
24 UNION ALL
25 SELECT 'H' col1, H col2 FROM T
26 UNION ALL
27 SELECT 'I' col1, I col2 FROM T
28 /
C COL2
X 0
Y 0
Z 2
A 0
B 0
C 1
D 3
E 0
F 0
G 0
H 0
C COL2
I 0
12 rows selected. -
Query for Identifying column changes
Hi Guys,
Need help in getting a query for my scenario.
I have 2 table Table A and Table B. Both have same columns and data type.
Table A:
Id PersonId Name Code Date
1 1000 John M 2014-07-28
2 1001 Mary B 2014-07-28
3 1002 Robin R 2014-07-28
4 1003 Maxie N 2014-07-28
Table B:
Id PersonId Name Code Date
1 1000 John 2014-07-28
2 1001 Hary S 2014-07-28
3 1002 Justin Q 2012-07-28
4 1003 Maxie P 2013-07-28
My situation is:
I need to compare both the tables and need to identify the rows that has a change in all columns, if all other columns are not changed and Code is changed to blank, i need to ignore that row.
The expected outcome is:
Id PersonId Name Code Date
2 1001 Hary S 2014-07-28
3 1002 Justin Q 2012-07-28
4 1003 Maxie P 2013-07-28
Thanks Guys...I found the solution in a easy way i guess...
select * from
SELECT ID, PERSONID,NAME,
case when code is null then
select a.code from tablea A where A.ID = B.ID
else
a.code
end as Code,
DATE FROM TABLE B
MINUS
SELECT ID,PERSONID,NAME,CODE,DATE FROM TABLE A
What do you guys think...would it work for my scenario....
i am testing few scenarios looks like working....... -
Performance of update query for single column vs multiple column
Hi All,
I could not find any answer for this, does it ever matter in terms of performance updating single column versus multiple column in a single update query.
For eg. table consisting of 15 columns, what would be the difference in performance when one column is update in the single query against another update query where 15 columns are updated.
Please do keep in mind my table columns in actually could be around 150+.
Thanks for any information provided.If updated columns aren´t on where clause , then the only impact of 15 columns will be a increase on redo generation, and a possible chainning row.
So since the redo is one of the things that have a large impact, the answer is yes.
The performance will be slower.
Regards
Helio Dias.
http://heliodias.com
OCE SQL, OCP 9i -
Update query for XMLTYPE column
Hello everyone,
I have inserted xml data into XMLTYPE column of my table,xml data is something like this
<Data type="FYI">
<ID xmlns="http://orcl.com">T-1-1</ID>
<Category>FRAME</Category>
<ProductID>1</ProductID>
<Name xmlns="http://orcl.com">Frame </Name>
<Type>BASIC</Type>
<Code>INSTALL</Code>
<NodeID>1</NodeID>
</Data>
Now i need to update the values inside the <Data> element,like
ID == T-2-2
Category == IFRAME
ProductID == 1.1
Name == IFRAME
We are using oracle 10g R2.
Please help me out how to update. It would be very thankfull for your valuble suggestions
Thanks in advance<Services>
<DataService type="FRLY">
<ID xmlns="http://www.openapplications.org/oagis/9">T-1-1-FRLY</ID>
<CategoryCode>FRAME</CategoryCode>
<ProductOfferingID>1</ProductOfferingID>
<Name xmlns="http://www.openapplications.org/oagis/9">Frame Relay</Name>
<SubType>FRLY - BASIC</SubType>
<ActionCode>INSTALL</ActionCode>
<NodeID>1</NodeID>
<Contract>
<ID xmlns="http://www.openapplications.org/oagis/9" schemeName="Networx Universal">00000</ID>
<Category name="Contract Type">U</Category>
</Contract>
<Contract>
<Type xmlns="http://www.openapplications.org/oagis/9">Routine</Type>
</Contract>
<CustomerParty>
<Location/>
</CustomerParty>
<ProvisioningStatus type="BillingSetup">
<Description xmlns="http://www.openapplications.org/oagis/9">C</Description>
</ProvisioningStatus>
<MileStone>
<ID xmlns="http://www.openapplications.org/oagis/9">CWD</ID>
<Date>2007-01-29</Date>
</MileStone>
<ActivityStatus>
<Code xmlns="http://www.openapplications.org/oagis/9" name="DueDate"/>
<EffectiveDateTime xmlns="http://www.openapplications.org/oagis/9">2007-01-29T00:00:00Z</EffectiveDateTime>
</ActivityStatus>
<AssociatedIDs>
<ID xmlns="http://www.openapplications.org/oagis/9">1</ID>
</AssociatedIDs>
<AssociatedIDs>
<TemporaryID schemeName="OPKEY">34908</TemporaryID>
</AssociatedIDs>
<Location>
<ID xmlns="http://www.openapplications.org/oagis/9">T-510092</ID>
</Location>
<OrderID>RequestID</OrderID>
<Accessory>
<ActionCode>ADD</ActionCode>
<Description xmlns="http://www.openapplications.org/oagis/9">IBM ESERVER-XSERIES306</Description>
<CategoryCode>5</CategoryCode>
<InstallVendorParty>
<Name xmlns="http://www.openapplications.org/oagis/9">MCI</Name>
</InstallVendorParty>
</Accessory>
<Circuit>
<ID xmlns="http://www.openapplications.org/oagis/9">T-1-1-FRLY</ID>
<AssociatedIDs/>
</Circuit>
</DataService>
</Services>
This was my xml which i have inserted into DB for the column XMLTYPE.Now i need to update few values in this whole file like values of
ID under<DataService>
Name under <DataService>
ID under <Contract>
Description under <ProvisioningStatus>
i was using the UPDATEXML query to update those it's saying i row updated but when i extract it says null.
Please help me out to solve this problem.
Thanks in advance. -
NOTIFICATION QUERY FOR UDF COLUMN
Dear experts,
I want notification query for delivery should not be add without fill up the information in machine number column (UDF Column- U_MCnumber)
Please do needful.
Thanks & Regards,
AkshataDear all,
I have got query ...........
If @object_type = '15'and @transaction_type= ('A')
BEGIN
If Exists (Select T0.DocEntry from ODLN T0 Inner Join DLN1 T1
On T0.DocEntry=T1.DocEntry INNER JOIN OITM T3 ON T3.ItemCode = T1.ItemCode
Where (T1.U_MCnumber Is Null and T3.ITMsgrpcod='119')
And T0.DocEntry = @list_of_cols_val_tab_del )
BEGIN
Select @error = -1,
@error_message = 'Please fill up machine number!!!'
End
End
Thanks & Regards,
Akshata -
Strange behaviour of hierarchical query
Hi,
there is two tables T(P,PK,...) (with hierarchy) and S(ID,IDS,....) with additional data.
I take query:
select S.IDS from T, S
where T.PK=S.ID
start with P=start number
connect by prior PK=P
Query work fine and return rows ...
but when I add another where condition
select S.IDS from T, S
where T.PK=S.ID and S.IDS=searched number
start with P=start number
connect by prior PK=P
query do not return rows even when searched number is in set returned by first query without additional condition.
It seems to me strange ... thanks for ideaHi,
The subquery match's the outer query rows.
In this event the IN condition returns FALSE. Hence the query runs with out any error.
As IN is concern the condition will look for True Or False Only.Error will happen only if any syntax issue else the query will still run.
you can mention any coulmn name of outer query in subquery eventhough they dont exisit , the inner query can reference the outer query's column names.
I hope you are clear on this...........
Raj.
Edited by: infant_raj on May 4, 2009 7:44 AM -
Strange results from JDBC Query using a VARRAY
Here's one for you experts:
I have a 9i release 2 db set up, to which I connect via the JDBC thin
driver. I have a JavaServer Pages application that needs to read a VARRAY
from a table and then use the contents of the VARRAY. Here's the code in
the JSP that does that:
resultset=db.executeQuery
("SELECT IMAGE_lIST FROM PAGE_IMAGE_ARRAY WHERE PAGENAME = " +
pagename);
oracle.sql.ARRAY array =
((oracle.jdbc.driver.OracleResultSet)resultset).getARRAY(1);
imageList = (String[])array.getArray();
for(int count=0; count<imageList.length; count++)
out.println("<p>The image at position " + count + " in the array is
the image titled: " + imageList[count]);
The JSP compiles and runs fine, but the output is as follows:
The image at position 0 in the array is the image titled: 0x7465737431
The image at position 1 in the array is the image titled: 0x7465737432
The image at position 2 in the array is the image titled: 0x7465737433
The image at position 3 in the array is the image titled: 0x7465737436
A query using SQL*Plus verifies that the actual values of the elements of
the array are 'test1', 'test2', 'test3', 'test6'. Notice that the last
digit in the hex(?) output matches the last digit of the actual string.
What's causing this? It looks like a data type mismatch, but I would have
thought that such an error would have triggered a compile-time error.
Any help is greatly appreciated.
Regards,
Dave PennDave,
The following should help.
1 select rawtohex('test1') val1,
2 rawtohex('test2') val2
3* from dual
SQL> /
VAL1 VAL2
7465737431 7465737432
SQL> select rawtohex('1') val1,
2 rawtohex('2') val2
3 from dual;
VA VA
31 32 -
Strange behaviour of name used for desktop icon when mounting SMB shares
My iMac is joined to a Windows Active Directory domain. This works fine. User logins are setup to mount various Windows shares at login time using some custom scripts that I have written, invoked from an Applescript app that runs as a login item. Again this works very nicely. The one strange thing is as follows, and this is troublesome for me...
The sequence of commands used to perform the mount is:
mkdir /Volumes/mountpoint
mount -t smbfs //servername/sharename /Volumes/mountpoint
This correctly mounts the share on /Volumes/mountpoint
but the desktop icon that appears as a result is called 'sharename' not 'mountpoint'. Why is this a problem? Well consider that one has the following shares that one wants to mount:
//Server1/System (will be mounted on /Volumes/Server1System)
//Server2/System (will be mounted on //Volumes/Server2System)
what I'd like to see are two desktop icons with names 'Server1System' and 'Server2System' but in fact I end up with two icons both called 'System' with no way to tell which is which other than actually opening one of them in Finder.
Anyone know
(a) Is this behaviour expected (i.e. by design)?
(b) Is there a way to control the name used for the desktop icon when mounting things this way?
Thanks!But, to invoke your app you will need to include it, otherwise you get the error above
sometimes you call
http://host:port/blank/page.jsp
instead of
http://host:port/blank/faces/page.jsp
In the last one the Faces Servlet will get your request and locate page.jsp inside the faces context. If you don't include it then you get that error -
Select query for char data type
Hi Gurus,
I am trying to fetch records from Z table.
Below the select query.
lv_low = '0900001'
lv_high = '0900002'
select matnr sernr into table lt_sernr
from zsd_upd_deldoc
where sernr >= lv_low and sernr <= lv_high.
but out put shows
9000010
9000011
900002
900001
9000010
9000019
9000019
9000018
9000017
9000014
9000018
9000017
Expecting O/P
900001
900002
Regards
Vinayak Sapkaltables: zsd_upd_deldoc.
data: begin of lt_table occurs 0,
sign(1),
option(2),
low(18),
high(18),
end of lt_table.
DATA: ls_doc_id_range LIKE LINE OF lt_table.
FIELD-SYMBOLS: <fs> LIKE LINE OF lt_table.
ls_doc_id_range-sign = 'I'.
ls_doc_id_range-option = 'BT'.
ls_doc_id_range-low = lv_low.
ls_doc_id_range-high = lv_high.
INSERT ls_doc_id_range INTO TABLE lt_table.
select matnr sernr into table lt_sernr
from zsd_upd_deldoc
where sernr >= lv_low and sernr <= lv_high.
select matnr sernr into table lt_sernr
from zsd_upd_deldoc
where sernr in lt_table.
loop at lt_sernr assigning <fs_sernr>.
write: / <fs_sernr>-sernr.
endloop.
O/P
9000010
9000011
900002
900001
9000010
9000019
9000019
9000018
9000017
9000014
9000018
9000017
Regards
Vinayak Sapkal -
Query for displaying columns in reverse order ?
Hi All,
I want to select/display all the columns of a table in reverse order. The no. of columns is arbitrary.
Can anyone please help me on this.\
Regards
-AKJapart from the physical data store implementation,
are columns actually guaranteed ordering ? Guaranteed.... probably not, but they are in the data dictionary in the order in which they are created, so are known to be consistent in that respect.
I don't think it's correct to refer to C(1)...C(n) ,
they are just columns, there's no particular reason
why one should come first or lastLikewise, I don't see the point in selecting columns out in a particular order unless you're trying to spool the output to a file. -
Strange behavior of JDBC Adapter
Hello everybody!
I found a pretty strange behaviour of JDBC Receiver Adapter during problems with network (big thanks to our Basis). According to the status in Adapter Engine, the message wasn't processed. In the database I can see these inserts. However, there are more lines in the XML than lines in the database. So, how it is possible that adapter commits only part of inserts. Logs and settings see below.
My XML includes a SQL_DML statement and a few INSERT statements, each contains many inserts.
It looks like that:
<?xml version="1.0" ?>
<MyMessage>
<statement>
<table1 action="SQL_DML">
<access>here I delete old values</access>
</table1>
</statement>
<statement>
<table2 action="INSERT">
<access>some data</access>
</table2>
</statement>
<statement>
<table3 action="INSERT">
<access>some data</access>
</table3>
</statement>
</MyMessage>
Part of adapter log is here:
Information
Message successfully put into the queue
Information
The message was successfully retrieved from the receive queue
Information
Message status set to DLNG
Information
Delivering to channel: Adapter_Name
Information
MP: processing local module localejbs/CallSapAdapter
Information
Receiver JDBC adapter: processing started; QoS required: ExactlyOnce
Information
JDBC Adapter Receiver Channel Adapter_Name: Processing started; party / service BS
Information
Database request processed successfully
Error
MP: exception caught with message Ack handling failed: creation of messageFactory failed: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Connection JDBC_http://sap.com/xi/XI/System is currently not started.
Error
Exception caught by adapter framework: Ack handling failed: creation of messageFactory failed: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Connection JDBC_http://sap.com/xi/XI/System is currently not started.
Error
Delivery of the message to the application using connection JDBC_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.Exception: Ack handling failed: creation of messageFactory failed: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Connection JDBC_http://sap.com/xi/XI/System is currently not started.
Information
Message status set to WAIT
Information
The asynchronous message was successfully scheduled to be delivered at ...
Information
Message status set to TBDL
Information
Retrying to deliver message to the application. Retry: 1
Information
The message was successfully retrieved from the receive queue
Information
Message status set to DLNG
Information
Delivering to channel: Adapter_Name
Information
MP: processing local module localejbs/CallSapAdapter
Information
Receiver JDBC adapter: processing started; QoS required: ExactlyOnce
Information
JDBC Adapter Receiver Channel Adapter_Name: Processing started; party / service BS
Error
Unable to execute statement for table or stored procedure. 'Table' (Structure 'statement') due to com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'fields'. Cannot insert duplicate key in object 'Table'. The duplicate key value is (field values).
Error
JDBC message processing failed; reason Error processing request in sax parser: Error when executing statement for table/stored proc. 'Table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'fields'. Cannot insert duplicate key in object 'Table'. The duplicate key value is (field values).
Error
MP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'Table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'fields'. Cannot insert duplicate key in object 'Table'. The duplicate key value is (field values).
Error
Exception caught by adapter framework: Error processing request in sax parser: Error when executing statement for table/stored proc. 'Table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'fields'. Cannot insert duplicate key in object 'Table'. The duplicate key value is (field values).
Error
Delivery of the message to the application using connection JDBC_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'Table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'fields'. Cannot insert duplicate key in object 'Table'. The duplicate key value is (field values).
Adapter settings:
Maximum concurrency: 20
Persistence: Local
Conflict Resolution: Redo
Advanced Mode: On
Number of Retries of Database Transaction on SQL Error: 0
Transaction Isolation Level: serializableDear All,
Follow the steps below to resolve the "Connection JDBC_http://sap.com/xi/XI/System is currently not started." issue:
1. Log in to NWA
2. Navigate to Operations -> Systems -> Start & Stop
3. Click on Java Services tab
4. Search the service Service "XPI Adapter: JDBC"
5. Select the service XPI Adapter: JDBC and click on Restart button
With the restart of JDBC Service in NWA, the channels should start working properly
Regards,
Shreyansh -
Strange behavior in inner query with group by clause
Hi All,
I found a very strange behaviour with Inner query having a group by clause.
Please look the sample code
Select b,c,qty from (select a,b,c,sum(d) qty from tab_xyz group by b,c);
This query gives output by summing b,c wise. But when i run the inner query it gives error as "not a group by expression "
My question is - though the inner query is wrong, how is it possible that this query gives output.
it behaves like -
Select b,c,qty from (select b,c,sum(d) qty from tab_xyz group by b,c);
Is it a normal behaviour ?
If it is a normal behaviour, then how group by behaves inside a inner query.
Thanks !!This case I have tested already and it throws error.
But why the initial posted query is not throwing
error even the inner query is wrong.
In what way oracle behaves for the initial posted
query?what is the scenario that throws the error? is it at the time when you only run the inner query or the whole query? -
TopLink JPA - trailing spaces on Char column
Gurus,
In JDBC you use the following to ignore trailing spaces when querying on Char column:
OracleConnection conn = (OracleConnection) c;
conn.setDefaultFixedString(true);
How to achieve this using TopLink JPA?
Thanks much,
NickyNicky,
I believe you would need to do this in API. Ideally setting these configurations on the properties of the JDBC connection pool is easier but if you wish to do it with TopLink Essentials I would use a session event listener's postAcquireConnection to customize it.
In the persistence.xml you will need to configure your persistence unit to use a session customer like:
<property name="toplink.session.customizer" value = "mypackage.JDBCConnectionConfig"/>Then you will need to implement this customizer and include it on the classpath of your application:
public class JDBCConnectionConfig implements SessionCustomizer {
public void customize(Session session) {
session.getEventManager().addListener(new JDBCConfigEventListener());
class JDBCConfigEventListener extends SessionEventAdapter {
public void postAcquireConnection(SessionEvent event) {
Connection conn = ((DatabaseAccessor) event.getResult()).getConnection();
OracleConnection oconn = (OracleConnection) conn;
oconn.setDefaultFixedString(true);
Note: I did not see setDefaultFixedString in the most recent version of the Oracle JDBC driver
I would definitely look into configuring your data source's connection pool with this property enabled before adding this event listener.
Doug
Maybe you are looking for
-
How to get Grand Total Text in ALV GRID
Hi Folks, I am able to get the SUBTOTAL TEXT .....But i need... How to get Grand Total Text in ALV GRID Display... Can any one give a Solution for this...
-
I cannot use a website I need to use, with Firefox 5.0. So, I need to uninstall and go back to 3.5 or 3.6. Please advise. Also, my control panel locks up since Windows Explorer has pbms. Which is why I am using Firefox instead. Thanks for any help!
-
NForce3 Chipset + Maxtor Problem
Hey Guys wonder if you'll could please help me with this weird problem i have: Recently i purchased a Maxtor 250GB IDE Drive.Its connected on IDE1 as MASTER On IDE2 i have a samsung dvd-writer on master.The problem is once i install the nVidia ide dr
-
Keynote 6.0 shows will not play videos, only sound from clips
I have upgrader to Mavericks and KN 6.0 Now when I try to play previous KN presnetations containing video clips, some play fine, others just play with sound + no video, and other play sound + video, but with loud "ehcoes" making them unusable. What d
-
Writing a function to find whether a value is present in a sql query output
Hi gurus, I would like to write a function to which i will pass a value and a sql query as parameters. Now the function needs to execute that sql query and find whether the given value is present in the output list when the query is executed. If it i