If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > SP to copy data from one table to another

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-30-11, 03:49
SoftSpot SoftSpot is offline
Registered User
 
Join Date: Oct 2011
Posts: 12
Red face SP to copy data from one table to another

Hi,

I need to copy data from one table to a newly created table. I tried the following Stored Procedure but could not get the syntax correct.

CREATE PROCEDURE "MmsBuyout"

INSERT INTO MmsPo (documentnumber,itemcode,ddate,unitused,descriptio n,qty,unitprice,taxamt,mms,buyout,budget) values
SELECT documentnumber,itemcode,ddate,unitused,description ,qty,unitprice,taxamt,
0,1,0 FROM historylines WHERE documentnumber >= 'PN105922' and itemcode like 'BO%'

Is there perhaps an easier way in P-Sql. I need to run it only once.
Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 10-30-11, 08:45
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
What version of PSQL are you using?
What's the exact error?
Does the INSERT statement work outside of the stored procedure?

You might try:
Code:
INSERT INTO MmsPo (documentnumber,itemcode,ddate,unitused,descriptio n,qty,unitprice,taxamt,mms,buyout,budget) 
SELECT documentnumber,itemcode,ddate,unitused,description ,qty,unitprice,taxamt,
0,1,0 FROM historylines WHERE documentnumber >= 'PN105922' and itemcode like 'BO%'
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 10-31-11, 00:42
SoftSpot SoftSpot is offline
Registered User
 
Join Date: Oct 2011
Posts: 12
SP to copy data from one table to another

Hi

Thanks a million it worked.
I will have a Q on a trigger later today.

Regards,
Reply With Quote
Reply

Tags
stored procedure

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On