Native SQL using variables?

Hi folks,
Is it possible to assign a SQL query to a variable, and then using an OPEN statement to read the variable?
E.g.,
query TYPE STRING VALUE 'SELECT * FROM mytable'.
EXEC SQL.
      OPEN c1 FOR :query
ENDEXEC.

OK, I've tried to narrow this length of string down to the following:
data mystring type string.
"SELECT ... ... ... WHERE" ... and then "mystring" needs to be appended to the end of the SQL statement.
E.g., mystring could be " field1 = '1234' AND field2 = 'XYZ' "
Is this possible? Thanks in advance for reading.

Similar Messages

  • PL SQL using variable in SQL statement

    I am trying to execute several sql statements, that have the same format but different values. Does this
    mean I need a bind variable?
    ie
    select TO_CHAR ( (SYSDATE - 2), 'YYYY_MM_DD') from dual
    select TO_CHAR ( (SYSDATE - 4), 'YYYY_MM_DD') from dual
    select to_char(add_months(sysdate,-2*1) from dual
    When I try to put the values into a varaiable (date, varchar2 or number) I am getting a conversion
    error.
    Can somebody show me an example of how to do something like this? Or at least point me to the correct
    part of the documentation that provides and example. Pardon my syntax as I know it is incorrect
    val :=add_months(sysdate,-2*1
    select to_char(val) from dual
    Thanks in advance to all who answer

    Hi,
    840386 wrote:
    I am trying to execute several sql statements, that have the same format but different values. Does this
    mean I need a bind variable?No, you don't need a bind variable, though bind variables may be more efficient than using PL/SQL variables. I don't see where you're trying to use any varibables at all in your examples. Is it in place of the literals, such as 2 or 'YYYY_MM_DD'? You can use either bind varibales or PL/SQL variables in those places.
    ie
    select TO_CHAR ( (SYSDATE - 2), 'YYYY_MM_DD') from dual
    select TO_CHAR ( (SYSDATE - 4), 'YYYY_MM_DD') from dual
    select to_char(add_months(sysdate,-2*1) from dualIn PL/SQL, when you have a SELECT statement, you must specify what you want to do with the results. For example, a SELECT ... INTO statement:
    SELECT  AVG (sal)
    INTO    avg_salary
    FROM    scott.emp;There's usually no point in SELECTing from dual in PL/SQL. It's not an error, but it's simpler just to use an assignment statement.
    When I try to put the values into a varaiable (date, varchar2 or number) I am getting a conversion
    error.Post a complete procedure or anonymous block, including variable declarations, that shows exactly what you're trying to do.
    >
    Can somebody show me an example of how to do something like this? Or at least point me to the correct
    part of the documentation that provides and example. Pardon my syntax as I know it is incorrect
    val :=add_months(sysdate,-2*1Assuming val is a DATE, that's basically correct. You have unbalanced parentheses (there's a '(', but no matching ')' ), and you need a semicolon (';') at the end of the statement. Perhaps ');' just got cut off when you were posting this.
    select to_char(val) from dualAgain, SELECTing from dual is unnecessary, but if you had some way to catch the returned value, that would work.
    Usually, the reason why you need to call TO_CHAR is that you want a value in a particular format, which is specified in the 2nd argument to TO_CHAR. Calling TO_CHAR with only one argument is a possible mistake, but not something that would raise an error.
    Here's an example that works:
    SET     SERVEROUTPUT     ON
    DECLARE
         d     DATE;
         v     VARCHAR2 (30);
    BEGIN
         d := ADD_MONTHS (SYSDATE, -2);          -- -2 = (-2*1)
         v := TO_CHAR (d, 'DD-Mon-YYYY');
         dbms_output.put_line (v || ' = v');
    END;
    /Output (when run on March 13, 2011):
    13-Jan-2011 = v

  • How to use Native SQL in Toplink

    I am using toplink in my project, can you please some one help me how to create native sql using toplink.
    I have seen EntityManager interface having method createNativeQuery, but how to create instance of EntityManager

    import javax.persistence.EntityManager;within class, place
    protected EntityManager  entityManager;of course make it public, private, whatever you need.
    Then, in your method
    entityManager.createNativeQuery(....);R. Grimes

  • Use of native SQL-select statment

    hi,
    in my z-abap i use a native sql, saying the following:
    EXEC SQL.
      select agzdau into :gf_agzdau from APZD08/AG
                    where AGMAID = '77732' and
                          AGJAHR = 2008 and
                          AGMON  = 09 and
                          AGSPAL = 'ZASALD'
                          %_HINTS AS400 'HARD_CLOSE'
    ENDEXEC.
    before that i make a connection to the server where the table is stored.
    APZD08 is the library and AG is the filename (on a AS/400-machine)
    BUT: the file is not always in APZD08-lib, it depends on the employee.
    how can i make the lib-name and file flexible:
    i have tried it with
    select...............from :gf_file
    and i have put a value for gf_file before.
    but with that i got an SQL-error -104 when executing.
    i can't use a hostvariable there it seems.
    any ideas ?
    reg, Martin

    Hi.
    I would use ADBC instead of EXEC SQL. Then you can concatenate the SQL statement in the way you want it. But in that case you should use host variables in the where condition to get better performance.
    So something like the following (untested, no syntax check yet, pseudo code...):
    DATA: p_con_name   TYPE dbcon-con_name,
          p_con_ref    TYPE REF TO cl_sql_connection,
          p_stmnt      TYPE REF TO cl_sql_statement,
          p_result_set TYPE REF TO cl_sql_result_set,
          query        TYPE string.
    p_con_ref = cl_sql_connection=>get_connection( 'YOURCON' ).
    LOOP AT it_employees
    * CASE your logic
    CONCATENATE 'select agzdau from '  table_name
                'where  AGMAID = ? and AGJAHR = ?'
           INTO statement SEPARATED BY SPACE.
    * ENDCASE
    TRY.
      p_stmnt = p_con_ref->create_statement( ).
      GET REFERENCE OF p_agamaid INTO p_paramref.
      p_stmnt->set_param( p_paramref ).
      GET REFERENCE OF p_agjahr INTO p_paramref.
      p_stmnt->set_param( p_paramref ).
      p_result_set = p_stmnt->execute_query( query ).
      GET REFERENCE OF gf_agzdau INTO p_resultref.
      p_result_set->set_param( p_resultref ).
      p_result_set->next( ).
      CATCH CX_SQL_EXCEPTION.
    * error handling needed!
      ENDTRY.
    ENDLOOP.
    p_con_ref->close( ).
    Oh, I was assuming that there is only one result. If there can be more (and better style anyway) do a while-loop until next( ) is different from zero.
    Best regards,
    Jan

  • Querying using Native SQL

    Hi Pals,
    I have a requirement which I would like to brief.
    I have an internal table with columns FIELD1 and FIELD2. For all the values in FIELD1 I have to query a table MSI(which does not form a part of the R/3 framework) through Native SQL statement and get the corresponding values for FIELD2.
    Could anybody suggest how I must proceed writing my statements between EXEC and ENDEXEC.
    Do I have to query the database table for each entry in my internal table or is it possible to use for all entries in my SQL statemnt.
    Your inputs would be highly appreciated.
    Thank You in advance.
    Regards,
    Gayathri N.

    Hai Gayathri
    check this document
    EXEC SQL.
    Addition
    ... PERFORMING form
    Effect
    Executes the Native SQL command enclosed by the statements EXEC SQL and ENDEXEC . In contrast to Open SQL , addressed database tables do not have to be known to the ABAP/4 Dictionary and the ABAP/4 program does not have to contain appropriate TABLES statements.
    Example
    Create the table AVERI_CLNT :
    EXEC SQL.
      CREATE TABLE AVERI_CLNT (
             CLIENT   CHAR(3)  NOT NULL,
             ARG1     CHAR(3)  NOT NULL,
             ARG2     CHAR(3)  NOT NULL,
             FUNCTION CHAR(10) NOT NULL,
             PRIMARY KEY (CLIENT, ARG1, ARG2)
    ENDEXEC.
    With Native SQL commands, passing data between an ABAP/4 program and the database is achieved using host variables . A host variable is an ABAP/4 variable prefixed by a "*" in the Native SQL statement.
    Example
    Display a section of the table AVERI_CLNT :
    DATA: F1(3), F2(3), F3(3).
    F3 = ' 1 '
    EXEC SQL.
      SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
             WHERE ARG2 = :F3
    ENDEXEC.
    WRITE: / F1, F2.
    To simplify the spelling of INTO lists in the SELECT command, you can specify a single structure as the target area as in Open SQL .
    Example
    Display a section of the table AVERI_CLNT :
    DATA: BEGIN OF WA,
            CLIENT(3), ARG1(3), ARG2(3),
          END OF WA.
    DATA  F3(3).
    F3 = ' 1 '
    EXEC SQL.
      SELECT CLIENT, ARG1 INTO :WA FROM AVERI_CLNT
             WHERE ARG2 = :F3
    ENDEXEC.
    WRITE: / WA-CLIENT, WA-ARG1.
    Notes
    In contrast to Open SQL , a client field in Native SQL is a field like any other and must be specified explicitly in calls.
    Authorization checks cannot be properly realized in EXEC SQL . You should perform these in the program.
    When you start the R/3 System, a CONNECT to the current database is executed automatically. An explicit CONNECT is unnecessary.
    A Native SQL command can (but does not have to) end with a ";". Under no circumstances should it end with a ".".
    Some database systems allow upper and lower case in table names and field names. If you want to take advantage of this, you must ensure that the spelling of names is correct. To enable entry of lower case letters in names in the ABAP/4 editor, you must set the attribute for upper/lower case in the report.
    Since there are no arrays in ABAP/4 , array operations are not possible in Native SQL . If the result of a SELECT command is a table, you can read this table line by line either with the Native SQL command FETCH or with the addition ... PERFORMING form .
    Unlike in ABAP/4 programs, the character " in a Native SQL statement does not introduce a comment until the end of the editor line.
    Addition
    ... PERFORMING form
    Effect
    If the result of a SELECT command is a table, you can read this table line by line in a processing loop. The subroutine form is called once for each line. In this subroutine, you can leave the loop by using EXIT FROM SQL . If the result of the selection is a single record, the subroutine is called only once.
    Example
    Display a section of the table AVERI_CLNT :
    DATA: F1(3), F2(3), F3(3).
    F3 = ' 1 '
    EXEC SQL PERFORMING WRITE_AVERI_CLNT.
      SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
             WHERE ARG2 = :F3
    ENDEXEC.
    FORM WRITE_AVERI_CLNT.
      WRITE: / F1, F2.
    ENDFORM.
    Note
    This addition is allowed only with a SELECT command.
    Related SELECT , INSERT , UPDATE , MODIFY , DELETE , OPEN CURSOR , FETCH , CLOSE CURSOR, COMMIT WORK and ROLLBACK WORK .
    go to se38
    type 'EXEC' and put cursor on 'EXEC' press f1-function key
    then you get help for EXEC
    Thanks & regards
    Sreenivasulu P
    Message was edited by: Sreenivasulu Ponnadi

  • Retreiving data from external DB using cursors (Native SQL)

    Hi experts,
    Iu2019m trying to use some functionality based on the Native SQL on an Oracle Server. Iu2019m facing some difficulties using cursors and fetching data from the external database.
    Basically the synonym its zfisicc_c_dblink, and Iu2019m running the for the following code:
    TRY.
          OPEN CURSOR WITH HOLD c1 FOR SELECT *
                                FROM  zfisicc_c_dblink
                                WHERE estado_sif = 'I'.
        CATCH cx_sql_exception INTO sqlerr_ref.
          PERFORM handle_sql_exception USING sqlerr_ref.
      ENDTRY.
    DO.
    *  "Move the data from the Cursor into the target area.
        FETCH NEXT CURSOR c1 APPENDING TABLE tab.
        IF sy-subrc  0.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE CURSOR c1.
    The cursor C1 it's cursor type and the table tab it's ZFISICC_C_DBLINK type, but every time i run it it's giving me the ORA-932 error.
    Database error text........: "ORA-00932: inconsistent datatypes: expected %s
    got %s"
    Can anyone help me on this error? What Iu2019m doing wrong when fetching the data ?
    Another doubt that Iu2019ve it's when using pl/Sql procedure. Can anyone tell how I can retrieve data from the external database with the following code?
    **Select Directo com Cursor
      EXEC SQL.
        CONNECT TO :gv_db_name AS 'dblink_con'
      ENDEXEC.
      IF sy-subrc NE 0.
        WRITE: 'Não foi possível fazer a ligação à DBCON: ', gv_db_name.
      ELSE.
        EXEC SQL.
          DECLARE CURSOR c_1 IS SELECT tipo_operacao FROM movimento_contribuicao
                 WHERE ROWNUM <= 10000;
              wa movimento_contribuicao.tipo_operacao%type;
    BEGIN
           OPEN c_1;
         LOOP
            FETCH c_1 INTO wa; "Not able to return data to SAP system
             EXIT WHEN c_1%NOTFOUND;
          END LOOP;
      END;
        ENDEXEC.
          EXEC SQL.
          DISCONNECT 'dblink_con'
        ENDEXEC.
      ENDIF.
    On the FETCH c_1 INTO wa; code Iu2019m moving the data to an Oracle variable, wa movimento_contribuicao.tipo_operacao%type;, and not to an program variable. Can anyone explain me this how this is +possible using this PL/SQL procedure?
    Thanks in advance,
    Best Regards
    João Martins
    Edited by: Rob Burbank on May 7, 2010 10:25 AM

    Hi Joao,
    Regarding your first question: It looks like there's a conversion problem (with one or more columns) from your Oracle table to your ABAP internal table.
    In the following link you can see (in your case in the SELECT section) the type conversions used for each type combination.
    Some combinations lead to an oracle error (specified in the "Result" column), like in your case (error 932).
    http://help.sap.com/saphelp_470/helpdata/EN/a3/74caa1d9c411d1950e0000e8353423/content.htm
    Regarding your second question: You can use the PERFORMING addition in the EXEC SQL statement.
    You can see an example in the following link:
    http://help.sap.com/saphelp_470/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm
    Hope it helps.
    Regards,
    Ana Luisa.

  • How to use Native SQL statement in JDBC receiver interface

    Dear All,
    Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
    Select Field1 Field2 from TABLE Where Field3 like "%Name'
    I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
    Hence I need to know:-
    1. What message mapping I should use in case if I have to use Native SQL statement.
    2.What operation mapping I should use in case if I have to use Native SQL statement.
    If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
    3 .How do to go about it to do the Java mapping.
    Thanks
    Ameet

    >
    Ameet Deshpande wrote:
    > Dear All,
    >
    > Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
    >
    > "
    > Select Field1 Field2 from TABLE Where Field3 like "%Name'
    > "
    > I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
    >
    > http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    > http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    >
    > The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
    >
    > Hence I need to know:-
    >
    > 1. What message mapping I should use in case if I have to use Native SQL statement.
    > 2.What operation mapping I should use in case if I have to use Native SQL statement.
    > If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
    > 3 .How do to go about it to do the Java mapping.
    >
    > Thanks
    > Ameet
    You can use a stored procedure, and call it from jdbc receiver adapter.
    I also solve this issue, with a DBLookup in message mapping. You can refer to my blog, and this usefull 3d:
    http://simonlesflex.wordpress.com/2010/12/07/pi-oracle-dblookup/
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

  • Using Native SQL in ABAP for DB2 database

    Dear Friends,
           I have 500K records in ITAB(Internal table) which needs to insert in 'Z' transparent table. Currently it is taking hours of time for insertion and commit. 
    Does using Native SQL helps in performance or any suggestions? If so please send the code. Our database is DB2.
    Your immediate reply is appreciated. Thanks in advance.

    Hi Rama,
    Using array inserts and commit after each Insert, set up your array size as a parameter and try  different array sizes.
    I would start with 2000 and increment by 1000 or 2000 and see what the optimal array size is.
    I would think more commits are desirable, as the array gets bigger it takes longer for the system to prepare in the event of a rollback.
    Just remember to commit after each insert. And are you enqueueing the table first?
    Hope this helps.
    Filler

  • How to use Native SQL String

    Hi all,
    How do i use Native SQL String in the Reciver JDBC Adapter.
    Do i need to change the message format could u suggest me some blogs on the same.
    Also please can anyone let me knw if i can use this for stored procedure.

    hi aditya,
    there shud be no format as such. for sql xml format there are specific structure. but for native sql there shudnt be any specific structure.
    as pointed in sap documentaion:
    Instead of an XML document format, a text is expected that represents any valid SQL statement.
    When inserting a line into a table the corresponding document looks as follows:
    INSERT INTO tableName  (column-name1, column-name2, column-name3) VALUES(‘column-value1’, ‘column-value2’, ‘column-value3’)
    so jus make sure that u give a valid sql statement becoz if will be passed as it is to the database and try ur scenario.
    regards,
    latika.

  • Using variable coulmn name in sql function

    Hi there,
    I am not an expert with PL/SQL and I can not figure out how to use variable column names in my function.
    My function is:
    CREATE OR REPLACE FUNCTION RESET_TRIGGERS(aTrigger VARCHAR2) RETURN NUMBER IS
    TEMP_ID NUMBER;
    TEMP_USER_ID NUMBER;
    BEGIN
    SELECT 'LIMS.'||'$aTrigger'||'.NEXTVAL' INTO TEMP_ID FROM DUAL;
    SELECT 'LIMS.'||'$aTrigger'||'_USER.NEXTVAL' INTO TEMP_USER_ID FROM DUAL;
    IF TEMP_ID > TEMP_USER_ID THEN
    LOOP
    SELECT LIMS.SQ_U_FINALRESULT_USER.NEXTVAL INTO TEMP_USER_ID FROM DUAL;
    EXIT WHEN TEMP_USER_ID = TEMP_ID;
    END LOOP;
    ELSE
    WHILE TEMP_ID < TEMP_USER_ID LOOP
    SELECT LIMS.SQ_U_FINALRESULT.NEXTVAL INTO TEMP_ID FROM DUAL;
    END LOOP;
    END IF;
    COMMIT;
    RETURN (TEMP_ID);
    END;
    What I want is that I pass a seqencename with aTrigger and that two triggers will be equal if not.
    eg ifaTrigger = 'SQ_U_FINALRESULT'
    than I want the triggers LIMS.SQ_U_FINALRESULT and LIMS.SQ_U_FINALRESULT_USER to be set equal.
    The above function will not work, but what will?????
    I hope you can help me out!
    Cheers

    A very strange function indeed.
    But here is what I think he meant to do:
    SQL> create procedure reset_sequences
      2  ( p_sequence_name in  varchar2
      3  , p_nextval          out number
      4  )
      5  is
      6    l_nextval1 number;
      7    l_nextval2 number
      8    ;
      9    procedure reset_sequence_value
    10    ( p_sequence_name in varchar2
    11    , p_current_value in number
    12    , p_new_value     in number
    13    )
    14    is
    15      l_dummy number;
    16    begin
    17      execute immediate 'alter sequence ' || p_sequence_name || ' increment by ' || to_char(p_new_value-p_current_value);
    18      execute immediate 'select ' || p_sequence_name || '.nextval from dual' into l_dummy;
    19      execute immediate 'alter sequence ' || p_sequence_name || ' increment by 1';
    20    end reset_sequence_value
    21    ;
    22  begin
    23    execute immediate
    24      'select ' || p_sequence_name || '.nextval,' || p_sequence_name || '_user.nextval from dual'
    25    into l_nextval1, l_nextval2
    26    ;
    27    if l_nextval1 < l_nextval2
    28    then
    29      reset_sequence_value(p_sequence_name,l_nextval1,l_nextval2);
    30    end if
    31    ;
    32    if l_nextval1 > l_nextval2
    33    then
    34      reset_sequence_value(p_sequence_name || '_user',l_nextval2,l_nextval1);
    35    end if
    36    ;
    37    p_nextval := greatest(l_nextval1,l_nextval2)
    38    ;
    39  end reset_sequences;
    40  /
    Procedure is aangemaakt.
    SQL> show err
    Er zijn geen fouten.
    SQL> create sequence testseq start with 5 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> create sequence testseq_user start with 2 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> declare
      2    l_new_value number;
      3  begin
      4    reset_sequences('testseq',l_new_value);
      5    dbms_output.put_line(l_new_value);
      6  end;
      7  /
    5
    PL/SQL-procedure is geslaagd.
    SQL> select testseq.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.
    SQL> select testseq_user.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.Regards,
    Rob.

  • # coming when I select data from oracle table using Native SQL

    Hi Gurus,
    I am selecting 'First name' from oracle table directly using native sql. I am fetching 65000 records but 10+ records having '#' at the end of firstname. For eg: John#.
    But oracle team couldn't find '#' in their table for those records. What could be problem?
    or what could be the character in oracle which comes as '#' in abap?
    Pls help...
    Saj

    Thanks for replies.
    My DB NLS_PARAMETER is AL32UTF8. I am able to pullout data with older version of ojdbc jar file. So I think there is no issue regarding NLS setting.
    So please guide me with proper solution as soon as possible.

  • [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/

  • Insert / Update of a TIME field using Native SQL

    Hi Oracle gurus,
    We are trying to perform inserts and updates within an ORACLE table where a TIME field exists without suscess. We are trying to code it using Native SQL.
    EXEC SQL.
    INSERT INTO table (field1[name], field2[age], field3[birthday], field4[hour])
    VALUES (:name, :age, TO_DATE(:date_birth), ¿:hour?)
    ENDEXEC.
    EXEC SQL.
    UPDATE table SET field3[birthday] = TO_DATE(:date_birth), field4[hour] = ¿:hour?
    WHERE field1[name] = :name AND field2[age] = :age
    ENDEXEC.
    Which is the right coding sentence in order to achieve our goal?
    Many thanks in advance. Best regards,
       Imanol

    Hi
    There is no TIME datatype in oracle. There is only a TIMESTAMP or DATE type or the field is VARCHAR2 as most date fields in a SAP database are. To help you we would need the real field type. If possible you please do a desc <owner>.<table> in a sqlplus session and give us the field type.
    If possible also supply the error you get.
    Regards, Michael

  • How to get oracle 9i blob column into an itab  in sap using Native SQL

    Hi ,
    We are using SAP ECC 5.0  and we need to coonect to an oracle database ver 9i rel2.
    We need to get the data stored in a blob(pdf/jpeg) into an itab and later
    use it for futher processing.
    I am familiar with using native SQL and I wrote a stored procedure in the non sap oracle database to send the blob info into an internal table in sap.
    But the information is in hex format and the long raw of SAP does not handle this very well.
    Plz see my code below.
    data: itab_insp_drawing like zpicture_cluster(which is of type lraw - 7902 )
          occurs 100 with header line.
    EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
      append itab_insp_drawing.
      while t_out_position < t_blob_length.
       EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
       append itab_insp_drawing.
       endwhile.
    Any ideas of how to handle blobs from non sap oracle table. I need this blob into an itab in sap.
    Help appreciated.
    Thanks
    Mala

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • Who to use Native SQL statements in ABAP

    hi all,
    who to use native sql staements in abap bypassing Application server.
    with regards,
    suresh babu aluri.

    Hi
    Native SQL statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check. The statements entered there are passed to the Native SQL interface and processed there as follows:
    Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC, in particular the DDL statements. These SQL statements are passed from the Native SQL interface to the database system largely unchanged. The syntax rules are specified by the database system, in particular the case sensitivity rules for database objects. If the syntax allows a separator character between individual statements, you can include several Native SQL statements between EXEC and ENDEXEC. Generally, the semicolon ( is used as the separator character.
    You can also include SAP-specific Native SQL language elements between EXEC and ENDEXEC. These statements are not passed directly from the Native SQL interface to the database, but are converted appropriately.
    All Native SQL statements bypass SAP buffering.
    The ENDEXEC statement sets sy-dbcnt to the number of table rows processed in the last Native SQL statement. After implicit cursor processing with PERFORMING, sy-dbcnt contains the total number of lines read.
    Programs with Native SQL statements are generally dependent on the database system used, so that they cannot be executed in all ABAP systems. This is especially true for the examples in this section, which was written for Informix database systems.
    Example
    Inserting two rows in the database table SCARR. If neither of these rows exists, sy-subrc is set to 0 by ENDEXEC and sy-dbcnt to 1. Otherwise, an exception is raised and handled.
    DATA: exc_ref    TYPE REF TO cx_sy_native_sql_error,
          error_text TYPE string.
    TRY.
        EXEC SQL.
          INSERT INTO scarr
                      (MANDT, CARRID, CARRNAME, CURRCODE, URL)
            VALUES ('000', 'FF', 'Funny Flyers', 'EUR',
                    'http://www.ff.com');
          INSERT INTO scarr
                     (MANDT, CARRID, CARRNAME, CURRCODE, URL)
            VALUES ('000', 'EF', 'Easy Flyers', 'EUR',
                    'http://www.ef.com');
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO exc_ref.
        error_text = exc_ref->get_text( ).
        MESSAGE error_text TYPE 'I'.
    ENDTRY.
    Reward points if useful
    Regards
    Anji

Maybe you are looking for

  • Scatter Plot will not start on requested date

    Hi, I am trying to make a very simple scatter plot in Numbers for Mac 3.1. I have created a table with two columns and 44 rows. one column is formatted to dates (year only), the other to numbers (3 decimal places). When I select the table, click on c

  • Get GPS location from the command line

    Is there a utility to get the current GPS location from the command line?  A quick search says `geo` will do it, but that appears to come with the android dev tools, which I'd rather not install right now.  The reason I want to do this is to avoid ha

  • RV220W : Some Errors in logs

    Hello, I have some errors in the RV220w log files, and i dont know the reason of these errors Mon Mar 26 19:59:48 2012(GMT+0100) [rv220w][System][PLATFORM] /pfrm2.0/bin/bwLimitConfig /tmp/system.db 18 dot11STA 2 failed. status=-1 Mon Mar 26 19:59:48

  • Get the length of column for each row in 2d array

    let say if i declared a 2d array int [][]set = new int[5][5]; if i had finished storing datas in the 2d array like the following Columns row 0[10][10][10][10][10] row 1[20][][][][] row 2[15][25][30][][] row 3[17][12][][][] row 4[10][][][][] how do we

  • Problem while automatic creation of measuring document

    Hello everyone, my client requirement is to track the usage hours of the PRT used for maintenace order. i have created the PRT as equipment with category P and assigned measuring point(counter) in the default values. Then the PRT is assigned in the o