Blog

How to store and extract XML data in and from an Oracle DataBase (DB)

Here are some snippets of code showing how to accomplish this:

    
CREATE TABLE SampleTable (id number primary key, person XMLType)
This first example creates a table with only two columns: id and person. The first is the PK of the table and the second is of XMLType type. The latter is going to contain our XML data.

Now let’s insert one row in the table.

 
INSERT INTO SampleTable VALUES (1, XMLType('XMLString'))

Where you must replace XMLString with any string representing XML. For example, you can replace it with:

Read more...

Using Javascript to detect the key pressed

Often it is useful to intercept the key pressed within an element of an HTML form, like a textbox and so on. For this purpose you can use Javascript to extract the code of the key that was pressed. Here is a snippet of code you can use–of course adapting it to your needs.

   
function keyPressed(e){
  var code;
  if(window.event){ //IE
   code = e.keyCode;
  }
  else{ //other browsers
    code = e.which;
  }
  //check, for example, if the Enter key was pressed (code 13)
  if(code == 13){
    //Enter key pressed
  }
  else{
    //Another key pressed
  }
}

Note: keyCode is used by Internet Explorer while which is used by the other browsers.

Read more...

The name-separator character in Java

Java was born as a platform-independent programming language. Some features that grant the platform independence are achieved using the APIs of the language itself. For example, to construct a filename path, you can use the public static field separator of the java.io.File class.

Example:

String path = java.io.File.separator + "foldername" + java.io.File.separator + "filename";

This produces the string /foldername/filename under Unix-like systems and \foldername\filename under Windows systems.

Read more...

Hello world!

Welcome to my blog. This is my first post. About myself: My name is Alessandro Lacava and I am a software engineer. I love designing and developing software. So, as you may have guessed, my blog is going to mainly contain articles, techniques, tips & tricks and much more about computer programming. Stay tuned.

Read more...