... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2006-06-26

Mysterious Stale Data in JIRA

Okay, it happened again.  This time, a JIRA item (RAPT-558) did not show in the All filter for the RAPT project -- or any other filter for that matters.  You could load the item directly, it just didn't appear in any lists.  Rebuilding the indexes corrected the problem.

Oracle, SQL*Plus, PL/SQL

SQL*Plus will behave as you expect when executing this sequence:

variable result number;
update zot set x=x+1 returning x into :result;
print result;

but not this sequence:

variable result number;
select count(*) into :result from user_catalog;
print result;

In the latter case, the SELECT statement is accepted and executed, but the INTO clause is not respected.  On the other hand, you can make it work by using a PL/SQL block:

variable result number;
begin
  select count(*) into :result from user_catalog;
end;
/
print result;

While we're on the topic of SQL*Plus, here are some useful snippets that I haven't captured before...

set echo on
whenever sqlerror exit failure

define supplied_user = &&1
define supplied_tablespace = &&2

prompt Creating tables for &&supplied_user in &&supplied_tablespace

declare
  table_count number;
begin
  select count(*) into table_count from user_catalog where table_name='ZOT';
  if 0 = table_count then
    execute immediate
      'create table &&supplied_user..zot (x integer) '
      || ' tablespace &&supplied_tablespace'
      ;
  end if;
end;
/

Note the two dots in "create table &&supplied_user..zot".  The second dot is needed because SQL*Plus will gobble the first dot it sees after any use of the "&" operator (unless you change that behaviour using SET CONCAT).

Blog Archive