Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZADANIE 15
- select * from (
- select name,
- salary,
- dense_rank() over (order by salary desc) as rnk
- from person)
- where rnk <= 3 and rownum<=3;
- ZADANIE 5
- static void Insertexample()
- // inserts a new record in workplace
- {
- string cprstring;
- string companystring;
- Console.WriteLine("Indtast cpr-number");
- cprstring = Console.ReadLine();
- Console.WriteLine("Indtast company-number");
- companystring = Console.ReadLine();
- string sql;
- sql = "insert into workplace values ('"+ cprstring + "'," + companystring + ")";
- //OracleCommand cmd = new OracleCommand();
- DbCommand cmd = dbFactory.CreateCommand();
- cmd.Connection = con;
- cmd.CommandText = sql;
- // lΔs tabellen person
- try
- { // ΔΊbn forbindelse til database
- con.Open();
- cmd.ExecuteNonQuery();
- Console.WriteLine("The insert is done");
- }
- catch (OracleException ex)
- {
- if (ex.Message.Contains("ORA-02291: integrity constraint (SYSTEM.CPRFOREIGN)"))
- Console.WriteLine("The cpr number does not exits");
- if (ex.Message.Contains("ORA-02291: integrity constraint (SYSTEM.COMPANYFOREIGN)"))
- Console.WriteLine("The company number does not exits");
- if(ex.Message.Contains("ORA-00001"))
- Console.WriteLine("Person already exists in company");
- }
- finally
- { // luk forbindelse til databasen
- con.Close();
- }
- Console.WriteLine();
- Console.WriteLine("---------------------------------------------------------------------");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement