Oracle: quotes and quote operator

There are several methods to put the quote into the string.

The first (and very traditional) one: use 2 quotes.
[cc lang=”oracle8″]
select ‘This ” is quote’ from dual;
[/cc]
If there are more than one quote, it’s difficult to read and write such strings

The second: use chr(39)
[cc lang=”oracle8″]
select ‘This ‘ || chr(39) || ‘ is quote’ from dual;
[/cc]

The third: put the quote into the variable
[cc lang=”oracle8″]
declare
s_quote varchar2(1) := ”” ;
begin
dbms_output.put_line(‘This ‘ || s_quote || ‘ is quote’ ) ;
end;
[/cc]

And, finally, Oracle 10g has added new feature: quote operator.
[cc lang=”oracle8″]
select q'[This ‘ is quote]’ from dual ;
[/cc]

The general form is q’X string X’. Here X is just some character. If the brackets are used, Oracle expects the closing bracket for the end of the string.

Here are the additional examples:
[cc lang=”oracle8″]
select q'(This ‘ is quote)’ from dual ;
select q’|This ‘ is quote|’ from dual ;
select q’#This ‘ is quote#’ from dual ;
select q’#This ‘ is quote#’ from dual ;
select q’?This ‘ is quote?’ from dual ;
select q’TThis ‘ is quoteT’ from dual ;
[/cc]

Oracle: problem relinking binaries on Solaris

I’ve got the following message relinking the binaries on Solaris:

ld: fatal: dlopen() of support library (libmakestate.so.1) failed with error:

ld.so.1: /usr/ccs/bin/sparcv9/ld: fatal: /usr/lib/libmakestate.so.1: wrong ELF class: ELFCLASS32

The problem was caused by missing 64-bit library libmakestate.so.1 in /usr/lib.

The normal library should look like the following:

[#] file /usr/lib/sparcv9/libmakestate.so.1
libmakestate.so.1: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped


If the library does not exist or is incorrect, it should be reinstalled from the package SUNWsprox ( Sun WorkShop Bundled 64-bit make library)

This command checks, if the package is installed in the system:
[#]  pkginfo -i SUNWsprox

After installing the package relink works fine.

NetBeans: use a radio button group

It’s possible to unite several radio buttons into the group. For example, if the buttons “On” and “Off” are in the same button group, only one of them will be active (which is logical).

To create the radio button group in NetBeans do the following:

    1. Use “Button group” from the components palette and put it into Your form. It will be added as “non-visual”

Button group component

    1. Add the radio buttons to the group, changing their ButtonGroup property (combobox in the Properties)

RadioButton properties

To remove the radio button group, go to the inspector window and remove radio button group there.

  • Remove radio button group

PDF file: set the bookmark

Strange enough, Adobe Acrobar Reader does not allow to put the user-defined bookmarks into the PDF file (and this is so simple and necessary thing!)

However, with the help of some “hack” the bookmarks still could be used.

Here is the trick:

  1. Go to PDF Hacks site and download the zip file with the javascript.
  2. Extract the file bookmark_page.js from the archive
  3. Copy the file bookmark_page.js to one of the following folders:
    • %ProgramFiles%\Adobe\Reader\Javascripts
    • %AppData%\Adobe\Reader\Javascripts

    Please, check the real installation path of the Acrobat software, it could be different on Your system.

  4. Restart the Acrobat Reader

Now You have 4 new menu items in the menu “View”. The first two could be called using shortcut “Alt-V-5” and “Alt-V-6” (for English version of Acrobat)
Bookmarks in PDF

The bookmarks are not saved in the PDF itself, so they could be lost, if the PDF file is moved to some other location.

To uninstall the bookmark script, just remove bookmark_page.js from the Javascripts folder and restart the Acrobat Reader.

Some other PDF tricks could be found in this book:
[amazon-product]0596006551[/amazon-product]

Install javadoc for NetBeans

Java documentation is not included neither in NetBeans installation, nor in “standard” Java SDK installation.

However, it’s possible to download it manually and add to the NetBeans IDE.

  1. Get the Java Documentation (currently “Java SE 6 Documentation”) from Sun site.
  2. Start NetBeans
  3. Select menu item “Tools->Java platforms”, then click “Javadoc” tab
  4. Click “Add Zip/Folder” button and select the path to the downloaded Zip-file

NetBeans Javadoc window

Java: minimize Application window

The following method could be used to minimize application window, if java.awt.Frame or its subclass is used:

public void setState(int state)
Parameters:
state – Frame.ICONIFIED if this frame is in iconic state;
Frame.NORMAL if this frame is in normal state.

Example:

// Close window on ESC
// use it in the constructor of the window, extending JFrame
//
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
rootPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setState(Frame.ICONIFIED);
}
} , stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);