Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 5th, 2006, 03:16 PM
beirti's Avatar
beirti beirti is offline
Contributing? HA!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: In the office...
Posts: 244 beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 m 2 sec
Reputation Power: 20
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;

Reply With Quote
  #2  
Old July 6th, 2006, 07:02 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 8,067 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 4 Weeks 2 h 10 sec
Reputation Power: 281
Quote:
Originally Posted by beirti
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.
Could you be so kind to share your solution with others?
Quote:
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..
Let me ask a more general question, why can't you use some reporting tool to produce formatted reports from Oracle? There are many free ones that work great, like JasperReports + iReport

Reply With Quote
  #3  
Old July 6th, 2006, 10:18 AM
beirti's Avatar
beirti beirti is offline
Contributing? HA!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: In the office...
Posts: 244 beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level)beirti User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 m 2 sec
Reputation Power: 20
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > DBMS_OUTPUT questions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT