Tuesday, March 11, 2014

Oracle Java Checking Null Values

private boolean find_product_sl(String sl) {

        try {
            String sql = "Select ID as L from INV_ITEM_SPEC where ITEM_SL_NO = ? and DEBTORS_ID is null";
            pst = conn.prepareStatement(sql);
            pst.setObject(1, sl);
            ResultSet rsc = pst.executeQuery();

            if (rsc.next())
                 return true;
            else return false;

        } catch (Exception e) {

            JOptionPane.showMessageDialog(null, "Connecitivity Problems x" + e, "Invalid", JOptionPane.ERROR_MESSAGE);

        }
        return false;
    }

Sunday, March 9, 2014

Oracle Create a Sequence




CREATE SEQUENCE  "ERP"."SALES_DEBTORS_BRANCH"  MINVALUE 0 MAXVALUE 300 INCREMENT BY 1 START WITH 10 CACHE 20 NOORDER  NOCYCLE ;

Oracle Java Case like If Else SQL



String  sql = "SELECT  CASE WHEN contract_active_for ='General' THEN 'General contact data for customer branch (overrides company setting)' ELSE TRIM(contract_active_for || ' ' || '(overrides company setting)') END as Assignment ,ref as Reference, TRIM(name ||' '|| name2) as \"Full Name\", phone as Phone, phone2 as \"Sec Phone\",fax as Fax, email from crm_persons where branch_id='"+ br_id+"'";
       

Oracle Java Concate / TRIM


 sql = "SELECT  id as ID,CASE WHEN contract_active_for ='General' THEN 'General contact data for customer branch (overrides company setting)' ELSE TRIM(contract_active_for || ' ' || '(overrides company setting)') END as Assignment ,ref as Reference, TRIM(name ||' '|| name2) as \"Full Name\", phone as Phone, phone2 as \"Sec Phone\",fax as Fax, email from crm_persons where branch_id='"+ br_id+"'";
       

Oracle Java Insert Date Function




TO_DATE('" + Ord_Date+ "', 'yyyy-mm-dd hh24:mi:ss'),

Oracle Java Date Between Sql



String query = "Select type_details as \"TYPE\" ,trans_no as \"#\", reference as Reference ,loc_code AS Location,tran_date as \"Date\", qty as Quantity, CASE WHEN qty >0 THEN 'In' WHEN qty <0 THEN 'Out' END as \"Inventory In - Out \" from inv_dcl_stock_moves where stock_id=? and trunc(tran_date) BETWEEN TO_DATE('"  + Date_From + "', 'yyyy-mm-dd') AND TO_DATE('"  + Date_To+ "', 'yyyy-mm-dd')";
             

Sunday, September 15, 2013

Oracle start and login remotly

login as: root
root@192.168.1.104's password:
Last login: Mon Sep  9 07:07:22 2013 from 192.168.1.103
[root@localhost ~]# ls
anaconda-ks.cfg  Documents  install.log         Music     Public     t -x
Desktop          Downloads  install.log.syslog  Pictures  Templates  Videos
[root@localhost ~]# /etc/init.d/oracle-xe start
Starting Oracle Net Listener.
Starting Oracle Database 11g Express Edition instance.

[root@localhost ~]# sqlplus system
-bash: sqlplus: command not found
[root@localhost ~]# echo $ORACLE_HOME

[root@localhost ~]# /u01/app/oracle/product/11.2.0/xe
-bash: /u01/app/oracle/product/11.2.0/xe: is a directory
[root@localhost ~]# . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
[root@localhost ~]# /u01/app/oracle/product/11.2.0/xe
-bash: /u01/app/oracle/product/11.2.0/xe: is a directory
[root@localhost ~]# echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/xe
[root@localhost ~]# sqlplus

SQL*Plus: Release 11.2.0.2.0 Production on Sun Sep 15 11:33:03 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: sakib
Enter password:

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL>