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:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old February 2nd, 2004, 03:01 AM
silverdream silverdream is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 silverdream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Using truncate command inside stored procedures

Hi All,

This is my first post here . Here is my question..

I have created a table in oracle and inserted data into it. Now i created a stored procedure which truncates the table.

Here is the command

TRUNCATE TABLE tablename

I am working on the same schema so i am the owner for all these objects.

I am getting the following error when i try to compile the stored procedure from TOAD.


PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:

:= . ( @ % ;
The symbol ":= was inserted before "TABLE" to continue.


And i am not an expert in oracle, so kindly be as descriptive as possible .

Thanks for your help in advance.

Silverdream

Reply With Quote
  #2  
Old February 2nd, 2004, 04:33 AM
silverdream silverdream is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 silverdream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried assigning the truncate statement to a string and performed an EXECUTE IMMEDIATE.

and it works

Have another question

I need to copy huge amount of data from table 'a' to table 'b'.
Is there any quick way to do something like this?

Thanks

silverdream

Last edited by silverdream : February 2nd, 2004 at 04:35 AM.

Reply With Quote
  #3  
Old February 2nd, 2004, 02:54 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
You can copy data from one table to another by using one of following method, I assume that table structure of both tables are identical and thier datatypes as well or atleast should be compatible.

Method 1:
------------
as long as you are not tryinh to copy long or bfile datatypes and the database is same, the following command suppose to work. <schemaname> is optional, if you are copying data of one table to another in the same schema.

SQL>insert into table b (select * from schemaname.a)
/

Method 2:
------------
If your databses are different then first create the databse link to make use <Method 1>, all restriction will be applied.

SQL>create public database link scott.com
2>connect to scott identified by tiger
3>using 'ORCL'
/
If you dont want to make a public database link, omitt the public keyword from the above command.
now use the <method1> as follows:

SQL>insert into table b (select * from a@scott.com)

OR

SQL>COPY FROM scott/tiger@ORCL -
TO scott/tiger@ORCL2 -
REPLACE b -
USING SELECT * FROM a
/
copy command will replace the table if it is already exist and keep the column names and thier data types identical to source table.


Regards,


<copy> command create the table in your schema itself, and keep the datatype of each column identical



SQL>Copy

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Using truncate command inside stored procedures


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway