Re: Date/Time Formatting
Hi Pavel, I don't see a builtin function which does what you want. You might be able to cobble together what you need using the LOCATE and SUBSTR functions, but the statement would probably look ugly. Alternatively, you can register your own user defined formatting function using the CREATE FUNCTION statement: http://db.apache.org/derby/docs/10.8/ref/ref-single.html#crefsqlj95081 Hope this helps, -Rick On 11/8/11 7:32 AM, Pavel Bortnovskiy wrote: Hello: Are there Derby built-in functions which can allow me to extract current date/time as integers as: Time HHmmss: 103152 Date MMdd: 2008 I could get as far as: *cast*(*current_time as **VARCHAR*(8)), *cast*(*current_date as **VARCHAR*(10)), but I was unable to find a function similar to str_replace in Sybase to remove “:” and “-“ Thank you, Pavel. Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the Financial Services Authority.
RE: Date/Time Formatting
Thank you, Rick, for your prompt response. I was able to solve it in the meantime with: year(current_date) * 1 + month(current_date) * 100 + day(current_date) as InsertDate, hour(current_time) * 1 + minute(current_time) * 100 + second(current_time) as InsertTime, But I was certainly hoping for a more elegant solution (wished there was a format date/time function)... -Original Message- From: Rick Hillegas [mailto:rick.hille...@oracle.com] Sent: Tuesday, November 08, 2011 11:20 AM To: Derby Discussion Subject: Re: Date/Time Formatting Hi Pavel, I don't see a builtin function which does what you want. You might be able to cobble together what you need using the LOCATE and SUBSTR functions, but the statement would probably look ugly. Alternatively, you can register your own user defined formatting function using the CREATE FUNCTION statement: http://db.apache.org/derby/docs/10.8/ref/ref-single.html#crefsqlj95081 Hope this helps, -Rick On 11/8/11 7:32 AM, Pavel Bortnovskiy wrote: Hello: Are there Derby built-in functions which can allow me to extract current date/time as integers as: Time HHmmss: 103152 Date MMdd: 2008 I could get as far as: *cast*(*current_time as **VARCHAR*(8)), *cast*(*current_date as **VARCHAR*(10)), but I was unable to find a function similar to str_replace in Sybase to remove “:” and “-“ Thank you, Pavel. Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the Financial Services Authority.
UDT and java arrays
Hi, Derby does support UDTs. One can use any java.io.Serializable java class as a UDT. On the other hand, derby does not support SQL ARRAY types. However, every java array is an object that implements java.io.Serializable, so can one define a UTD of the form CREATE TYPE APP.DARRAY EXTERNAL NAME 'double[]' LANGUAGE JAVA; ? ij does not complain. It also allows to use it in a table definition, e.g. ij CREATE TYPE APP.DARRAY EXTERNAL NAME 'double[]' LANGUAGE JAVA; 0 Zeilen eingefügt/aktualisiert/gelöscht ij create table XXX ( ASDF APP.DARRAY ); 0 Zeilen eingefügt/aktualisiert/gelöscht However, how do I insert values into this table, using normal SQL and using the JDBC API? Or is this all nonsense, although I do not get any error message so far? /Karl
OutOfMemoryException when executing 180,000 batches
Is it unusual that Derby (used in-memory only) seems to throw an out of memory exception when executing 180,000 batched insert statements? (The JVM was started with -Xms1024m -Xmx2048m): Caused by: java.sql.SQLException: Java exception: 'GC overhead limit exceeded: java.lang.OutOfMemoryError'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedResultSet.noStateChangeException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setDate(Unknown Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setDate(Unknown Source) at org.apache.derby.iapi.types.SQLDate.setInto(Unknown Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeBatchElement(Unknown Source) Are there memory limitations for Derby running in the in-memory only mode? Is there anything that can be done to avoid getting such errors? Thanks, Pavel. Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the Financial Services Authority.