1a) Develop a trigger that will set CustBalance in Customer table to 100 if the balance (either inserted or updated) is less than 100
b) Create a function called Balance_Format. This function should convert a number to a string formatted as Canadian currency. For example, 33.2 will become CAD $33.2
ExternalCustomer table
|
Column Name |
Data type |
Sample data |
|
CustomerID |
NUMBER |
1 |
|
CustomerName |
VARCHAR2(24) |
Roger Waters |
|
PhoneNumber |
VARCHAR2(14) |
9058822222 |
|
Balance |
NUMBER(8,2) |
3200.12 |
Customer Table
|
Column Name |
Data type |
Sample data |
|
CustID |
NUMBER |
1 |
|
CustFirstName |
VARCHAR2(12) |
Roger |
|
CustLastName |
VARCHAR2(12) |
Waters |
|
CustPhoneNum |
VARCHAR2(18) |
(905) 882-2222 |
|
CustBalance |
NUMBER(8,2) |
3200.00 |
1a)
create or replace trigger custBalanceTrigger
After insert or update
on ExternalCustomer
for each row
begin
if :NEW.Balance < 100 then
update Customer set CustBalance =
100 where CustID = :new.CustomerID;
end if;
end;
1b)
create or replace function Balance_Format(inArg number)
return varchar2 is inStr varchar2(100)
begin
inStr = concat('CAD $',
to_char(inArg));
return inStr;
end;
1a) Develop a trigger that will set CustBalance in Customer table to 100 if the balance...
SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...
I need help for SQL homework.
the question:
the code for part 1,2:
drop table Customer;
drop table Company;
drop table Cruise;
drop table TravelAgent;
drop table Reservation;
drop sequence customerID_seq;
drop sequence cruiseID_seq;
drop sequence travelAgentID_seq;
drop sequence reservationID_seq;
create table Customer(
customerID number,
firstName varchar2(15),
lastName varchar2(15),
address varchar2(30),
phone number(10) not null,
age number(3),
Constraint Customer_PK Primary Key (customerID),
constraint Customer_unique unique (firstName,lastName,phone),
constraint Customer_check check(phone is not null)
);
create sequence customerID_seq
start with 1
increment...
--* BUSIT 103 Assignment #3 DUE DATE : Consult course calendar /* You are to develop SQL statements for each task listed. You should type your SQL statements under each task. You should always create an alias for any derived fields. Add a sort that makes sense for each query. */ USE AdventureWorksLT2012; --1. Build a single column of data in which...
* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...