Thursday, December 26, 2013

Trim Example In Oracle SQL


TRIM function


TRIM is a function that takes a character expression and returns that expression with leading and/or trailing pad characters removed. Optional parameters indicate whether leading, or trailing, or both leading and trailing pad characters should be removed, and specify the pad character that is to be removed.

TRIM Syntax


TRIM( [ trimOperands ] trimSource)
trimOperands ::= { trimType [ trimCharacter ] FROM | trimCharacter FROM }
trimType ::= { LEADING | TRAILING | BOTH }
trimCharacter ::= CharacterExpression
trimSource ::= CharacterExpression

Trim Example In Oracle SQL 1 : Trim Character



Trim Single Character from declaring Text Value. Here Trim 'A' from 'AAAHAI'.

Example Query For Trim Single Character


SELECT TRIM('A' FROM 'AAAHAI') FROM DUAL;
OUTPUT:
HAI


Trim Example In Oracle SQL 2 : Trim Space



Trim Space Character from declaring Text Value. Here Trim Space from ''I AM THIYAGARAAJ'.

Example Query For Trim Space


SELECT TRIM(' ' FROM 'I AM THIYAGARAAJ') FROM DUAL;
OUTPUT:
I AM THIYAGARAAJ


Trim Example In Oracle SQL 3 : Trim Character




Trim Single Character from declaring Text Value. Here Trim 'A' from ''I AM THIYAGARAAJ'.

Example Query For Trim Space



SELECT TRIM('A' FROM 'AAI AM THIYAGARAAJAAAA') FROM DUAL;
OUTPUT:
I AM THIYAGARAAJ

Trim Example In Oracle SQL 4 :Trim Space


Trim Space Character from declaring Text Value. Here Trim Space from ''I AM EXAMPLE'.

Example Query For Trim Space


SELECT TRIM(' ' FROM '        I AM EXAMPLE') FROM DUAL;
OUTPUT:
I AM EXAMPLE

java.net.socketexception permission denied in Android

Problem:


java.net.socketexception permission denied in Android


Solution:


Add Internet Permission In Manifest FilePermission Code:
uses-permission android:name="android.permission.INTERNET";
Add In manifest.xml

Step By Step Example For Object Type In Oracle



Object Type Definition


Object-oriented programming is especially suited for building reusable components and complex applications. In PL/SQL, object-oriented programming is based on object types. They let you model real-world objects, separate interfaces and implementation details, and store object-oriented data persistently in the database.

Step By Step Example For Object Type In Oracle


Create Object Type


-----------------------------------------------------------------------------------

SQL> CREATE TYPE ObjectPersonType AS OBJECT (

  2    ID       NUMBER,

  3    FNAME    VARCHAR2(20),

  4    LNAME    VARCHAR2(25),

  5    PHONE    VARCHAR2(20),

  6    MAP MEMBER FUNCTION get_idno RETURN NUMBER,

  7    MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY ObjectPersonType ));

  8  /


Type created.

-----------------------------------------------------------------------------------


here,  object variables are,

ID       NUMBER,

FNAME    VARCHAR2(20),

LNAME    VARCHAR2(25),

PHONE    VARCHAR2(20)


and

Object Memeber Functions,Procedures are

MAP MEMBER FUNCTION get_idno RETURN NUMBER

-- Return Self ID Number,

MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY ObjectPersonType )

-- In & Out Is Own Type Parameter


-----------------------------------------------------------------------------------

Create/ Replace Type Body


 
SQL> CREATE OR REPLACE TYPE BODY ObjectPersonType AS

  2    MAP MEMBER FUNCTION get_idno RETURN NUMBER IS

  3    BEGIN

  4      RETURN ID;

  5    END;

  6    MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY ObjectPersonType ) IS

  7            BEGIN

  8      -- use the PUT_LINE procedure of the DBMS_OUTPUT package to display details

  9              DBMS_OUTPUT.PUT_LINE(TO_CHAR(ID) || ' ' || FNAME || ' ' || LNAME);

  10      DBMS_OUTPUT.PUT_LINE(PHONE);

 11    END;

 12  END;

 13/


Type body created.

-----------------------------------------------------------------------------------

Create New Table Using Object Type (ObjectPersonType)


 
Description:

Table Name Is PERSONLIST,

Fields are, RECORDDATE as Date & DETAILS As ObjectPersonType(Using Defined Object Type)


CREATE TABLE PERSONLIST (

  RECORDDATE   DATE,

  DETAILS              ObjectPersonType);


Table created.

-----------------------------------------------------------------------------------

Insert Values For Object Type PERSONLIST


 
INSERT INTO PERSONLIST VALUES (

                SYSDATE,  ObjectPersonType (25, 'Raaj', 'Malik','9876700001'));


1 row created.


INSERT INTO PERSONLIST VALUES (

                SYSDATE,  ObjectPersonType (21, 'Boss', 'Sivaji','9876700002'));


1 row created.

-----------------------------------------------------------------------------------

Select Statements For Object Type



SQL> SELECT * FROM PERSONLIST;


RECORDDAT

---------

DETAILS(ID, FNAME, LNAME, PHONE)

--------------------------------------------------------------------------------

13-JUL-10

OBJECTPERSONTYPE(25, 'Raaj', 'Malik', '9876700001')


13-JUL-10

OBJECTPERSONTYPE(21, 'Boss', 'Sivaji', '9876700002')



SQL> SELECT DETAILS FROM PERSONLIST;


DETAILS(ID, FNAME, LNAME, PHONE)

--------------------------------------------------------------------------------

OBJECTPERSONTYPE(25, 'Raaj', 'Malik', '9876700001')

OBJECTPERSONTYPE(21, 'Boss', 'Sivaji', '9876700002')



SQL> SELECT DETAILS FROM PERSONLIST WHERE RECORDDATE=( SELECT MAX(RECORDDATE) FROM PERSONLIST);


DETAILS(ID, FNAME, LNAME, PHONE)

--------------------------------------------------------------------------------

OBJECTPERSONTYPE(21, 'Boss', 'Sivaji', '9876700002')


SQL> SELECT c.DETAILS.get_idno() FROM PERSONLIST c;


C.DETAILS.GET_IDNO()

--------------------

                  25

                  21


SQL> SELECT Obj.DETAILS.FNAME FROM PERSONLIST Obj;


DETAILS.FNAME

--------------------

Raaj

Boss



SQL> SELECT DETAILS FROM PERSONLIST Obj WHERE Obj.DETAILS.FNAME='Raaj';


DETAILS(ID, FNAME, LNAME, PHONE)

--------------------------------------------------------------------------------

OBJECTPERSONTYPE(25, 'Raaj', 'Malik', '9876700001')



SQL> DECLARE

  Obj OBJECTPERSONTYPE;

BEGIN

  SELECT DETAILS INTO Obj FROM PERSONLIST WHERE RECORDDATE=( SELECT MAX(RECORDDATE) FROM PERSONLIST);

  Obj.display_details();

END;

/

21 Boss Sivaji

9876700002


PL/SQL procedure successfully completed.

--------------------------------------------------------------------------------






Get Oracle Version ( SQL )

You can get all information about Oracle Version ( SQL ). Below Examples,

Get Oracle Version ( SQL ) Database Version


select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - Production
CORE    10.2.0.2.0      Production
TNS for Solaris: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production  

Get Oracle Version ( SQL ) Select Full Product Details


select * from product_component_version;PRODUCT
----------------------------------------------------------------
VERSION
----------------------------------------------------------------
STATUS
----------------------------------------------------------------
NLSRTL
10.2.0.2.0
Production
Oracle Database 10g Enterprise Edition
10.2.0.2.0
ProdPRODUCT
----------------------------------------------------------------
VERSION
----------------------------------------------------------------
STATUS
----------------------------------------------------------------PL/SQL
10.2.0.2.0
Production

TNS for Solaris:
10.2.0.2.0

PRODUCT
----------------------------------------------------------------
VERSION
----------------------------------------------------------------
STATUS
----------------------------------------------------------------
Production

Get Oracle Version ( SQL ) Select Version With Banner


select * from v$version where banner like 'Oracle%';

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
Select Version With Banner

select * from v$version where banner like 'PL/SQL%';
BANNER
----------------------------------------------------------------
PL/SQL Release 10.2.0.2.0 - Production

 

Wednesday, December 25, 2013

Difference of Unhandled and Handled exception


Step 1 : Create Table

 create table cust_table

 (

   NAME                                VARCHAR2(30),

   ORD_DT                            DATE,

   PUR_DATE                    DATE,

   QUANTITY                        NUMBER,

   ITEM_NO                         VARCHAR2(30)

  );


  Step 2 : Try to execute a block without exception part.

    begin

                                insert into cust_table(NAME,ORD_DT,PUR_DATE,QUANTITY,ITEM_NO) values('Sivakurunath',sysdate-1,sysdate,100,'ORA0001');


                                insert into cust_table(NAME,ORD_DT,PUR_DATE,QUANTITY,ITEM_NO) values('Sivakumar',sysdate-1,sysdate,100,'ORA0002');


                                update cust_table set NAME='eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'

                                where ITEM_NO='ORA0002';

 end;

 /


  Step 3 : Do select ,Check how many rows inserted and updated.

 select * from cust_table;


 Step 4 : Try to execute same block with  exception.

  begin

                                insert into cust_table(NAME,ORD_DT,PUR_DATE,QUANTITY,ITEM_NO) values('Sivakurunath',sysdate-1,sysdate,100,'ORA0001');


                                insert into cust_table(NAME,ORD_DT,PUR_DATE,QUANTITY,ITEM_NO) values('Sivakumar',sysdate-1,sysdate,100,'ORA0002');


                                update cust_table set NAME='eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'

                                where ITEM_NO='ORA0001';


 exception

     when others then

        dbms_output.put_line(sqlerrm);

 end;

 /


 step 5 : Do select ,Check how many rows inserted and updated.

 select * from cust_table;


 step 6 : Find in which scenario transaction remain as a part of transaction (step 2 or step 4). 


No Title Bar For Android Coding

No Title Bar For Android Coding Example


    @Override    public void onCreate(Bundle savedInstanceState) {       
 super.onCreate(savedInstanceState);      
 requestWindowFeature(Window.FEATURE_NO_TITLE); // Add this Line

Import
import android.view.Window;

Difference Between View and Materialized View with Examples


Difference Between View and Materialized



  1. Materialized views are disk based and update periodically base upon the query definition.

  2. Views are virtual only and run the query definition each time they are accessed.


Difference Between View and Materialized Working Example


Step 1 : Create Base Table


create table T1(KEY number,VAL varchar2(10));

insert into t1 values(1,'a');
insert into t1 values(2,'b');
insert into t1 values(3,'c');
insert into t1 values(4,'');

Step 2 : Create Ordinary View


create view v as select * from t1 ;

Step 3 : Create Materialized View


create materialized view log on t1 with rowid;
create materialized view mv refresh fast with rowid as select * from t1 ;

Step 4: Check for rowid similarity and difference in materialized view


select rowid from T1 order by rowid ;
select rowid from v order by rowid ;
select rowid from mv order by rowid ;

Step 5 := Update base table


update t1 set val = upper(val);

Step 6 := After DML try to select


select * from T1 order by rowid ;
select * from v order by rowid ;
select * from mv order by rowid ;

Step 7 :- Refresh your materialized View


execute dbms_mview.refresh( 'MV' );

Step 8 := Try to update Base table Via both the view


update v set val = lower(val); -- View will be create
update mv set val = lower(val); -- Here it won't

Step 9 := Drop all objects.


drop materialized view mv ;
drop view v ;
drop table t1;

How Exception Works - Detailed Step by Step Explanation In Oracle PL/SQL


What is Exception  In Oracle PL/SQL ?


Whenever error occurred in executable area (ie. in begin block) then exception will raise and program will terminate .

Difference Between Calling and Called program



  • A program contain many programs inside then it is called as calling program.

  • A program called by another program then it is called as called program.


How Exception Works  In Oracle PL/SQL



  1. If exception handled in both calling and called environment .Then any exception arrives inside the called program then exception will be handled by itself only(ie. called program) and program will not terminate until exception raised in calling environment or execute completely.

  2. While handling exception in calling environment but not in called environment .Then any exception arrives inside the called program then exception will be handled by called one and program terminates immediately.


Exception Works


Detailed Step by Step Explanation In Oracle PL/SQL


Step 1: Drop Table If Exists


drop table error;
drop table tab_1;
drop table tab_2;
drop table tab_3;



Step 2: Create Table


create table error ( value number, status varchar2(1000),st_date timestamp,nam_tab varchar2(50));
create table tab_1 (a number , dup_num number, name varchar2(30));
create table tab_2 (a number , dup_num number, name varchar2(30));
create table tab_3 (a number , dup_num number, name varchar2(30));



Step 3: Drop Sequence


drop sequence test_seq;



Step 4 : create Sequence


create sequence test_seq increment by 1 start with 1 maxvalue 100 nocache nocycle;



Step 5:= Create Packages use exception in both calling and called environment


create or replace package pack_one
as
procedure p1(p_a number);
end pack_one;
/


create or replace package body pack_one
as
procedure p1(p_a number)
as
v_num number;
v_error varchar2(4000);
begin


select dup_num
into v_num
from tab_1
where a = p_a;
dbms_output.put_line('Step 1 ..........................');
pack_two.p2(v_num);
dbms_output.put_line('Step 2 ..........................');
pack_three.p3(v_num);
dbms_output.put_line('Step 3 ..........................');
Exception
when others then
v_error := substr(sqlerrm,1,100);
insert into error values(test_seq.nextval ,v_error,sysdate,'pack_one.p1');
end p1;
end pack_one;
/

create or replace package pack_two
as
procedure p2(p_a number);
end pack_two;
/


create or replace package body pack_two
as
procedure p2(p_a number)
as
v_num number;
v_error varchar2(4000);
begin
select dup_num
into v_num
from tab_2
where a = p_a;
Exception
when others then
v_error := substr(sqlerrm,1,100);
insert into error values(test_seq.nextval ,v_error,sysdate,'pack_one.p2');
end p2;
end pack_two;
/


create or replace package pack_three
as
procedure p3(p_a number);
end pack_three;
/


create or replace package body pack_three
as
procedure p3(p_a number)
as
v_num number;
v_error varchar2(4000);
begin
select dup_num
into v_num
from tab_3
where a = p_a;
Exception
when others then
v_error := substr(sqlerrm,1,100);
insert into error values(test_seq.nextval ,v_error,sysdate,'pack_one.p3');
end p3;


end pack_three;
/

Step 6: Truncate Table rows only


Truncate table tab_1;
Truncate table tab_2;
Truncate table tab_3;



Step 7 : Insert Few Rows


Insert into tab_1 values(1,20,'Hello');
Insert into tab_2 values(2,3,'Hi');
Insert into tab_3 values(20,1,'Wow');


set serveroutput on
execute pack_one.p1(1);


Select * from error;



Step 8 : Create Package by writing Exception only in calling package (eg.pack_one)


create or replace package pack_one
as
procedure p1(p_a number);
end pack_one;
/


create or replace package body pack_one
as
procedure p1(p_a number)
as
v_num number;
v_error varchar2(4000);
v_seq number;
begin
select dup_num
into v_num
from tab_1
where a = p_a;
dbms_output.put_line('Step 1 ..........................');
pack_two.p2(v_num);
dbms_output.put_line('Step 2 ..........................');
pack_three.p3(v_num);
dbms_output.put_line('Step 3 ..........................');
Exception
when others then
v_error := substr(sqlerrm,1,100);
insert into error values(test_seq.nextval ,v_error,sysdate,'pack_one.p1');
end p1;
end pack_one;
/


create or replace package pack_two
as
procedure p2(p_a number);
end pack_two;
/


create or replace package body pack_two
as
procedure p2(p_a number)
as
v_num number;
v_error varchar2(4000);
begin
select dup_num
into v_num
from tab_2
where a = p_a;
end p2;
end pack_two;
/


create or replace package pack_three
as
procedure p3(p_a number);
end pack_three;
/
create or replace package body pack_three
as
procedure p3(p_a number)
as
v_num number;
v_error varchar2(4000);
begin
select dup_num
into v_num
from tab_3
where a = p_a;
end p3;
end pack_three;
/



Step 9: Truncate Table rows only


Truncate table tab_1;
Truncate table tab_2;
Truncate table tab_3;



Step 10 : Insert Few Rows


Insert into tab_1 values(1,20,'Hello');
Insert into tab_2 values(2,3,’Hi’);
Insert into tab_3 values(20,1,'Wow');


set serveroutput on
execute pack_one.p1(1);


Select * from error;



Create simple procedure in PL/SQL Oracle


Subprograms


Subprograms are named PL/SQL blocks that can be called with a set of parameters.
There are two types of blocks in PL/SQL:
•    Procedures
•    Functions

Structure Of Oracle Procedure(Anonymous block)


DECLARE         (optional)
        /* Variable Block                     */
    BEGIN             (mandatory)
        /* Executable Statements / Queries     */
    EXCEPTION    (optional)
        /* Exception Action                 */
END;                (mandatory)
/

Syntax of PL/SQL Oracle Procedure


CREATE [OR REPLACE] PROCEDURE procedure_name
 [(parameter1 [mode1] datatype1,
  parameter2 [mode2] datatype2,
  . . .)]
IS|AS
PL/SQL Block;

Structure Of Oracle Procedure(Named block)


CREATE [OR REPLACE] PROCEDURE procedure_name          (mandatory)
        /* Variable Block                     */
    BEGIN             (mandatory)
        /* Executable Statements / Queries     */
    EXCEPTION    (optional)
        /* Exception Action                 */
END;                (mandatory)
/

Modes:


•    IN: procedure must be called with a value for the parameter. Value cannot be changed
•    OUT: procedure must be called with a variable for the parameter. Changes to the parameter are seen by the user (i.e., call by reference)
•    IN OUT: value can be sent, and changes to the parameter are seen by the user

Default Mode is:


IN

Consider Table


Table Name: Example
NAME             VARCHAR2(10)
NUM              NUMBER(3)

Table Data


Select * from example;
NAME       NUM                    
---------- ----------------------
NAMEONE    1                      
NAMETWO    2                      
NAMETHREE  3                      
NAMEFOUR   4                      
NAMEFIVE   5                      
NAMESIX    6                      
NAMESEVEN  7                      
test -100  100                    
test -200  200                    
test -300  300                    
test -500  500        

11 rows selected

Create Simple Procedure in PL/SQL Oracle For Get Name From Example Table


Create or replace procedure p_getname
(v_num IN example.num%TYPE,
v_name OUT example.name%TYPE)
/*    v_num     - Input Parameter            */
/*    v_name     - Output Parameter            */
IS
BEGIN
    select name
    into v_name
    from example
    where v_num = num;
END;
/

Calling the Procedure


set serveroutput on;
declare
    getname  example.name%TYPE;
begin
    p_getname(1,getname);
    dbms_output.put_line('-----------');
    dbms_output.put_line(getname);
end;
/

Sample Output:


anonymous block completed
-----------
NAMEONE

Create table In Oracle Simple Example

Create table In Oracle


The Data Definition Language (DDL) manages table and index structure. The most basic items of DDL are the CREATE, ALTER, RENAME, DROP and TRUNCATE statements. Here we see about Create Table with examples

Create Table Statement


A CREATE TABLE statement creates a table. Tables contain columns and constraints, rules to which data must conform. Table-level constraints specify a column or columns. Columns have a data type and can specify column constraints (column-level constraints).

Create table In Oracle Syntax:


CREATE TABLE TABLENAME (
   field1 data_type,
   field2 data_type,
   ...
   ...
   fieldn data_type
)

Create table In Simple Example Declaration:


here,
Consider
Two Fields;
1) E_ID as number
2) E_Name as varchar(20)

Create table In Oracle Simple Example Code:


CREATE TABLE Example
CREATE TABLE EMPLOYEE
   (
   E_ID NUMBER,
   E_NAME VARCHAR2(20)
   );

Message Box In Java Using Plain AWT


Message Box In Java Using Plain AWT Example Code:


here mention full java program for Message Box In Java Using Plain AWT

    import java.awt.*;
    import java.awt.event.*;
    public class MsgBox extends Dialog implements ActionListener
    {  
    private Button ok,can;
    public boolean isOk = false;
    /*  * @param frame parent frame
        * @param msg message to be displayed
        * @param okcan true : ok cancel buttons, false : ok button only   */  

    MsgBox(Frame frame, String msg, boolean okcan)
    super(frame, "Message", true);
    setLayout(new BorderLayout());
    add("Center",new Label(msg));
    addOKCancelPanel(okcan);
    createFrame();
    pack();
    setVisible(true);
    }

    MsgBox(Frame frame, String msg)
    {  this(frame, msg, false);  }
    void addOKCancelPanel( boolean okcan )
    {  Panel p = new Panel();
    p.setLayout(new FlowLayout());
    createOKButton( p );
    if (okcan == true)
    createCancelButton( p );
    add("South",p);  
    }

    void createOKButton(Panel p)
    {  
    p.add(ok = new Button("OK"));
    ok.addActionListener(this);
    }

    void createCancelButton(Panel p)
    {
    p.add(can = new Button("Cancel"));
    can.addActionListener(this);
    }

    void createFrame()
    {
    Dimension d = getToolkit().getScreenSize();
    setLocation(d.width/3,d.height/3);
    }

    public void actionPerformed(ActionEvent ae)
    {
    if(ae.getSource() == ok)
    {  
    isOk = true;  setVisible(false);
    }
    else if(ae.getSource() == can)
    {  
    setVisible(false);
    }
    }

    public static void main(String args[])
    {
    Frame f = new Frame();
    f.setSize(200,200);
    f.setVisible(true);
    MsgBox message = new MsgBox  (f , "Hey you user, are you sure ?", true);
    if (message.isOk)
    System.out.println("Ok pressed");
    if (!message.isOk)
    System.out.println("Cancel pressed");
    message.dispose();
    }
    }

Drop In Oracle

Drop In Oracle:


Assume table name is EMPLOYEE
DROP TABLE_NAME;
DROP EMPLOYEE;

EditText Hint In Android

Syntax:
android:hint="hint-statement"


EditText Hint In Android Example:

<android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter user Name"
/>


EditText Hint In Android Screenshot:

TextView font Change In Android

Syntax:


android:typeface="serif"

TextView font Change In Android Example:


<android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Example Application"
android:typeface="serif"
/>

Count In Oracle SQL

Assume table name is EMPLOYEE and it has E_NAME Field.

Count In Oracle SQL  : All Records In Table



SELECT COUNT(*) FROM EMPLOYEE;

Count In Oracle SQL : All Records In Table with Head Name


SELECT COUNT(*) AS EMPLOYYE_COUNT FROM EMPLOYEE;

Count Column Records In Table


SELECT COUNT(E_NAME) FROM EMPLOYEE;

Count Distinct Column Records In Table


SELECT COUNT(DISTINCT E_NAME) FROM EMPLOYEE;

Count In Oracle SQL : Selected Records In Table


SELECT COUNT(*) FROM EMPLOYEE WHERE CONDITION E_NAME = 'BOND';

Count In Oracle SQL : Selected Records with Head Name


SELECT COUNT(*) FROM EMPLOYEE NAME_BOND WHERE CONDITION E_NAME = 'BOND';

Delete In Oracle SQL

Assume table name is EMPLOYEE and it has E_NAME Field.

Delete In Oracle SQL : All Rows In Tables



DELETE TABLE_NAME;
DELETE EMPLOYEE;

Delete In Oracle SQL : All Rows In Tables


DELETE FROM TABLE_NAME;
DELETE FROM EMPLOYEE;

Delete In Oracle SQL : Selected Rows In Tables


DELETE FROM TABLE_NAME WHERE CONDITION;
DELETE FROM EMPLOYEE WHERE E_NAME = 'RAJU';

Delete In Oracle SQL : through Select Rows In Tables


DELETE FROM (SELECT * FROM TABLE_NAME WHERE CONDITION);
DELETE FROM (SELECT * FROM EMPLOYEE WHERE E_NAME = 'RAJU');

Jar Mismatch Found no of versions of android-support-v4.jar in the dependency list/ Conflict in jar with multi-library project


Problem:


Jar Mismatch Found no of versions of android-support-v4.jar in the dependency list
Conflict in jar with multi-library project

Solutions:



  1. Looks like it found the library twice. You need to delete one.

  2. Mismatch Android Versions for Projects and Its Library Projects

  3. Please go to libs folder of your main project and copy / replace the android-support-v4.jar file to the libs folder of all attached to your project libraries projects. It should solve the library conflict issue.


Monday, December 23, 2013

Get Date Time In Oracle

Date Time In Oracle: Date From System In Oracle


SELECT SYSDATE FROM DUAL;

Date Time In Oracle: Date From System In Oracle


SELECT TO_CHAR(SYSDATE,'YYYY MM DD') FROM DUAL;


Date Time In Oracle: Time From System In Oracle


SELECT TO_CHAR(SYSDATE,'HH MI SS') FROM DUAL;


Date Time In Oracle: Date From System with Heading In Oracle


SELECT TO_CHAR(SYSDATE,'YYYY MM DD') TODAY_DATE FROM DUAL;


Date Time In Oracle: Time From System with Heading In Oracle


SELECT TO_CHAR(SYSDATE,'HH MI SS') NOW_TIME FROM DUAL;


Date Time In Oracle: Time(24 Hours) From System with Heading In Oracle


SELECT TO_CHAR(SYSDATE,'HH24 MI SS') NOW_TIME FROM DUAL;


Date Time In Oracle: Time(12 Hours) From System with Heading In Oracle


SELECT TO_CHAR(SYSDATE,'HH MI SS') NOW_TIME FROM DUAL;


Date Time In Oracle: Date & Time(12 Hours) From System with Heading In Oracle


SELECT TO_CHAR(SYSDATE,'YYYY MM DD HH24 MI SS') DAT_TIME FROM DUAL;

Create Sequence In Oracle

Sequence In Oracle Definition:


You can create for auto increment number/ID creation. Oracle generates sequence of number depend upon our code boundary.


Sequence In Oracle Syntax:


CREATE SEQUENCE SEQUENCE_NAME

        MINVALUE VALUE        ( Assign Minimum Value )

        MAXVALUE VALUE        ( Assign Maximum Value )

        START WITH VALUE    ( Assign Start Value )

        INCREMENT BY VALUE;    ( Assign Increment Value )


Sequence In Oracle Example:


CREATE SEQUENCE DUMMY_SEQUENCE

    MINVALUE 1

    MAXVALUE 10000

    START WITH 1

    INCREMENT BY 1

    CACHE 20;


Sequence Usage:


    DUMMY_SEQUENCE.NEXTVAL


Sequence Inside Query


INSERT INTO DUMMY_PERSONAL_DTLS

(DUMMY_ID,DUMMY_FNAME,DUMMY_LANME)

VALUES

(DUMMY_SEQUENCE.NEXTVAL,'RAJINI','THIYAGARAAJ');

Simple Program For Binary Search In Java Programming

Algorithm Definition:


A straightforward implementation of binary search is recursive. The initial call uses the indices of the entire array to be searched. The procedure then calculates an index midway between the two indices, determines which of the two subarrays to search, and then does a recursive call to search that subarray. Each of the calls is tail recursive, so a compiler need not make a new stack frame for each call. The variables imin and imax are the lowest and highest inclusive indices that are searched.

Example Program For Binary Search In Java




import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;


// Simple Program For Binary Search In Java Using Class


public class BinarySearchExample {


    public static void main(String arg[]) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        BinarySearch binarySearch = new BinarySearch(10);

        binarySearch.readData();

        System.out.println("Enter the Element to search");

        int find = Integer.parseInt(br.readLine());

        int index = binarySearch.search(find);


        if (index != -1) {

            System.out.println("Element found Position : " + (index+1));

        } else {

            System.out.println("Element not found");

        }

    }

}


class BinarySearch {


    private int data[];

    private int size;


    public BinarySearch(int size) {

        this.data = new int[size];

        this.size = size;

    }


    public void readData() throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        System.out.println("Please Enter Values");

        for (int i = 0; i < size; i++) {

            System.out.println("Enter Value #"+(i+1)+" : ");

            data[i] = Integer.parseInt(br.readLine());

        }

    }


    public int search(int find) {

        int start = 0;

        int end = data.length - 1;

        int mid;

        while (start <= end) {

            mid = (start + end) / 2;

            if (data[mid] == find) {

                return mid;

            } else if (data[mid] < find) {

                start = mid + 1;

            } else if (data[mid] > find) {

                end = mid - 1;

            }

        }

        return -1;

    }

}


Sample Output:


Please Enter Values

Enter Value #1 :

34

Enter Value #2 :

11

Enter Value #3 :

22

Enter Value #4 :

45

Enter Value #5 :

78

Enter the Element to search

45

Element found Position : 4

 

Simple Program For Binary Search In Java ( Simple Way )

Binary Search Algorithm Definition:


A straightforward implementation of binary search is recursive. The initial call uses the indices of the entire array to be searched. The procedure then calculates an index midway between the two indices, determines which of the two subarrays to search, and then does a recursive call to search that subarray. Each of the calls is tail recursive, so a compiler need not make a new stack frame for each call. The variables imin and imax are the lowest and highest inclusive indices that are searched.


Simple Program For Binary Search In Java




import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;


// Simple Program For Binary Search In Java Using Class


public class BinarySearchExample {


    public static void main(String arg[]) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        System.out.println("Enter number of elements");

        int num = Integer.parseInt(br.readLine());

        int a[] = new int[num];

        System.out.println("Please enter");

        for (int i = 0; i < num; i++) {

            a[i] = Integer.parseInt(br.readLine());

        }

        System.out.println("Enter the element to search");

        int find = Integer.parseInt(br.readLine());

        int index = search(a, find);

        if (index != -1) {

            System.out.println("Element found : " + index);

        } else {

            System.out.println("Element not found");

        }

    }


    public static int search(int ar[], int find) {

        int start = 0;

        int end = ar.length - 1;

        int mid;

        while (start <= end) {

            mid = (start + end) / 2;

            if (ar[mid] == find) {

                return mid;

            } else if (ar[mid] < find) {

                start = mid + 1;

            } else if (ar[mid] > find) {

                end = mid - 1;

            }

        }

        return -1;

    }

}


Simple Program For Binary Search Sample Output:



Please Enter Values


Enter No Of Elements

5

Please enter

Enter Value #1 :

67

Enter Value #2 :

34

Enter Value #3 :

45

Enter Value #4 :

90

Enter Value #5 :

101

Enter the Element to search

45

Element found Position : 3

Simple Example Program For Queue In Java Using Array and Class

Queue Wiki Definition:


In each of the cases, the customer or object at the front of the line was the first one to enter, while at the end of the line is the last to have entered. Every time a customer finishes paying for their items (or a person steps off the escalator, or the machine part is removed from the assembly line, etc.) that object leaves the queue from the front. This represents the queue “dequeue” function. Every time another object or customer enters the line to wait, they join the end of the line and represent the “enqueue” function. The queue “size” function would return the length of the line, and the “empty” function would return true only if there was nothing in the line.

Simple Example Program For Queue In Java Using Array and Class




import java.io.*;


class QueueAction {


    BufferedReader is = new BufferedReader(new InputStreamReader(System.in));

    int items[];

    int i, front = 0, rear = 0, noOfItems, item, count = 0;


    void getdata() {

        try {

            System.out.println("Enter the Limit :");

            noOfItems = Integer.parseInt(is.readLine());

            items = new int[noOfItems];

        } catch (Exception e) {

            System.out.println(e.getMessage());

        }

    }


    void enqueue() {

        try {

            if (count < noOfItems) {

                System.out.println("Enter Queue Element :");

                item = Integer.parseInt(is.readLine());

                items[rear] = item;

                rear++;

                count++;

            } else {

                System.out.println("Queue Is Full");

            }

        } catch (Exception e) {

            System.out.println(e.getMessage());

        }

    }


    void dequeue() {

        if (count != 0) {

            System.out.println("Deleted Item :" + items[front]);

            front++;

            count--;

        } else {

            System.out.println("Queue IS Empty");

        }

        if (rear == noOfItems) {

            rear = 0;

        }

    }


    void display() {

        int m = 0;

        if (count == 0) {

            System.out.println("Queue IS Empty");

        } else {

            for (i = front; m < count; i++, m++) {

                System.out.println(" " + items[i]);

            }

        }

    }

}


class QueueProgram {


    public static void main(String arg[]) {

        DataInputStream get = new DataInputStream(System.in);

        int choice;

        QueueAction queue = new QueueAction();

        queue.getdata();

        System.out.println("Queue\n\n");

        try {

            do {

                System.out.println("1.Enqueue\n2.Dequeue\n3.Display\n4.Exit\n");

                System.out.println("Enter the Choice : ");

                choice = Integer.parseInt(get.readLine());

                switch (choice) {

                    case 1:

                        queue.enqueue();

                        break;

                    case 2:

                        queue.dequeue();

                        break;

                    case 3:

                        queue.display();

                        break;

                }

            } while (choice != 4);

        } catch (Exception e) {

            System.out.println(e.getMessage());

        }

    }

}


Sample Output:


Enter the Limit :

4

Queue


1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

1

Enter Queue Element :

45

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

1

Enter Queue Element :

67

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

1

Enter Queue Element :

89

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

1

Enter Queue Element :

567

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

1

Queue Is Full

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

3

 45

 67

 89

 567

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

2

Deleted Item :45

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

2

Deleted Item :67

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

2

Deleted Item :89

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

2

Deleted Item :567

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

2

Queue IS Empty

1.Enqueue

2.Dequeue

3.Display

4.Exit


Enter the Choice :

4

Simple Example Program For Queue In Java

Queue Wiki Definition:


In each of the cases, the customer or object at the front of the line was the first one to enter, while at the end of the line is the last to have entered. Every time a customer finishes paying for their items (or a person steps off the escalator, or the machine part is removed from the assembly line, etc.) that object leaves the queue from the front. This represents the queue “dequeue” function. Every time another object or customer enters the line to wait, they join the end of the line and represent the “enqueue” function. The queue “size” function would return the length of the line, and the “empty” function would return true only if there was nothing in the line.

Simple Example Program For Queue In Java




import java.io.IOException;

import java.util.LinkedList;

import java.util.Queue;


public class QueueExample {


    public static void main(String arg[]) throws IOException {

        Queue<Integer> q = new LinkedList<Integer>();

        

        // Add in Queue

        q.add(23);

        q.add(33);

        System.out.println(q);

        System.out.println("Queue Element :"+q.element());

        // Offer In Queue 

        q.offer(34);

        q.offer(98);

        q.offer(77);


        System.out.println(q);

        System.out.println("Queue Element :"+q.element());

        q.poll();

        System.out.println("Queue Element :"+q.element());

        System.out.println("After poll : " + q);

    }

}


Sample Output:


[23, 33]

Queue Element :23

[23, 33, 34, 98, 77]

Queue Element :23

Queue Element :33

After poll : [33, 34, 98, 77]

Great Android Mobiles for Dec 2013 to Jan 2014

Great Android Mobiles for Dec 2013 to Jan 2014 Below Rs. 15000 Range


Sony Xperia M Dual


Dual Core - 1GB RAM - 5MP Camera - Android 4.1 - 4GB Internal Memory - 4.0 Inch Screen

Price : 13,000 (Single SIM) Rs

Price :14,000 (Dual SIM) Rs

http://www.gsmarena.com/sony_xperia_m-5497.php

Great Android Mobiles for Dec 2013 to Jan 2014 Below Rs. 20000 Range


Huawei Ascend G700


Quad Core - 2 GB RAM - 8 MP Camera - Android 4.2 - 8GB Internal Memory - 5.0 Inch Screen

Price : 16,000 Rs

http://www.gsmarena.com/huawei_ascend_g700-5633.php

Sony Xperia C


Quad Core - 1GB RAM - 8P Camera - Android 4.2 - 4GB Internal Memory - 5.0 Inch Screen

Price : 17,000 Rs

Check Spec:

http://www.gsmarena.com/sony_xperia_c-5541.php

Great Android Mobiles for Dec 2013 to Jan 2014 Above Rs.20000 and Below Rs.30000 Range


Nexus 5


Quad Core - 2 GB RAM - 8 MP Camera - Android 4.4 - 16/32GB Internal Memory - 5.0 Inch Screen

Price : 29,000 Rs

http://www.gsmarena.com/lg_nexus_5-5705.php

LG Optimus G Pro


Quad Core - 2 GB RAM - 8 MP Camera - Android 4.4 - 16/32GB Internal Memory - 5.5 Inch Screen

Price : 27,500 Rs

http://www.gsmarena.com/lg_optimus_g_pro_e985-5254.php

Xperia ZL


Quad Core - 2 GB RAM - 13 MP Camera - Android 4.1 - 16GB Internal Memory - 5.0 Inch Screen

Price : 26,500 Rs

http://www.gsmarena.com/sony_xperia_zl-5203.php

Great Android Mobiles for Dec 2013 to Jan 2014 Above Rs.30000 Range


LG G2


Quad Core - 2 GB RAM - 13 MP Camera - Android 4.2 - 8GB Internal Memory - 5.2 Inch Screen

Price : 37,000 Rs

http://www.gsmarena.com/lg_g2-5543.php

While Loop in PL/SQL Example Code and Concepts

While Loop In Oracle PL/SQL


The WHILE LOOP statement runs one or more statements while a condition is TRUE. The WHILE LOOP statement ends when the condition becomes FALSE or NULL, when a statement inside the loop transfers control outside the loop, or when PL/SQL raises an exception.

Syntax WHILE Loop In Oracle PL/SQL


WHILE Contitions
Loop Statements
END LOOP

While Loop in PL/SQL Example Code : Start With 1 to 10


DECLARE
i NUMBER :=0;
BEGIN
WHILE i < 10 LOOP
i:= i+1;
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/

While Loop in PL/SQL Example Code :  Start With 10 to 17


DECLARE
i NUMBER :=10;
BEGIN
WHILE i < 17 LOOP
i:= i+1;
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/

While Loop in PL/SQL Example Code :  Start & End With variables value


DECLARE
StartValue NUMBER := 10;
EndValue   NUMBER := 20;
BEGIN
WHILE StartValue < EndValue LOOP
StartValue := StartValue + 1;
DBMS_OUTPUT.PUT_LINE('Current Number :'||StartValue);
END LOOP;
END;
/

Sunday, December 22, 2013

For Loop PL/SQL Example Code and Syntax


For Loop Overview and Defintion


Whereas the number of iterations through a WHILE loop is unknown until the loop completes, the number of iterations through a FOR loop is known before the loop is entered. FOR loops iterate over a specified range of integers. The range is part of an iteration scheme, which is enclosed by the keywords FOR and LOOP. A double dot (..) serves as the range operator. The syntax follows:

FOR counter IN [REVERSE] lower_bound..higher_bound LOOP
sequence_of_statements
END LOOP;

Syntax For Loop In Oracle


FOR Conditions
Loop Statements
END LOOP

For Loop Evaluation Formula In Oracle PL/SQL


The range is evaluated when the FOR loop is first entered and is never re-evaluated.

As the next example shows, the sequence of statements is executed once for each integer in the range. After each iteration, the loop counter is incremented.

FOR i IN 1..3 LOOP -- assign the values 1,2,3 to i
sequence_of_statements -- executes three times
END LOOP;

For Loop PL/SQL Example Code: Start With 1 to 10


BEGIN
FOR i IN 1..10 LOOP
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/

For Loop PL/SQL Example Code: Start With 10 to 17


BEGIN
FOR i IN 10..17 LOOP
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/

For Loop PL/SQL Example Code: Start & End With variables value


DECLARE
StartValue NUMBER := 10;
EndValue   NUMBER := 20;
BEGIN
FOR i IN StartValue .. EndValue LOOP
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/

Simple Example Program For Stack in Java Using Array and Class

A stack is a basic computer science data structure and can be defined in an abstract, implementation-free manner, or it can be generally defined as a linear list of items in which all additions and deletion are restricted to one end that is Top.

Simple Example Program For Stack in Java Using Array and Class




// Simple Example Program For Stack in Java Using Array and Class

// Coded By Thiyagaraaj M.P


import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;


class Stack {


    private int top;

    private int item[];


    Stack(int size) {

        top = -1;

        item = new int[size];

    }


    void pushItem(int data) {

        if (top == item.length - 1) {

            System.out.println("Stack is Full");

        } else {

            item[++top] = data;

            System.out.println("Pushed Item :" + item[top]);

        }

    }


    int popItem() {

        if (top < 0) {

            System.out.println("Stack Underflow");

            return 0;

        } else {

            System.out.println("Pop Item : " + item[top]);

            return item[top--];

        }

    }

}


class StackExample {


    public static void main(String[] args) throws IOException {

        Stack stk = new Stack(5);

        boolean yes=true;

        int choice;

        BufferedReader is = new BufferedReader(new InputStreamReader(System.in));

        

        do{

            System.out.println("1).Push\n2).Pop\n3).Exit\n\nEnter Choice");

            choice = Integer.parseInt(is.readLine());

            

            switch(choice)

            {

                case 1: System.out.println("Enter Push Item: ");

                        stk.pushItem(Integer.parseInt(is.readLine()));

                        break;

                case 2: stk.popItem();break;

                case 3: yes = false;break;

                default: System.out.println("Invalid Choice");

            }

        }while(yes==true);

        

    }

}


Sample Output:


1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

14

Pushed Item :14

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

567

Pushed Item :567

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

67

Pushed Item :67

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

789

Pushed Item :789

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

56

Pushed Item :56

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

99

Stack is Full

1).Push

2).Pop

3).Exit


Enter Choice

2

Pop Item : 56

1).Push

2).Pop

3).Exit


Enter Choice

2

Pop Item : 789

1).Push

2).Pop

3).Exit


Enter Choice

2

Pop Item : 67

1).Push

2).Pop

3).Exit


Enter Choice

2

Pop Item : 567

1).Push

2).Pop

3).Exit


Enter Choice

2

Pop Item : 14

1).Push

2).Pop

3).Exit


Enter Choice

2

Stack Underflow

1).Push

2).Pop

3).Exit


Enter Choice

3

Simple Example Program For Stack in Java Stack Utils

Definition:


A stack is a basic computer science data structure and can be defined in an abstract, implementation-free manner, or it can be generally defined as a linear list of items in which all additions and deletion are restricted to one end that is Top.

Simple Example Program For Stack in Java Stack Utils




// Simple Example Program For Stack in Java Stack Utils

// Coded By Thiyagaraaj M.P


import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.Stack;


class StackProgram {


    public static void main(String[] args) throws IOException {

        Stack stk = new Stack();

        stk.setSize(5);

        

        boolean yes=true;

        int choice;

        BufferedReader is = new BufferedReader(new InputStreamReader(System.in));

        

        do{

            System.out.println("1).Push\n2).Pop\n3).Exit\n\nEnter Choice");

            choice = Integer.parseInt(is.readLine());

            

            switch(choice)

            {

                case 1: System.out.println("Enter Push Item: ");

                        stk.push(Integer.parseInt(is.readLine()));

                        break;

                case 2: System.out.println("Poped Item : "+stk.pop());break;

                case 3: yes = false;break;

                default: System.out.println("Invalid Choice");

            }

        }while(yes==true);

        

    }

}


Sample Output:


run:

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

23

1).Push

2).Pop

3).Exit


Enter Choice

1

Enter Push Item:

45

1).Push

2).Pop

3).Exit


Enter Choice

2

Poped Item : 45

1).Push

2).Pop

3).Exit


Enter Choice

2

Poped Item : 23

1).Push

2).Pop

3).Exit

Simple Example Program For Stack in Java( Simple Way Of Use )

Definition:


A stack is a basic computer science data structure and can be defined in an abstract, implementation-free manner, or it can be generally defined as a linear list of items in which all additions and deletion are restricted to one end that is Top.

Simple Example Program For Stack In Java


// Simple Example Program For Stack ( Simple Way Of Use )

// Coded By Thiyagaraaj M.P

import java.util.Stack;


public class SimpleStack {


    public static void main(String[] args) {

        Stack stack = new Stack();


        System.out.println("Stack Items \n" + stack);

        System.out.println("Stack Size :" + stack.size());


        System.out.println("Stack Push \n");

        stack.push("A");

        stack.push(new Integer(20));

        stack.push("Example");


        System.out.println("Stack Items \n" + stack);

        System.out.println("Stack Size :" + stack.size());


        System.out.println("Stack Pop \n");

        System.out.println("Pop Data :" + stack.pop());

        System.out.println("Pop Data " + stack.pop());

        System.out.println("Pop Data " + stack.pop());


        System.out.println("Stack Items \n" + stack);

        System.out.println("Stack Size :" + stack.size());

    }

}

Sample Output:


Stack Items

[]

Stack Size :0

Stack Push


Stack Items

[A, 20, Example]

Stack Size :3

Stack Pop


Pop Data :Example

Pop Data 20

Pop Data A

Stack Items

[]

Stack Size :0

Simple Stack Program In C

Stack Overview


In computer science, a stack is a particular kind of abstract data type or collection in which the principal (or only) operations on the collection are the addition of an entity to the collection, known as push and removal of an entity, known as pop.[1] The relation between the push and pop operations is such that the stack is a Last-In-First-Out (LIFO) data structure. In a LIFO data structure, the last element added to the structure must be the first one to be removed. This is equivalent to the requirement that, considered as a linear data structure, or more abstractly a sequential collection, the push and pop operations occur only at one end of the structure, referred to as the top of the stack. Often a peek or top operation is also implemented, returning the value of the top element without removing it.

Stack Function signatures


  init: -> Stack
  push: N x Stack -> Stack
  top: Stack -> (N U ERROR)
  pop: Stack -> Stack
  isempty: Stack -> Boolean

Example Simple Stack Program In C


 #include<stdio.h>
#include<stdlib.h>
#define SIZE 50void push(int i);
int pop(void);
int  *tos, *p1, stack[SIZE];

int main(void)
{
  int value;
  tos = stack; /* tos points to the top of stack */  
p1 = stack; /* initialize p1 */
do {    
printf("Enter value: ");
   
scanf("%d", &value);
if(value != 0)
push(value);
   
else
printf("value on top is %d\n", pop());
} while(value != -1);
return 0;
}
 

void push(int i)
{
  p1++;
  if(p1 == (tos+SIZE)) {
    printf("Stack Overflow.\n");
    exit(1);
  }
  *p1 = i;
}int pop(void)
{
  if(p1 == tos) {
    printf("Stack Underflow.\n");
    exit(1);
  }
  p1--;
  return *(p1+1);
}

Thursday, December 19, 2013

Copy and Delete Files using VB .Net



Copy and Delete Files using VB .Net




Environment:


Visual Studio 2005
Visual Basic


Header:


Imports System
Imports System.IO


Copy


Function:
File.Copy(SourceFile, DestinationFile)

Example :     
File.Copy("C:\test.txt", "C:\test.txt")


Delete


Function:
File.Delete(DestinationFile)

Example :  
File.Delete("C:\test.txt")


Copy and Delete Files using VB .Net Example Coding


Dim FileToCopy As String
Dim NewCopy As String

FileToCopy = "C:\test.txt"
NewCopy = "C:\NewTest.txt"

If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
MsgBox("File Copied")
End If

 




Message In Android Using Toast


Message In Android Using Toast Function :


public void Message(String Msg)
    {
        Toast.makeText(AndroidExample.this, Msg.toString(), Toast.LENGTH_SHORT).show();
    }

Message In Android Using Toast Calling Method:


Message("Hai");

Tuesday, December 17, 2013

Serialize form in jquery Example

Serialize form in jquery Example : HTML Form


<form id='d34' class='form_example' name='customercontact' method='post' action='customerUpdate.php'>
Form <br />
Name: <input type='text' name='name' class='textbox' value=''><br />
Number: <input type='text' name='number' class='textbox' value=''><br />
E-mail: <input type='text' name='contact_email' class='textbox' value=''><br />
</form>
<br><br>
<button id="form_save">Main button</button>

Serialize form in jquery Example : JQuery Code


$(document).ready(function() {
$('#form_save').click(function(e){
e.preventDefault();
$.each($('form.customer_contact'), function(index) {
var sData = $(this).serialize();
$.ajax({
type: "POST",
url: "updateCustomer.php",
data: sData,
success: function(someMessageFromPhp) {
alert(someMessageFromPhp);
}
});
});
});
});

Android SDK is out of date or is missing templates In Android Studio

Android SDK is out of date or is missing templates In Android Studio


How to solve the problem "Android SDK is out of date or is missing templates" In Android Studio. Easy and Simple Steps

Follow these Steps



  • Open up your project in Android Studio.

  • Go to Settings for the Project via F4. Or selecting the Project Root -> Right-Click and then Module Settings.

  • You will find Project Settings and Module Settings under which you have the option of selecting both your JDK and Android SDKs if you want.

  • For e.g. under Platform Settings, you will find SDKs and you can simply tap on the green + sign to add your own path to a locally present SDK.


Check Once


First of all, on Windows and Mac, the individual tools and other SDKpackages are saved with the Android Studio application directory.

Windows: Users\AppDataLocalAnroidandroid-studiosdk Mac: /Applications/Android Studio.app/sdk/ Make sure your android-sdk-path is correct and the sdk tool version is 22 or later.

first time do open the Configure—> Project Defaults —> Project Structure, set your project sdk is Android SDK.

then select SDK tab and select build target (eg:Android4.2.2)

Android Studio not start with connected device

Android Studio not start with connected device


Step 1 : Run Configuration

Change Run Configuration for Connected Device

You should change Create Run Configuration in that General Tab select Target Device

  • Show chooser dialog

  • USB Devices

  • Emulator


In Menu

Get From Run -> Edit configurations

android.view.InflateException: Error inflating class com.google.ads.AdView in android studio

Step 1:


Check Once, You need to put the admob jar (Download New Version) into the libs folder of your project.

Step 2:


Remove admob Jar in libs folder of your project

File -> Project Structure -> Modules -> Dependencies -> Add AdMob.jar File

Step 3: Check One Android Manifest File


<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>