Alex
Alex

Reputation: 1733

Stored Procedure Insert (Select and Values)

I'm looking to have a stored procedure that will:

How do I approach this?

CREATE OR REPLACE PROCEDURE TEST AS 
BEGIN

select ID from TABLE A;


INSERT INTO TABLE B
    (
    created_date,
    created_by,
    ID
    )
VALUES ('sysdate', '1', 'RESULTS FROM SELECT QUERY');
END TEST;

Not sure how to merge static data ('sysdate' and '1') with results from a query.

Upvotes: 0

Views: 2166

Answers (1)

sgeddes
sgeddes

Reputation: 62861

No need for 2 separate queries. This should work with INSERT INTO SELECT:

INSERT INTO TABLEB
    (
    created_date,
    created_by,
    ID
    )
SELECT 'sysdate', '1', id
FROM TABLEA

Upvotes: 2

Related Questions