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 August 18th, 2005, 08:10 AM
dangerousjohnny dangerousjohnny is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 109 dangerousjohnny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 25 m 18 sec
Reputation Power: 6
Oracle PL/SQL help

Hello all,

I'm just wondering if you could help me with some Oracle SQL syntax script I'm trying to write. Basically, I have 3 .dbf table files that I need copied into an oracle database with some additional stuff done to them.

1) I need to first copy these databases as is into the Oracle DB
2) Then I need to copy certain values from the tables into newly created tables with different column names and some extra fields added for use later
3) I also need to fix some data in the tables (ie year 2004 is recorded as A4)

I just need the basic syntax how to do these commands, any help appreciated!

Reply With Quote
  #2  
Old August 18th, 2005, 05:24 PM
michaeljshannon michaeljshannon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 26 michaeljshannon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 38 m 15 sec
Reputation Power: 0
1. There are several ways to accomplish this step. Perhaps the most straight-
forward is to copy your .dbf into a text file and then use SQLLDR to import it.

If memory serves correct, something like
USE MY_FILE.DBF
COPY TO NEW_FILE SDF

Then you need to create a SQLLDR script to load this newly created text file.

This is a bit involved, your best bet is to check any Oracle book for the specifics.

2. This is easy:

CREATE NEW_TABLE AS
SELECT COL1 COL_NAME1,
COL2 COL_NAME2
FROM OLD_TABLE;

You can add columns to the new table:

ALTER TABLE NEW_TABLE ADD COL3 VARCHAR2(20);

3. UPDATE NEW_TABLE
SET COL5 = '2004'
WHERE COL5 = 'A4'

These are just generalizations. Your best bet is to print out the Oracle PL/SQL documentation and do some reading.

Reply With Quote
  #3  
Old August 19th, 2005, 08:25 AM
dangerousjohnny dangerousjohnny is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 109 dangerousjohnny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 25 m 18 sec
Reputation Power: 6
thank you for your reply... is there a way to make the code reusable? This script will be run over and over again, the only thing changing will be the table name prefixes

Reply With Quote
  #4  
Old August 19th, 2005, 12:33 PM
elkehinze's Avatar
elkehinze elkehinze is offline
The Queen of Typos
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Sep 2004
Location: Two Rivers, WI
Posts: 1,151 elkehinze User rank is Sergeant Major (2000 - 5000 Reputation Level)elkehinze User rank is Sergeant Major (2000 - 5000 Reputation Level)elkehinze User rank is Sergeant Major (2000 - 5000 Reputation Level)elkehinze User rank is Sergeant Major (2000 - 5000 Reputation Level)elkehinze User rank is Sergeant Major (2000 - 5000 Reputation Level)elkehinze User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 15 h 6 m 40 sec
Reputation Power: 50
Send a message via ICQ to elkehinze Send a message via AIM to elkehinze Send a message via MSN to elkehinze Send a message via Yahoo to elkehinze
Quote:
Originally Posted by dangerousjohnny
thank you for your reply... is there a way to make the code reusable? This script will be run over and over again, the only thing changing will be the table name prefixes


Do you have perl on your system? You could set up a cron job using a perl dbi to do the updates to the tables for you.

Reply With Quote
  #5  
Old August 19th, 2005, 01:03 PM
dangerousjohnny dangerousjohnny is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 109 dangerousjohnny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 25 m 18 sec
Reputation Power: 6
no, unfortunately no perl installed

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle PL/SQL help


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 4 hosted by Hostway
Stay green...Green IT