Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2011
    Posts
    12

    Red face Unanswered: 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.

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    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.

  3. #3
    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,

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •