Sunday, 26 December 2010

Make XP auto login

Click Start > Run and type

CONTROL USERPASSWORDS2

Select the user account from the list (the account to which you want to automatically logon). Uncheck Users must enter a user name and password to use this computer option, and click Ok. Type the user account password and complete the process.

For Windows XP Home, don't try to auto-login as the built-in Administrator, as you'll receive an error message.

Thanks to site: http://windowsxp.mvps.org/Autologon.htm

Friday, 17 December 2010

Tracing ORA-01427

To Trace Oracle error ORA-01427


SQL> alter system set events '1427 trace name ERRORSTACK level 10';


After the error occurs, see the trace generated in the udump directory.

To disable tracing:

SQL> alter system set events '1427 trace name ERRORSTACK off';


Testing on 15 Dec 2010, now sql that caused the error, is listed on trace file.

Stats Pack or AWR

Since none of my databases are Enterprice Licenced, I dont get to use AWR year on year.
So hence alwasy foget the AWR command, still surviving with the stats pack command.

Here's one that I need remember:


@?/rdbms/admin/awrrpt.sql

Thursday, 16 December 2010

Munin 10+ cpu patch

for 10 or cpu box:


please login to lnx-db28.nid as root.

vi /usr/share/munin/plugins/cpu

search for NCPU

remove a space e.g.

From

NCPU=`expr \`grep '^cpu. ' /proc/stat | wc -l\` - 1`


To (Only removing the space after cpu.)

NCPU=`expr \`grep '^cpu.' /proc/stat | wc -l\` - 1`


Restart munin node on that box

/etc/init.d/munin-node restart

How to find the tables that have stale statistics?

How to find the tables that have stale statistics?

SET SERVEROUTPUT ON

DECLARE
ObjList dbms_stats.ObjectTab;
BEGIN

dbms_stats.gather_database_stats(objlist=>ObjList, options=>'LIST STALE');

FOR i in ObjList.FIRST..ObjList.LAST
LOOP
dbms_output.put_line(ObjList(i).ownname || '.' || ObjList(i).ObjName || ' ' || ObjList(i).ObjType || ' ' || ObjList(i).partname);
END LOOP;
END;
/


ref: http://oraclespin.wordpress.com/2009/04/19/how-to-find-the-tables-that-have-stale-statistics/



DBMS_STATS.GATHER_SCHEMA_STATS(ownname=>'AR_SILVER1_AUTOSLIM', objlist=>ObjList, options=>'LIST STALE');

Saturday, 16 October 2010

OpenBravo

Found below link very useful:

http://forge.openbravo.com/plugins/espforum/view.php?group_id=101&forumid=434922&topicid=7015387

Keeing a copy here, in case the orginal is moved or broken.


==============
Discount Fixed
==============

Step 1: Create a new button for the main screen.

Login as Admin and goto maintainence --> resources and add the following line to "Ticket.Buttons"

< button key="button.discount" name="button.discount" code="Code.Discount" />


Step 2: Create a new resource called "Code.Discount" and add the follwing code to it.

import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo;

discountamount = sales.getInputValue();

index = sales.getSelectedIndex();
if (index >= 0) {
line = ticket.getLine(index);
if (line.getPrice() > 0.0 && discountamount > 0.0) {

sdiscount = Formats.CURRENCY.formatValue(discountamount);

ticket.insertLine(index + 1,
new TicketLineInfo(
"Discount " + sdiscount,
line.getProductTaxCategoryID(),
line.getMultiply(),
-discountamount,
line.getTaxInfo()));
sales.setSelectedIndex(index + 1);
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}


Step 3: Add permission to who all can use this function.

Either Administrator, Manager or Employees etc...

The following line will be added to maintainence ==> roles.


< class name="button.discount" />


Restart your POS and goto sales screen to check out your new button........ Viola


I would add one more step:

add following line in the pos_messages.properties located in Locales folder so a proper label on the button is placed.


button.discount=Discount



==================
Discount Percentag
==================

Here is the code for a user entered discount percentage rate.

Pros: You can enter discount amount. i.e. 10% of total ticket entered as 10

20% of total ticket entered as 20 and so on

Cons: You can not remove the discount once entered. ( can anyone point me how to add this exception as it gives out a strange error )



Input this code in a new resource called "discount.Total"



// % Discount for the total of the receipt

import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo;
import java.util.Properties;

discountperc = JOptionPane.showInputDialog(null, "Input percentage.....");
double discountrate = Double.parseDouble(discountperc);
discountrate = discountrate/100.00;

total = ticket.getTotal();
if (total > 0.0) {
sdiscount = Formats.PERCENT.formatValue(discountrate);

taxes = ticket.getTaxLines();
for (int i = 0; i < taxes.length; i++) {
taxline = taxes[i];
ticket.insertLine(ticket.getLinesCount(),
new TicketLineInfo(
"Discount " + sdiscount + " of " + taxline.printSubTotal(),
taxline.getTaxInfo().getTaxCategoryID(),
1.0,
-taxline.getSubTotal() * discountrate,
taxline.getTaxInfo()));
}
sales.setSelectedIndex(ticket.getLinesCount() - 1);
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}


now create a new button in "Ticket.Buttons"


< button key="button.discount" name="button.discount" code="discount.Total" />


and also add the permission in maintenance -> roles


< class name="button.discount" />

Wednesday, 6 October 2010

Temp tablespace


CREATE TEMPORARY TABLESPACE temp_n TEMPFILE '/u01/oracle/oradata/NIDEV/temp_01.dbf' SIZE 500M
autoextend off extent management local UNIFORM SIZE 1M;

alter database default temporary tablespace temp_n;



col PROPERTY_VALUE for a40
col DESCRIPTION for a40
select * from database_properties;