Re: EOF and optimizing Oracle sequence generation

2015-08-04 Thread Petite Abeille

> On Aug 4, 2015, at 9:47 PM, Ruggentaler, JR  
> wrote:
> 
> ALTER SEQUENCE TABLE_NAME_SEQ INCREMENT BY 10;

Not directly related to EOF per se, but, in Oracle,  ALTER … CACHE … is used to 
control preallocation:

http://docs.oracle.com/database/121/SQLRF/statements_6017.htm

Also, in 12c, you can use identity columns to hide all that sequence business:

https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Catching ERXAttachmentExceedsLengthException

2015-08-04 Thread CHRISTOPH WICK | i4innovation GmbH, Bonn
Hi Miguel,

AFAIK (and I even wrote a mail to Mike Shrag, who wrote this code) there is no 
real good way to catch an ERXAttachmentExceedsLengthException.

What I did was:

1. in your application class, override the "handleException" method and check 
if anException isinstanceof ERXAttachmentExceedsLengthException or any other 
kind of exception.

If the anException is a ERXAttachmentExceedsLengthException, try to go back to 
the page where you were coming from. In my example I stored the last page with 
the ERAttachmentUpload in my session, so I can restore it (and set an error 
message for the user):

public WOResponse handleException(Exception anException, WOContext context) {

if (anException instanceof ERXAttachmentExceedsLengthException) {
ERXComponent nextPage = ((Session) 
context.session()).lastPageBeforeAttachmentExceedsLengthException();

if (nextPage instanceof Main) {
((Main) 
nextPage).setErrorMessageFromException("ERROR: This attachment is too 
big. ...");
}
return nextPage.generateResponse();
} else {
OtherExceptionResponsePage nextPage = 
(OtherExceptionResponsePage)

pageWithName(de.i4innovation.app.components.OtherExceptionResponsePage.class);
nextPage.setTheException(anException);
return nextPage.generateResponse();
}
}


2. There is a Javascript/jQuery solution to check the file-name and file-size 
BEFORE you actually upload the file to your server.

It assumes your wo:ERAttachmentUpload has the id 'uploadButton'. The save 
button has the id 'saveButton' and an initially not displayed div has the id 
'uploadMessage'.

With jn("#uploadButton").change(function(evt) ... you bind a function to the 
Upload button that is fired during the onChange event -> that means before the 
file is actually uploaded.


It works like this:










/* extend js' string with an endsWith function */
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

/* define the max file size */
var maxFileSize = 20971520;

/* run jQuery in noConflict mode */
var jn = jQuery.noConflict();

/* attach this function to the file-upload-button's onChange event */
jn("#uploadButton").change(function(evt) {
if (window.File && window.FileReader && window.FileList && 
window.Blob) {
// Great success! All the File APIs are supported.
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some 
properties.
for (var i = 0, f; f = files[i]; i++) {
var msgDiv = 
document.getElementById('uploadMessage');
var msgButton = 
document.getElementById('saveButton');
if (f.size > maxFileSize) {
var fSize = f.size/100;
var msg = "ERROR: This attachment is 
too big.
Maximum file size is: 10MByte, actual file size: "+fSize.toFixed(2)+" MByte.
Please upload a smaller file!"; msgDiv.style.display = "block"; msgDiv.innerHTML = msg; msgButton.style.display="none"; } else { if (!endsWith(f.name.toLowerCase(), "zip")) { var msg = "ERROR: This file is not a zip file.
Please choose a zip file."; msgDiv.style.display = "block"; msgDiv.innerHTML = msg; msgButton.style.display="none"; } else { msgDiv.style.display = "none"; msgButton.className= "btn btn-success"; msgButton.style.display = "block"; } } } // end for-loop } else { alert('CAVE: This browser doesn\'t support attachment size validation!'); document.getElementById('saveButton').style.display="block"; } }); If you like I would send you the demo project I've developed. It's only 27kb, but I'm not sure to post it on the list here. C.U.CW -- The three great virtues of a programmer are Laziness, Impatience and Hubris. (Randa

EOF and optimizing Oracle sequence generation

2015-08-04 Thread Ruggentaler, JR
I am trying to lower the number of Oracle DB roundtrips to get primary 
keys/sequences.

I have tried setting the following Wonder properties
-er.extensions.ERXJDBCAdaptor.className er.extensions.jdbc.ERXJDBCAdaptor
-er.extensions.ERXPrimaryKeyBatchSize 1

and changing one of my entities user info dictionary to:

userInfo = {
"_EntityModeler" = {generateSource = NO; };
modificationDate = "2000-04-20 12:37:17 -0700";
ERXPrimaryKeyBatchSize = 10;
};

Now Wonder select 10 primary keys and caches them. The only issue is JDBC does 
not allow batching of select so this only changes the sequence of how the 
primary keys are fetched. This causes a database roundtrip for each primary key 
needed.

I am wondering if anyone has subclassed ERXJDBCAdaptor or JDBCAdaptor and 
created an adaptor the uses the Oracle sequence increment to reduce database 
roundtrips to acquire a “batch” of sequences.

— Oracle query sequence increment value to determine the sequence "batch size".
SELECT INCREMENT_BY FROM ALL_SEQUENCES WHERE SEQUENCE_NAME=’TABLE_NAME_SEQ';

— Oracle change sequence increment to 10 ("batch size" to 10)
ALTER SEQUENCE TABLE_NAME_SEQ INCREMENT BY 10;

JR
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com