Wednesday, April 18, 2007

Denise Melani Niple Slip

One comment I do not hate very effective

Today I was trying a script made by a colleague and I bumped against another not-too-natural behavior of Oracle (sqlplus, in particular).

But as usual as we put the quiz:

Following this sequence of commands (where 'table1', "table2" "Table 3" and the user "user" there) what is the output to sqlplus [of course, with "feedback on"]?
 
/ * do the permissions * / grant select on table1 to
user;
user to grant select on table2;
/ * added * Table 3 /
user to grant select on Table 3;

[1] 2 Posts of "granting failed"
[2] 3 messages "concession failed"
[3] 4 messages concession failed "


The answer in the first comment ..

Friday, April 13, 2007

Geoff Jansz Baked Cherry Cheesecake

Oracle ..

Of course it is sometimes difficult ...

select LPAD (ltrim ('\u0026lt;string>', '0 '), 4, '0') from dual

What does this SQL query?
Well .. takes the string that I put in the place of \u0026lt;string>, removes all the zeros that are left and then makes it again to the left padding with zeros, until a string of 4 characters.

For example: if
STRING is 0000000000123, the result is 0123
if STRING is 023, the result is 0023
if STRING is 0000000, the result is 0000

ERROR! Since the second
Oracle, there is no 'difference between an empty string ('') and a \u0026lt;null> the query result is null ...

grrrrr ...
the correct version then:
select LPAD (LTRIM (NVL ('\u0026lt;string>', '0 '), '0'), 4, '0 ') from dual