Skip to Content
author's profile photo Former Member
Former Member

Native SQL - Insert syntax

Hi all,

Can any body give me syntax for Native SQL command 'INSERT' with example.

Thanks & Regards,

Seshagiri.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 30, 2007 at 12:41 PM

    Hai sheshgiri,

    Here is the complete code( with syntax).

    Go through it.

    REPORT Z_NATIVE_SQL.

    PARAMETERS p_carrid TYPE spfli-carrid.

    DATA:

    carrid TYPE spfli-carrid,

    connid TYPE spfli-connid,

    cityfrom TYPE spfli-cityfrom,

    cityto TYPE spfli-cityto.

    EXEC SQL.

    OPEN dbcur FOR

    SELECT distinct carrid,connid,cityfrom, cityto

    FROM spfli

    WHERE carrid = :p_carrid

    ENDEXEC.

    DO.

    EXEC SQL.

    FETCH NEXT dbcur INTO :carrid, :connid, :cityfrom, :cityto

    ENDEXEC.

    IF sy-subrc <> 0.

    EXIT.

    ELSE.

    WRITE:

    / carrid,connid, cityfrom, cityto.

    ENDIF.

    ENDDO.

    EXEC SQL.

    CLOSE dbcur

    ENDEXEC.

    Hope this helps you.

    Regds,

    Ram chary.Pammi

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi seshagiri,

      1. If you sap server is UNIX/AIX operating system,

      then probably this kind of secondary database connection

      to MSSQL Server (Microsoft OS)

      2. is not possible at present.

      3. Bcos the dll/system files required,

      are not provided by SAP for such connection.

      regards,

      amit m.

  • Posted on Apr 30, 2007 at 01:50 PM

    Hi,

    Please check this sample code.

    *Create new HWID
            EXEC SQL.
              INSERT INTO CTXTB_PACKDATA
                     (HWID, CODE, SRS, AM, UCID, STOPLEVEL)
              VALUES (:LWA_HWID, :LWA_CODE, :LWA_SRS, :LWA_AM, '0', '0')
            ENDEXEC.
    

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Thanks for quick info.

      Can you please give me source code with Native SQL commands for following ABAP program:

      ******************************************************************************************

      Hi,

      My task is to transfer some data from SAP(ECC 6.0) to another NON-SAP server (MS-SQL database system).I have the limitation that I should not write code in MS-SQL system.

      My code in ABAP is as shown below:

      ********************************************************

      REPORT ZDATA_TEST_GIRI4.

      data: begin of it_customer occurs 0,

      kunnr like kna1-kunnr, “ CHAR - 10

      name1 like kna1-name1, “ CHAR - 35

      end of it_customer.

      select kunnr

      name1

      up to 5 rows into table it_customer

      from kna1.

      *--Code for data transfer using Native SQL statements

      *--(Yet to be written...)

      (Some information):

      In the MS-SQL system,the

      target table name is : customers

      Fields are:

      CustomerNo - Data type - LONG

      CustomerEName - Data type - TEXT(35)

      (1)Can you please,give me the Native SQL statements(preferably the source code),like data declarations,insert commands for data transfer from it_customer to target table ‘customers’.

      (2)And data retrieval statements to cross check whether data is inserted sucessfully or not?

      Note: Also please tell me how to cross check that the connection is correctly established between SAP and MS-SQL servers?

      Thanks & Regards,

      Seshagiri.M.

  • author's profile photo Former Member
    Former Member
    Posted on Apr 30, 2007 at 02:57 PM

    Native SQL syntax depends on your database system. So, what database do you use?

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 11, 2007 at 11:59 PM

    I have to insert some 100 records from SAP ECC 6.0 to another legacy system whose database is oracle.

    I am able to insert one record, but i am not sure of inserting all the 100 records.

    How do i loop etc in between exec sql and endexec.

    NOTE: I have the data in sap in internal table and custom table as well.

    INSERT INTO KM.CIP_AGREEMENT_DETAILS

    ( SLC_ID, AGREEMENT_ID, AGREEMENT_TYPE_ID, AGREEMENT_START_DATE, AGREEMENT_END_DATE )

    VALUES ( 0000000000955, 0000000033555, 005, '01-JAN-2007', '02-03-2008' )

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.