Firebird/InterBase Quiz

This is just for fun - no prizes are offered (except of publishing your name in big font if you send me correct answers :-)
I received lot of answers, but none correct so far :-(

How to change character set

How would you change character set of table's column (already populated with data containig national characters), without copying data to different column/table/database/file ? (i.e. do it "in place")

Details:
Sometimes people create new database with character set NONE, populate it with data, and then decide to change character set of some columns to something more suitable, like ISO8859_1. The problems are


How does WAIT transaction work ?

When update conflict occur in WAIT transaction, it goes into wait state. What is it that this transaction waits for ? Does it wait for offending record (to be "unlocked"), or for the other transaction (to be committed/rollbacked) ? Is there any difference at all ?


ASCII NUL characters

Suppose we have database with no tables, external tables, UDFs, ... There is only one procedure with one VARCHAR output parameter:
CREATE PROCEDURE proc
  RETURNS (str VARCHAR(10)) AS
BEGIN
  ...
END 
When you execute this procedure, it will return string consisting of 5 ASCII NUL characters (binary zeroes).
What is in the body of SP ?

SOLUTION


OR vs IN

Suppose you can choose between these two select statements (they will give you the same result sets):

(A)

SELECT *
  FROM tab
 WHERE x='YES' OR x='NO' OR x='PERHAPS' OR x='MAYBE'; 
(B)
SELECT *
  FROM tab
 WHERE x IN ('YES','NO','PERHAPS','MAYBE'); 
What would you do if you are concerned about speed ?
  1. Choose (A) because it is always faster than (B)
  2. Choose (A) because it is equally fast or faster than (B)
  3. Choose (B) because it is equally fast or faster than (A)
  4. Choose (B) because it is always faster than (A)
  5. Test both because IB's optimizer is unpredictable
  6. Pick arbitrary one because they are equivalent
  7. Something else ...
(Some kind of evidence is better than just guessing)

SOLUTION


Ivan Prenosil (2002)