lunes, 7 de abril de 2008

Simple solution for the ORA-01157 and ORA-01110 Errors

Did you erase a datafile?, do you still need that datafile?, if the answer for the last question was yes, this is not the solution for you!, otherwise, continue...

SQL>startup mount;
SQL>alter database datafile '/AS10g/oradata/asdb/users02.dbf' offline drop;
SQL>alter database open;

SQL>shutdown immediate;
SQL>startup;


and then, you will see something like this:

Total System Global Area 1048576000 bytes
Fixed Size                   782524 bytes
Variable Size             892342084 bytes
Database Buffers          155189248 bytes
Redo Buffers                 262144 bytes



It is done!


In my case, I did not need that datafile anymore, so my problem was solved just following the above solution.

Regards,
Héctor Suárez Barenca

miércoles, 5 de marzo de 2008

Maximum subarray (java implementation)

You're given an array containing both positive and negative integers and required to find the subarray with the maximum sum.

This is an interesting problem, I read that the solution was given in 1977 in less than a minute, so I took the original algorithm for the article and I implemented with Java, enjoy it!

    public static void main(String[] args)
    {
        int[] offset = new int[2];
        int[] x = { 31, -41, 59, 26, -53, 58, 97, -93, -23, 18 };
        int n = x.length;
        int maxsofar = 0;
        for (int i = 0; i < n; i++)
            for (int j = i; j < n; j++)
            {
                int sum = 0;
                for (int k = i; k <= j; k++)
                    sum += x[k];
                /* sum is sum of x[i..j] */
                if (sum > maxsofar)
                {
                    offset[0] = i;
                    offset[1] = j;
                    maxsofar = sum;
                }
            }
        System.out.println("Subarray [" + offset[0] + "..." + offset[1]
                + "] = " + maxsofar);
    }