How to use INSERT in EXEC SQL ...... ENDEXEC ?

Hi,
The following code;
DATA: BEGIN OF str_insert,
        a(3) TYPE c,
        b(3) TYPE c,
      END OF str_insert.
EXEC SQL.
  SET CONNECTION DEFAULT
ENDEXEC.
str_insert-a = 'a'.
str_insert-b = 'b'.
EXEC SQL.
INSERT INTO ZSAP  VALUES :str_insert
ENDEXEC.
The Structure of the ZSAP table (There is no data in ZSAP);
A CHAR 3 (Primary Key)
B CHAR 3
I cannot instert a record to this table it throughs the following error;
Runtime Errors         DBIF_DSQL2_SQL_ERROR  
Exceptn                CX_SY_NATIVE_SQL_ERROR
How could use a structure to insert values into ZSAP?
Thanks,
Kishan

Hello..
  loop at T_PC.
    loop at T_PCD .
      at new NUMREFERENCIA.
        exec sql.
         INSERT INTO tblPolizaContableR3
            (LibroMayor, PeriodoContable, Prefijo, NumReferencia,
            Fecha, FuenteDiario, ComentarioPoliza, Moneda,
            TipoCambio, RefExternaID1, RefExternaID2, RefExterna1,
            RefExterna2, DescRefExterna)
         VALUES (:T_PC-LIBROMAYOR, :T_PC-PERIODOCONTABLE,
          :T_PC-PREFIJO, :T_PC-NUMREFERENCIA, :T_PC-FECHA,
          :T_PC-FUENTEDIARIO, :T_PC-COMENTARIOPLIZA, :T_PC-MONEDA,
          :T_PC-TIPOCAMBIO, :T_PC-REFEXTARNAID1, :T_PC-REFEXTERNAID2,
          :T_PC-REFEXTERNA1, :T_PC-REFEXTERNA2, :T_PC-DESCREFEXTERNA)
        endexec.
      endat.
        exec sql.
         INSERT INTO tblPolizaContableDetR3
            (LibroMayor, PeriodoContable, Prefijo, NumReferencia,
            Partida, Cuenta, CuentaIMSA, CCostoIMSA,
            Cargo, Abono, ComentarioPartida)
         VALUES (:T_PCD-LIBROMAYOR, :T_PCD-PERIODOCONTABLE,
          :T_PCD-PREFIJO, :T_PCD-NUMREFERENCIA, :T_PCD-PARTIDA,
          :T_PCD-CUENTA, :T_PCD-CUENTAIMSA, :T_PCD-CCOSTOIMSA,
          :T_PCD-CARGO, :T_PCD-ABONO, :T_PCD-COMENPARTIDA)
        endexec.   
    endloop.
Hope this help you.
Regards, Gustavo Estrada

Similar Messages

  • How to use INSERT query ?

    Frenz,
    I have created one internal table and i am doing loop on it like...
    Loop at it_data into wa_data.
    Endloop.
    I want to insert some data into table zdata.
    How to use INSERT records on this data base table?
    Give me one example.
    Regards,
    RH

    Hi,
    explain better what you want....
    Do you want to change data in an existing raw?
    Loop at tb_data into wa_data.
    wa_data-field1 = 'jsahdu'.
    modify tb_data from wa_data.
    endloop.
    If you want to add raws you use APPEND statement.
    In the end you'll modify your table zdata from the internal table tb_data:
    MODIFY zdata FROM TABLE tb_data.
    Using modify you change raws basing on primary keys. If a raw doesn't exist it will be inserted.
    Regards

  • How to use OEM to moniter sql server 2000

    Hi,
    I need to learn How to use OEM to moniter sql server 2000.
    Can anyone help me and give me some website or documents
    to read?
    So I can learn to do this job.
    Thanks.

    See Note 115302.1 in Metalink.oracle.com
    in how to use OEM Diagnostic pack addon for SQL Server
    Or search for
    oem "user events"
    to build your own monitor script.

  • How to use Java with PL/SQL commands to send an email with attachment

    Apologizes in advance if this is the wrong place to ask the question.
    I need to use Java with PL/SQL commands to send an email with attachment. My java application runs from the command line and does some magic to gather info from an Oracle 11g db. If the DB has sendmail configured, I'd like to send the results of the data gathering as an attachment to the email addresses. I'm not sure how to do this. I've been reading up on on PL/SQL can send email with UTL_SMTP - with attachments. I'm just not sure how to translate that into being triggered by my Java application. Any suggestions or pointers on what I should read would be appreciated.
    Background - I've been programming in Java for 10+ years, but this is my first time using databases. I also have been on these forums for a long time, but lost my profile when it was switched to Oracle.
    Thanks for all help.

    user13726880 wrote:
    The original requirements were put together and given to me, an Oracle newbie. They expected the Java app to use something intrinsic to Oracle and Unix sendmail. To solve my problem, I use a JDBC connection to run some SQL commands. I take that data, format it and send the results by email to the user. By default the requirement is to send it as an HTML attachment using Unix 'sendmail'. So I do that using Runtime exec. I have also added JavaMail functionality as an alternative to sendmail. It works great and as expected.Sounds like a reasonable solution.
    Note however that PL/SQL itself can send email. And PL/SQL can call unix sendmail too.
    However myself I would have done it in java with JavaMail.

  • GRANT statements in EXEC SQL/ENDEXEC

    Hello, All!!
    Can someone please advise if this is possible in ABAP? Sample code is:
          exec sql.
            GRANT SELECT ON :tabname TO 'DB_ROLE'
          endexec.
    I am getting a ORA-00903 error, the trace file is showing "GRANT SELECT ON :A0  TO 'OWB_BI_READONLY';"
    Please advise ASAP; points guaranteed for helpful answers.
    Best Regards,
    Reenal

    Hi Reenal,
    Try using the below code:
      data: zsql type ref to CL_SQL_STATEMENT.
      CREATE OBJECT ZSQL.
      tabname = <i>tablename</i>.
      data: lv_state(200),
            lv_strstate type string.
      concatenate
            'GRANT SELECT ON'
            tabname
            'to OWB_BI_READONLY'
            into lv_state separated by space.
      lv_strstate = lv_state.
      translate lv_strstate to upper case.
      TRY.
          CALL METHOD ZSQL->EXECUTE_DDL
            EXPORTING
              STATEMENT = lv_strstate.
        catch CX_SQL_EXCEPTION INTO exc_ref.
          error_text = exc_ref->get_text( ).
          MESSAGE error_text TYPE 'I'.
      ENDTRY.

  • How to use Image field in SQL-7 for curvs

    I sampling data from a NI-card. There will be a lot of data so I thought I should use Image-field in SQL-7 to save the hole curve. How do you do that?

    I would suggest looking into the Database Connectivity Toolset. It has complete SQL functionality and uses ADO to connect to many types of databases. I have it and it comes with example programs which demonstrate how to write to and read from databases using SQL.
    J.R. Allen

  • How to use parameters in oracle SQL script????

    Right now I am writing a SQL script to create a schema and build the objects of this schema....
    I use a .net winform program to run sqlplus to parse this sql script ...
    The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
    So, how to use parameter in SQL script ...........
    Are there some example scripts in oracle home directory for me to refer to????

    Hi,
    UNISTD wrote:
    thanks .....
    what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
    CREATE USER  &1 ...a bind variable won't work.
    "DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
    "DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
    ACCEPT sets a substitution variable with user interaction.
    And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
    sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
    The foloowing works, but, as you can see, it's ugly.
    "DEFINE 1" display a message like
    DEFINE 1            = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
    SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
    The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
    So you can use a script like this:
    --     This is  DEFINE_DEFAULT.SQL
    SPOOL     got_define_txt.sql
    DEFINE     &dd_old
    SPOOL     OFF
    COLUMN     dd_new_col     NEW_VALUE     &dd_new
    WITH     got_define_txt     AS
         SELECT  q'[
              @got_define_txt
    ]'               AS define_txt
         FROM    dual
    SELECT     CASE
             WHEN  define_txt LIKE '%=%'
             THEN  REGEXP_REPLACE ( define_txt
                               , '.+"
    ([^"]*)
                         , '\1'
             ELSE  '&dd_default'
         END        AS dd_new_col
    FROM     got_define_txt
    {code}
    and start your real script, ssss.sql, something like this:
    {code}
    DEFINE          dd_new     = sv1
    DEFINE          dd_old     = 1
    DEFINE          dd_default     = FOO
    @DEFINE_DEFAULT
    DEFINE          dd_new     = sv2
    DEFINE          dd_old     = 2
    DEFINE          dd_default     = "Testing spaces in value"
    @DEFINE_DEFAULT
    {code}
    when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
    Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
    Here's how it works:
    Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query.  That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default.  The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
    Notice that the paramerters to define_default.sql must be passed as global varibales.
    Why didn't I just use arguments, so that we could simply say:
    {code}
    @DEFINE_DEFAULT  sv1  1  FOO
    {code}
    ?  Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
    I repeat: there must be a better way, but I'm sorry, I don't know what it is.
    I usually don't do the method above.  Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
    For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
    {code}
    @ssss  ?  par2  ?
    {code}
    and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value.  The use has  to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to use INSERT INTO ALL statement in jdbc prepared statement with beans

    Kindly give me some example that how we can use "INSERT INTO ALL STATEMENT" in jdbc prepared statement inside a jsf bean?
    Actually i want to take employee id's of present employees using single jsf page and using one textbox for each employee id.
    How can i use INSERT INTO ALL statement to achieve this?
    Following is my code snippet.
    AttendanceBean.java:
    public class AttendanceBean {
    private int atteid;
    private String attdname;
    private int attday;
    private int attmonth;
    private int attyear;
    public static Connection getAttConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:globldb3";
    String username = "scott";
    String password = "tiger";
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
    public String addAttendance(){
    Connection conn = null;
    PreparedStatement pstmt = null;
    boolean committed = false;
    try {
    conn = getAttConnection();
    conn.setAutoCommit(false);
    String query = "INSERT ALL INTO attendance VALUES (?,?,?,?,?)";
    pstmt = conn.prepareStatement(query);
    pstmt.setInt(1,this.atteid);
    pstmt.setString(2,this.attdname);
    pstmt.setInt(3,this.attday);
    pstmt.setInt(4,this.attmonth);
    pstmt.setInt(5,this.attyear);
    pstmt.executeUpdate();
    conn.commit();
    conn.setAutoCommit(true);
    committed = true;
    return "home.xhtml";
    } catch (Exception e) {
    e.printStackTrace();
    return "CRM.xhtml";
    } finally {
    try{
    if (!committed) conn.rollback();
    if (pstmt != null) pstmt.close();
    if (conn != null) conn.close();
    }catch(Exception e){
    e.printStackTrace();
    }

    Check this program for some info on Push buttons:
    1-DEMO_DYNPRO_PUSH_BUTTON
    2-DEMO_DYNPRO_MODULE
    3-DEMO_DYNPRO_ON_CONDITION
    Suppose Your screen is 101
    Then in that screen create one push button and assign it a function code.
    Now in the PAI of the 101 screen
    Create Module for user command
    Inside that module checc the sy-ucomm if sy-ucomm eq <Function code of your push button>
    Insert the values in database.
    *& Module USER_COMMAND_0101 INPUT
    process after input for screen 0101 *
    MODULE USER_COMMAND_0101 INPUT.
    CASE OK_CODE.
    WHEN 'SAVE'.
    *Insert the values here
    WHEN 'DISP'.
    ENDCASE.
    CLEAR OK_CODE.
    ENDMODULE. " USER_COMMAND_0101 INPUT
    Regards
    Neha
    Edited by: Neha Shukla on Dec 3, 2008 1:02 AM
    Edited by: Neha Shukla on Dec 3, 2008 1:02 AM
    Edited by: Neha Shukla on Dec 3, 2008 1:06 AM

  • How to use Insert for mulit-values

    Can anyone help, I try to insert mulit-values using insert command. but keep getting error. here is the code.
    INSERT INTO PRODUCTS
    VALUES (
    'C','CABLE',39.95,
    'D','DSL',29.95,
    'U','DIALUP_56K',19.95);
    Thank you!

    The SQL you posted isn't valid, assuming that there are only three columns in your table. The type of insert statement you posted can only insert 1 row at a time.
    You could look into loading data into collections and using the bulk insert syntax to insert multiple values in a single statement. Please post to the PL/SQL forum if you need more assistance on this.
    Justin

  • Using #include or EXEC SQL include

    Hi
    I havent much worked with Pro C so I have question
    I need to modify a Pro C file to include a new lib,
    So is it better to use:
    EXEC SQL INCLUDE multibyte_chars.ph;
    OR
    #include "multibyte_chars.ph"Are both basically doing the same thing?
    Please reply

    Hi,
    Pro C is not a Sun Studio product.
    Searched google.com, found this Oracle FAQ: Pro *C:
    http://www.db.cs.ucdavis.edu/public/oracle/faq/proc.html
    Rose

  • How to use Runtime.getRuntime().exec() in JSP? is it works in JSP or not

    Hi to all,
    i want run a .exe file from JSP file. In java i am able do this, using Runtime.getRuntime().exec().
    but same thing, when i trying with JSP it is not working?
    plz let me is there any other ways to do it..

    It depends, usually (ie in an J2EE container) you're not allowed to access files or the runtime environment, by definition. What do you wan't to achieve with the exe?
    --olaf                                                                                                                                                                                                                                                                                                                                                           

  • How to use substitution variable in sql

    Hai All
    I have two tables Rgpmain and Rgpitem the fields are
    Rgpmain
    unitid,periodid, docno, vendcode ,vendname, part_taken_by and .....
    Rgpitem
    unitid, periodid, docno, partno, partname .... And i need to give some values in runtime using sub variable
    i need to to four values in sub function and i will give one value and i need the result of one variable
    The qurey will like this
    Select * from rgpmain m, rgpitem i where unitid=1 and periodid=14 and m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and vendcode ='&p_vendcode'
    Or
    m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and vendname like '&p_vendname%'
    Or
    m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and partname like '&p_partname%'
    or
    m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and partno ='&p_partno'
    This is my query
    And while i am executing there are four options showing to enter..
    My need is i need enter only one field Ie vendcode and execute the vendcode like ABC01 then i need the only
    the result that belong to vendcode ABC01 but my query giving all the rows
    Pls tell me what is wrong with my query
    Thanks In Advance
    Srikkanth.M

    Hai
    Thanks Man i under stood that nv2 if 1 col is null then it will return 2 col or els 1 col but i working with large
    database and i need four or five column using sub. Pls tell whats went wrong with my query when i am executing
    one by one at the first time its works fine but next time it returns 1000 rows. pls tell me how to use four or five columns
    Regards
    srikkanth.M

  • [DW 8.02 + PHP] how to use variables in advanced SQL queries

    Hi all,
    I can't find a way to use variables in an SQL query after
    updating
    dreamweaver 8.02.
    I always get error messages that says: 'missing variable
    type:myvariablename', undefined#myvariablename... and so on.
    What is the correct way to use variables?
    I usually set a variable in a PHP statement (example: <?
    $today=date('Y-m-d'); ?>)
    and then I compare this variable in the SQL query.
    What is the correct syntax for variable in DW 8.02 in
    advanced SQL
    queries?
    TIA
    tony

    sweetman wrote:
    > I'm editing a website created with DW 8.01 and MX
    Kollection.
    >
    > I updated DW to 8.02 and now I can't edit an existing
    SQL query.
    > I always get an error message 'Missing variable type'
    and I can't go
    > on.
    InterAKT released a new version of Kollection to cope with
    the 8.0.2
    changes. AFAIK, you should be able to download the updated
    version from
    your InterAKT account area.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • How to use sets in PL/SQL

    Hi all,
    I want to know how to implement algebraic sets in PL/SQl.
    I mean for example if there is a table R(A,B) where A is aprimary key having the data :-
    {(1,2),(2,1),(2,3),(3,1)}
    i want to have a data type that represents sets of data corresponding to attribute B.
    i.e the data type should have the value {1,2,3}
    Thanks.

    Not sure that I understand correctly.. and how you want to fit PL/SQL into this.
    Sets are best handles as Oracle tables. The best language to deal with sets are SQL. So to get the results you want should be a simple:
    SELECT DISTINCT b FROM table_r ORDER BY 1
    The results of this can be a cursor that needs to be stepped (fetch) through.
    The results can be bulk collected into a dynamic array, e.g.
    create or replace type TArray is table of number;
    And then in PL/SQL:declare
      array TArray;
    begin
      SELECT DISTINCT b BULK COLLECT INTO array FROM table_r ORDER BY 1;
    end;The array object will now contain TArray(1,2,3).

  • How to use hints in PL/SQL

    Hi,
    If I want to use hints in PL/SQL procedure, it is valid to write it this way:
    begin
    update /*+  INDEX(opp DIM_OPP_REFDB_IDX) */
            scott.rec_dim_opportunity opp
            set opp.mp_opportunity_re ....
    endI doubt when I tried it that the optimizer didn't actually use the index.
    Thanks in advance.
    Oracle 10g R1
    Windows 2003 32-bit

    the table is of 90MB and when the UPDATE statement is used in SQL, the explain plan output shows that the index is used.
    When I execute it from a procedure, the Current Statement show in TOAD doesn't show that the index is used and the update takes forever. Explain plan of the statement (as show in TOAD) shows that full table scan is being used.

Maybe you are looking for

  • Can I download App Store purchases as an installer?

    I have limited and slow internet at home but access to much faster unlimited internet at work.  Downloading 1GB+ sized apps will just take forever at home, not to mention putting a big dent in my monthly download limit.  Unfortunately I cannot take m

  • N95 fw minor update

    hi apparantly there is a minor update for the nokia n95 something called a minor data pack(????)update(MCU SW 10.0.18) going on rumour i visited CPW today and told them i wanted an update for my phone they took it and told me to return for it the end

  • Input an electric guitar

    How can I input my electric guitar into the garage Band programm? When I input it I hear thru the Imac Mic, not with the USB input. I've an Imic. I also put the preferences thru the USb Imic, nut no sound... I try thru my Boss BR1200CD and with the R

  • Downloading a different web browser

    To Whom it may Conern, I wanted to inquire can one download another web browser on the iphone4,other than having Safari.perhaps firefox which is what iuse on my desktop.Or perhaps the one and only google chrome which i love also.But Safari i really d

  • MSS 60.1.19 - Salary Development iView - Internal error wh reading the data

    Hi guys! I face the problem of an iView Salary Development. I get error: Internal error while reading the data. I found a thread with the same problem, but there is no solution. Did anyone of you solve this problem? Thanx for answers! Peter