App6: Write a program to update employee salaries with increment for the
certain range with dynamic input.
Eg: Increment all employee salaries by 500 whose salary < 5000
1) import cx_Oracle
2) try:
3) con=cx_Oracle.connect('scott/tiger@localhost')
4) cursor=[Link]()
5) increment=float(input("Enter Increment Salary:"))
6) salrange=float(input("Enter Salary Range:"))
7) sql="update employees set esal=esal+%f where esal<%f"
8) [Link](sql %(increment,salrange))
9) print("Records Updated Successfully")
10) [Link]()
11) except cx_Oracle.DatabaseError as e:
12) if con:
13) [Link]()
14) print("There is a problem with sql :",e)
15) finally:
16) if cursor:
17) [Link]()
18) if con:
19) [Link]()
App7: Write a program to delete employees whose salary greater provided
salary as dynamic input?
Eg: delete all employees whose salary > 5000
1) import cx_Oracle
2) try:
3) con=cx_Oracle.connect('scott/tiger@localhost')
4) cursor=[Link]()
5) cutoffsalary=float(input("Enter CutOff Salary:"))
6) sql="delete from employees where esal>%f"
7) [Link](sql %(cutoffsalary))
8) print("Records Deleted Successfully")
9) [Link]()
10) except cx_Oracle.DatabaseError as e:
11) if con:
12) [Link]()
13) print("There is a problem with sql :",e)
14) finally:
15) if cursor:
16) [Link]()
17) if con:
18) [Link]()
App8: Write a program to select all employees info by using fetchone()
method?
1) import cx_Oracle
2) try:
3) con=cx_Oracle.connect('scott/tiger@localhost')
4) cursor=[Link]()
5) [Link]("select * from employees")
6) row=[Link]()
7) while row is not None:
8) print(row)
9) row=[Link]()
10) except cx_Oracle.DatabaseError as e:
11) if con:
12) [Link]()
13) print("There is a problem with sql :",e)
14) finally:
15) if cursor:
16) [Link]()
17) if con:
18) [Link]()
nd
DURGASOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
7 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | [Link]