|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
DBMS_OUTPUT questions
Hi, I've answered my own question from the post below about 'pulling bits and pieces from tables' if a moderator would be kind enought to delete that.
What I'm trying to do within my script is to create new pages between each report and also to use tabs within the DBMS_OUTPUT commands.. See the code below for what I mean. If you want the source tables, give a shout. It's all from examples Code:
SPOOL c:\oraclescripts\customer_report.txt
DECLARE
v_temp_id NUMBER(6);
v_temp_total NUMBER(10,2);
CURSOR c_cus_details IS
SELECT customer_id,
Name,
Phone_number
FROM customer
WHERE salesperson_id =
(
SELECT employee_id
FROM employee
WHERE last_name = 'SHAW'
)
AND customer_id IN
(
SELECT customer_id
FROM sales_order
WHERE EXTRACT(YEAR FROM order_date) = '1990'
)
;
CURSOR c_order_details IS
SELECT customer_id,
order_date,
ship_date,
total
FROM sales_order
WHERE customer_id = v_temp_id
AND EXTRACT(YEAR FROM order_date) = '1990'
ORDER BY order_date
;
BEGIN
FOR cus_details IN c_cus_details
LOOP
v_temp_id := cus_details.customer_id;
v_temp_total := 0;
DBMS_OUTPUT.PUT_LINE('------------- Details --------------');
DBMS_OUTPUT.PUT_LINE('Customer ID: '||cus_details.customer_id);
DBMS_OUTPUT.PUT_LINE('Name: '||cus_details.name);
DBMS_OUTPUT.PUT_LINE('Phone: '||cus_details.phone_number);
DBMS_OUTPUT.PUT_LINE('-');
DBMS_OUTPUT.PUT_LINE('------------- Orders ---------------');
DBMS_OUTPUT.PUT_LINE('-');
--USE TABS ON NEXT LINE INSTEAD OF SPACES
DBMS_OUTPUT.PUT_LINE('-Order Date- -Ship Date- -Total-');
FOR order_details IN c_order_details
LOOP
DBMS_OUTPUT.PUT_LINE('-'||order_details.order_date||' '||order_details.ship_date||'
'||order_details.total);
v_temp_total := v_temp_total + order_details.total;
END LOOP;
DBMS_OUTPUT.PUT_LINE('- -------');
DBMS_OUTPUT.PUT_LINE('- '||v_temp_total);
DBMS_OUTPUT.PUT_LINE('- -------');
--MOVE OUTPUT TO NEW PAGE. SPECIFIED PAGE LENGTH of XX lines. WITH PAGE HEADERS
END LOOP;
END;
/
SPOOL OFF;
|
|
#2
|
||||
|
||||
|
Quote:
Quote:
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) |
|
#3
|
||||
|
||||
|
Call it a penchant of mine to struggle at the hard way of doing things.
As regards the answer to pulling bits and pieces from different tables, that's it above. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > DBMS_OUTPUT questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|