Insert Items with OPenquery Statment

I am linking to an Oracle server via my sql server and need to insert data into the oracle server
This is the data I need to put in the openquery statement where the statment has tripple xxx's.  But I do get how to get that data in there.
Select      ActualVal,
            TargetVal,
            ToleranceVal,
            Bench1,
            Bench2,
            Bench3,
            Bench4,
            Bench5
From      CognosMetrics where bitDB = 1
INSERT OPENQUERY(METRICS, 'INSERT INTO KPI_USER_VALUE (KPI_USER_VALUE_SID,
                            KPI_SID,
                            TIME_PERIOD_SID,
                            UNIT_LOOKUP_ID,
                            ACTUAL_VALUE,
                            TARGET_VALUE,
                            TOLERANCE_RAW,
                            BENCHMARK_VALUE,
                            BENCHMARK2_VALUE,
                            BENCHMARK3_VALUE,
                            BENCHMARK4_VALUE,
                            BENCHMARK5_VALUE,
                            SECURITY_ITEM_SID,
                            CREATED_DT,
                            PROCESSED)
SELECT   
(select max(kpi_sid) + 1 from (select kpi_sid from kpi union select kpi_user_value_sid from kpi_user_value)) as kpi_sid, KPI_SID, 'xxxTIME_PERIOD_SID', KCC.UNIT_LOOKUP_ID, 'xxxACTUAL_VALUE', 'xxxTARGET_VALUE', 'xxxTOLERANCE_RAW', 'xxxBENCHMARK_VALUE', 'xxxBENCHMARK2_VALUE', 'xxxBENCHMARK3_VALUE', 'xxxBENCHMARK4_VALUE', 'xxxBENCHMARK5_VALUE', 21, sysdate, 'N'
     FROM      KPI KPI
            INNER JOIN
               KPI_CLASS_CURRENCY KCC
            ON KPI.KPI_CLASS_SID = KCC.KPI_CLASS_SID
               AND KCC.CURRENCY_CD = 'USD'
    WHERE   KPI.KPI_SID = 9573
	')

Open in new window

kdeutschAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Máté FarkasDatabase Developer and AdministratorCommented:
You should use simple SELECT * FROM ... query in the OPENQUERY statement. SQL Server will map the "remote insert" operator thow this select statement. For example:
INSERT INTO OPENQUERY(METRICS, 'INSERT * FROM KPI_USER_VALUE')(KPI_USER_VALUE_SID, KPI_SID)
SELECT kpi_user_value_sid, kpi_sid FROM KPI

--OR

INSERT INTO OPENQUERY(METRICS, 'INSERT * FROM KPI_USER_VALUE')(KPI_USER_VALUE_SID, KPI_SID)
VALUES(123, 321)

Open in new window

0
Máté FarkasDatabase Developer and AdministratorCommented:
Sorry
INSERT INTO OPENQUERY(METRICS, SELECT * FROM KPI_USER_VALUE')(KPI_USER_VALUE_SID, KPI_SID)
SELECT kpi_user_value_sid, kpi_sid FROM KPI

--OR

INSERT INTO OPENQUERY(METRICS, 'SELECT * FROM KPI_USER_VALUE')(KPI_USER_VALUE_SID, KPI_SID)
VALUES(123, 321)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.