EXEC SQL  - Convert NVARCHAR to char

Hi all,
I am tring to read data from Sql sever using native SQL,
My problem is that if I need to get data using WHERE on a field that is declared as NVARCHAR in SQL then the sekect is not working.
for example -
EXEC SQL.
      select count(*)
      from DocLine@MICRONET1_LINK
      where  "DocNum"  = '1234'
      into :lv_count
    ENDEXEC.
DocNum is defined as NVARCHAR.
in SQL server there is a function name CONVERT but I cant use it threw Native Sql in abap.
Thanks,
Naama

Luc,
You can use the reftohex() function (http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions100a.htm).
Regards,
Geoff

Similar Messages

  • EXEC SQL FAILS

    Hi,
    I am having 2 SQL blocks which calls the function HPS_SELECT_PIN_NB and INC_PIN_ERROR_NUMBER in oracle . Now the problem is that in the function inc_pin_error_number () .I see the trace event
    trace_event("Debut inc_pin_error_number()", PROCESSING);
    but i am NOT able to execute the EXEC SQL EXECUTE statement ( I guess that the control is not going in this EXEC statement ) , but when i call this same function (HPS_INC_PIN_NB) from the function load_pin_error_number it works .
    Please have a look at the two functions below and suggest as to why the functions is NOT being called from inc_pin_error_number .
    BLOCK 1
    int load_pin_error_number (V_card_number,
    V_pin_verification_number)
    char *V_card_number;
    int *V_pin_verification_number;
    EXEC SQL BEGIN DECLARE SECTION;
    int response_code;
    VARCHAR T_card_number[22];
    int T_pin_verification_number;
    VARCHAR ERREUR[256];
    EXEC SQL END DECLARE SECTION;
    char buffer[LG_MAX];
    trace_event("Debut load_pin_error_number()", PROCESSING);
    memset(T_card_number.arr, 0, sizeof(T_card_number.arr));
    memcpy(T_card_number.arr, V_card_number, strlen(V_card_number));
    T_card_number.len = strlen(V_card_number);
    response_code =999;
    EXEC SQL EXECUTE
    BEGIN
    :response_code:= HPS_SELECT_PIN_NB (:T_card_number,
    :T_pin_verification_number);
    EXCEPTION
    WHEN OTHERS THEN BEGIN
    :response_code :=-2;
    :ERREUR := SQLERRM;
    END;
    END;
    END-EXEC;
    if (response_code == -2)
    memset(buffer, 0, sizeof(buffer));
    sprintf(buffer,"GET PIN ERROR ERROR : %s\n", ERREUR.arr);
    trace_event(buffer, ERROR);
    *V_pin_verification_number = T_pin_verification_number;
    sprintf(buffer,"V_pin_verification_number %d\n", V_pin_verification_number);
    trace_event(buffer,V_pin_verification_number);
    trace_event("Fin load_pin_error_number()", PROCESSING);
    sprintf(buffer,"Response_code %d\n", response_code);
    trace_event(buffer,response_code);
    return(response_code);
    BLOCK 2
    int inc_pin_error_number (V_card_number)
    char *V_card_number;
    EXEC SQL BEGIN DECLARE SECTION;
    int response_code;
    VARCHAR T_card_number[22];
    VARCHAR ERREUR[256];
    EXEC SQL END DECLARE SECTION;
    char buffer[LG_MAX];
    trace_event("Debut inc_pin_error_number()", PROCESSING);
    memset(T_card_number.arr, 0, sizeof(T_card_number.arr));
    memcpy(T_card_number.arr, V_card_number, strlen(V_card_number));
    T_card_number.len = strlen(V_card_number);
    response_code =-1;
    EXEC SQL EXECUTE
    BEGIN
    :response_code:= HPS_INC_PIN_NB (:T_card_number);
    EXCEPTION
    WHEN OTHERS THEN BEGIN
    :response_code :=-2;
    :ERREUR := SQLERRM;
    END;
    END;
    END-EXEC;
    if (response_code == -2)
    memset(buffer, 0, sizeof(buffer));
    sprintf(buffer,"INC PIN ERROR ERROR : %s\n", ERREUR.arr);
    trace_event(buffer, ERROR);
    trace_event("Fin inc_pin_error_number()", PROCESSING);
    return(response_code);
    Regards
    Dhananjay Javalkar
    null

    Perhaps you can trap (profile) the query in Oracle to see what it gets submitted,
    thing is this query
    select id from table where ProcessedStatusColumn is null and DateColumn = (sub select to get most recent date in table where ProcessedStatusColumn is null)
    is not guaranteed to return a value, you need a default returned in case the search failed e.g.
    select
    NVL(id, 0)
    from table where ProcessedStatusColumn is null and DateColumn =
    (sub select to get most recent date in table where
    ProcessedStatusColumn is null)
    Arthur My Blog

  • 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

  • Abap sql convert to native sql fuction

    hi expert!
    exist a function can do follow things:
      convert selection-screen's select-options which user key in
         to oracle where condition expression
    or exist one function can convert abap sql to oracle sql
    thank you very much

    example:
      EXEC SQL.
            CONNECT TO :'DATA BASE NAME'
          ENDEXEC.
          IF sy-subrc EQ 0 .
             TRY.
                  EXEC SQL .
                    SELECT COUNT(*) FROM <TABLE NAME>
                    INTO :recount
                    WHERE code = :itab-<FIELD>
                  ENDEXEC .
                CATCH cx_sy_native_sql_error INTO exc_ref.
                  error_text = exc_ref->get_text( ).
                  MESSAGE error_text TYPE 'I'.
              ENDTRY.

  • EXEC SQL Error: ORA-01401: Inserted value too large for column

    Getting this SQL Error: ORA-01401: Inserted value too large for column..on an EXEC SQL Insert statement when writing to an
    external Oracle DB from SAP.
    On further analysis..it appears that this happens to the fields..when the string length matches the field length.
    Example:  Plant field is defined as char(4) on the SAP side and it is a Varchar2(4) on the Oracle side.
    When a value like '1015' is passed thru a variable in the insert statement then this ORA-01401 error pops up.
    No error:
       - if the value '1015' is passed directly in the insert statement to the external table  (or)
       - when a value with 3 chars or less(like the first three chars..101) is passed thru a variable  defined as 'Plant(4) type c'.
       - when using EXEC sql within SAP
       - when reading from the external db table
    This was working ok until the  Oracle Patch P9147110 was installed recently.
    Any suggestions !

    Hello Dvas,
    what's the characterset of your external database?
    What's the column definition in your external database (byte or character based)?
    If you use a characeterset like UTF8 it is possible, that one character needs more than one byte and then you will run into such kind of issues if the definition is too small.
    Regards
    Stefan

  • EXEC SQL with IN Clause

    Hello,
    I'm trying to run an EXEC SQL statement with an IN clause.  Here's my SQL code:
    EXEC SQL.
          OPEN C FOR
          SELECT name
                 FROM sv_hoover_data
                 where dunsNum in :DUNS_NUMBERS
        ENDEXEC.
    My DUNS_NUMBERS variable is of type String and contains the following data:
    ('12334223','4353434','54674563')
    When the statement is executed, I receive the following error message in SM21:
    Line 1: Incorrect syntax near '@P1'.
    Also, the underlying database is MS SQL Server.  When I run the query via MS Query Ananlyzer, it runs fine.
    Does any know if EXEC SQL can handle IN clauses, and if so, how they're written?
    Thanks,
    Matt

    I haven't used it myself (yet), but this is what I found in the help:
    EXEC SQL - EXECUTE
    Syntax
    EXEC SQL.
      EXECUTE PROCEDURE proc ( IN    p_in1    IN    p_in2 ...,
                               OUT   p_out1   OUT   p_out2 ...,
                               INOUT p_inout1 INOUT p_inout2 ... )
    ENDEXEC.
    Effect
    In database systems, you can define procedures as so-called "stored procedures". Since the syntax for calling such procedures and the pertinent parameter transfer for various database systems can vary widely, a uniform command exists in Native SQL.
    The statement EXECUTE PROCEDURE calls a procedure proc stored in the database. For all formal parameters of the procedure, you must specify the actual parameters, separated by commas. You must specify IN, OUT or INOUT before every actual parameter, in order to indicate whether the parameter is an input, output, or input/output parameter. You can use literals or Host Variables labeled by a colon(:)for the actual parameters.
    Example
    This example defines a selfunc procedure using database specific SQL-Statements (Informix). It also calls the procedure using the SAP-specific Native-SQL-Statement EXECUTE PROCEDURE in a LOOP-loop by means of a Selection Table, and deletes the the procedure using an SQL-Statement. In the case shown here, the procedure is a function whose return value output in EXECUTE PROCEDURE is copied to the host variable name.
    DATA scarr_carrid TYPE scarr-carrid.
    SELECT-OPTIONS s_carrid FOR scarr_carrid NO INTERVALS.
    DATA s_carrid_wa LIKE LINE OF s_carrid.
    DATA name TYPE c LENGTH 20.
    TRY.
        EXEC SQL.
          CREATE FUNCTION selfunc( input CHAR(3) )
            RETURNING char(20);
            DEFINE output char(20);
            SELECT carrname
                   INTO output
                   FROM scarr
                   WHERE mandt  = '000' AND
                         carrid = input;
            RETURN output;
            END FUNCTION;
        ENDEXEC.
        LOOP AT s_carrid INTO s_carrid_wa
                         WHERE sign = 'I' AND option = 'EQ'.
          TRY.
             EXEC SQL.
                EXECUTE PROCEDURE selfunc( IN  :s_carrid_wa-low,
                                           OUT :name )
              ENDEXEC.
              WRITE: / s_carrid_wa-low, name.
            CATCH cx_sy_native_sql_error.
              MESSAGE `Error in procedure execution` TYPE 'I'.
          ENDTRY.
        ENDLOOP.
        EXEC SQL.
          DROP FUNCTION selfunc;
        ENDEXEC.
      CATCH cx_sy_native_sql_error.
        MESSAGE `Error in procedure handling` TYPE 'I'.
    ENDTRY.

  • TRY ... CATCH doesn't work with EXEC SQL?

    When I created a native SQL statement, I knew before, that it would take a few tries to get it working. I decided to use exception classes to avoid short dumps, but it didn't work.
    Following code causes a short dump because of the dot after :xp_stras in the native SQL SELECT statement:
       try.
           EXEC SQL                     PERFORMING  list.
             SELECT LIFNR, NAME1, STRAS
                                    INTO  :xsl
                                    FROM  LFA1
             WHERE  UPPER( NAME1 )  LIKE  :xp_name1
             AND    UPPER( STRAS )  LIKE  :xp_stras.
           ENDEXEC.
                                                                                    catch CX_SY_NATIVE_SQL_ERROR.
           write: /1 'CX_SY_NATIVE_SQL_ERROR'.
       catch CX_SY_SQL_ERROR.
           write: /1 'CX_SY_SQL_ERROR'.
       catch CX_DYNAMIC_CHECK.
           write: /1 'CX_DYNAMIC_CHECK'.
       catch CX_ROOT.
           write: /1 'CX_SY_ROOT'.
       endtry.
    In ST22 you can see
    Name of runtime error: DBIF_DSQL2_SQL_ERROR
    Exception:
    The name of the exception is empty, in other short dumps you can find there the name of the exception class. Maybe that's the reason for CATCH does'nt work, but I don't understand it.
    Online help for EXEC SQL says:
    Catchable Exceptions
    CXSY_NATIVE_SQL_ERROR_
    Cause: SQL-Error at the execution of a Native SQL-command.
    Runtime Error: DBIF_DSQL2_SQL_ERROR
    We have SAP ECC 6.0 with SAP_BASIS rel. 700 lvl. 0013.
    If You have an idea why CATCH doesn't work, please tell me!
    Regards,
    Klaus

    Hi Rob,
    I tried out Your original code as program ZTEST5 and got a short dump (sorry, some of the short dump symbols are formatting this post in a wrong way ...):
    Short text
        An SQL error occurred when executing Native SQL.
    What happened?
        The error 919 occurred in the current database connection "DEFAULT".
    What can you do?
        Note down which actions and inputs caused the error.
        To process the problem further, contact you SAP system
        administrator.
        Using Transaction ST22 for ABAP Dump Analysis, you can look
        at and manage termination messages, and you can also
        keep them for a long time.
    How to correct the error
        Database error text........: "ORA-00919: invalid function"
        Database error code........: 919
        Triggering SQL statement...: "FETCH NEXT "
        Internal call code.........: "[DBDS/NEW DSQL]"
        Please check the entries in the system log (Transaction SM21).
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "DBIF_DSQL2_SQL_ERROR" " "
        "ZTEST5" or "ZTEST5"
        "START-OF-SELECTION"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction
           Restrict the time interval to 10 minutes befor
        after the short dump. Then choose "System->List->
        (Unconverted)".
        3. If the problem occurs in a problem of your own
        program: The source code of the program
           In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".
        4. Details about the conditions under which the e
        actions and input led to the error.
    System environment
        SAP-Release 700
        Application server... "lux01617"
        Network address...... "195.217.80.104"
        Operating system..... "Linux"
        Release.............. "2.6.5-7.283-smp"
        Hardware type........ "x86_64"
        Character length.... 16 Bits
        Pointer length....... 64 Bits
        Work process number.. 5
        Shortdump setting.... "full"
        Database server... "lux09208"
        Database type..... "ORACLE"
        Database name..... "D10"
        Database user ID.. "SAPDAT"
        Char.set.... "C"
        SAP kernel....... 700
        created (date)... "Dec 2 2007 20:18:08"
        create on........ "Linux GNU SLES-9 x86_64 cc3.3.3"
        Database version. "OCI_102 (10.2.0.2.0) "
        Patch level. 138
        Patch text.. " "
        Database............. "ORACLE 9.2.0.., ORACLE 10.1.0.., ORACLE 1
        SAP database version. 700
        Operating system..... "Linux 2.6"
        Memory consumption
        Roll.... 16192
        EM...... 16759392
        Heap.... 0
        Page.... 98304
        MM Used. 694160
        MM Free. 3493088
    User and Transaction
        Client.............. 500
        User................ "Z0000D2P"
        Language key........ "E"
        Transaction......... "SE38 "
        Transactions ID..... "48FE92EB921F51C3E1000000C3D95068"
        Program............. "ZTEST5"
        Screen.............. "SAPMSSY0 1000"
        Screen line......... 6
    Information on where terminated
        Termination occurred in the ABAP program "ZTEST5" - in "START-OF-SELECTION".
        The main program was "ZTEST5 ".
        In the source code you have the termination point in line 16
        of the (Include) program "ZTEST5".
    Source Code Extract
    Line  SourceCde
        1 REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.
        2
        3 TABLES: lfa1.
        4
        5 DATA: BEGIN OF xsl,
        6         lifnr TYPE lfa1-lifnr,
        7         name1 TYPE lfa1-name1,
        8         stras TYPE lfa1-stras,
        9       END   OF xsl.
       10
       11 DATA: xp_name1 TYPE lfa1-name1,
       12       xp_stras TYPE lfa1-stras.
       13
       14 TRY.
       15     EXEC SQL PERFORMING list.
    >>>>>       SELECT LIFNR, NAME1, STRAS
       17       INTO :xsl
       18       FROM LFA1
       19       WHERE UPPER( NAME1 ) LIKE :xp_name1
       20       AND UPPER( STRAS ) LIKE :xp_stras.
       21     ENDEXEC.
       22
       23   CATCH cx_sy_native_sql_error.
       24     WRITE: /1 'CX_SY_NATIVE_SQL_ERROR'.
       25   CATCH cx_sy_sql_error.
       26     WRITE: /1 'CX_SY_SQL_ERROR'.
       27   CATCH cx_dynamic_check.
       28     WRITE: /1 'CX_DYNAMIC_CHECK'.
       29   CATCH cx_root.
       30     WRITE: /1 'CX_SY_ROOT'.
       31 ENDTRY.
       32
       33 &----
       34 *&      Form  LIST
       35 &----
    Edited by: Klaus Babl on Oct 22, 2008 6:42 AM

  • EXEC SQL & CREATE TABLE

    Hi,
    I am trying to create table using EXEC SQL. But, the table that I had created using EXEC SQL is not shown in data dictionary. I can not see that table from SE11. If I run the same program again, then gives error about there is already a table that I want to create. So, How can see it? Is seeing that table possible?
    EXEC SQL.
    CREATE TABLE ZCOPYTABLE(
    NAME CHAR(15) NOT NULL,
    SURNAME CHAR(15) NOT NULL,
    TEL CHAR(10) NOT NULL,
    PRIMARY KEY (NAME, SURNAME)
    ENDEXEC.

    Hello Huseyin,
    I don't think you can use the Native SQL statements for DDL (data definition language) statements in SQL.
    The reason is that the Native SQL statements by-pass the SAP Application Server and are executed directly at the Database Server. You will find more information on the SAP Online Help Documentation site.
    Since the ABAP Dictionary is very much an application, it fails to recognize the tables which were not created through it.
    The DDL statements in Native SQL are only for advanced database adminstration tasks.
    Hope this helps.
    Regards,
    Anand Mandalika.

  • EXEC SQL

    Hi,
    What does an EXEC SQL stmt do in ABAP?
    What is the disadvantage of using it?
    Regards,
    Kalai

    Hi
    <b>EXEC SQL</b>
    EXEC SQL [PERFORMING subr].
    ENDEXEC.
    These 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. These SAP-specific language elements are::
    <b>Host variables</b>
    Statements for cursor processing
    Database procedure calls
    Statements for establishing database connections
    All Native SQL statements bypass SAP buffering. Automatic client handling is not performed.
    <b>System fields</b>
    The statement ENDEXEC sets the system fields sy-subrc and sy-dbcnt.
    sy-subrc Meaning
    0 The statements between EXEC and ENDEXEC were executed successfully.
    4 The statements between EXEC and ENDEXEC were not executed.
    The ENDEXEC statement sets sy-dbcnt to the number of table rows processed in the last Native SQL statement.
    Programs with Native SQL statements are generally dependent on the database system used, so that they cannot be executed in all SAP Systems. This is especially true for the examples in this section, which was written for Informix database systems.
    <b>Example</b> 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.
    <b>Reward if usefull</b>

  • Memory Allocated using EXEC SQL VAR in ProC

    For a table that stores resumes, I have a ProC program which outputs LONG column values into a host variable. Here is the table definition:
         create table resume (resume_id number(5),
                   resume_size number(15),
                   resume_text LONG)
    The size of the resume_text can be vary from 0 bytes up to 90K bytes. We use the column "resume_size" to store the size of the resume_text in bytes. Since most of them are smaller than 8K, we don't want to allocate 90K memory for every resume SELECT call. Before we do the SELECT on the resume_text, a host variable pointer is used to allocate memory according to the size of the resume_text:     
         char *resume_buffer;
    len = get_resume_size(id); /* A SELECT statement to fetch the resume_size for this resume from the table */               
         resume_buffer = malloc(len); /* Allocate memory for the resume according to the resume_size. For example, len could be 6000 */
         EXEC SQL VAR resume_buffer IS LONG (100000);      /* without using a constant number will lead to a compiler error */
         EXEC SQL SELECT resume_text INTO :resume_buffer FROM resume WHERE resume_id = :id;
    Is 100000" the size actually allocated in memory (either OS level or Oracle data buffer cache) every time it runs or is it just the maximum possible size needed to satisfy the precompiler?
    Any help greatly appreciated.

    You have to use 'BEGIN procedure_name END' in the execute statement while calling PL/SQL Procedures
    EXEC SQL EXECUTE
    DECLARE
    BEGIN
    END;
    END-EXEC;

  • SQL Server nvarchar and JDBC

    Hi to all,
    My DBMS is SQL Server2000 and i created a table which has two columns. Two of them were defined as varchar, but when i wrote Turkish character, these characters automaticly were converted to the different characters. Because varchar does not support Unicode. So, I had to use nvarchar, but if i used nvarchar how can I match nvarchar values to the java.sql.Types. There is no matching values for SQL Server nvarchar type. So, that is my question, how can i write Turkish character to the SQL Server via application which uses JDBC API to connect to the SQL Server.
    Regards
    Bulent

    Hi I am curious to see how you established a JDBC connection using Java to SQL Server 2000.
    Can you provide some code as an example for me?
    I am having problems just establishing a connection. I downloaded the JDBC driver from MS site and installed it.
    Here is some code I got:
    Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://DEV01:1433;DatabaseName=NG_RFQ;SelectMethod=cursor", "jla", "jla");
                   Statement stmt = con.createStatement();
                   ResultSet rs = stmt.executeQuery("SELECT * FROM Customer");
                   if(rs.next()){
                        customerName = rs.getString("CustomerName");
                        buyerName = rs.getString("BuyerName");
                   con.close();
    Can you tell me what I am doing wrong? Do I need to create a new DSN or something? I have no idea.
    Please advise.
    Thanks!!!

  • Pro*Cで「EXEC SQL AT」句のエラーについて

    お世話になります。
    Pro*CでのEXEC SQL AT句について、複数ユーザをログインして、ユーザを切り替え(?)しようと
    したとき、記述の仕方によって、エラーになるケースとならないケースとあって、困っています。
    下に示すソースコードの要点を説明しますと、「_select_usr」という関数で操作しようとするユーザを
    切り替えしています。
    この関数を用いて、1回目((1)と示す箇所)は正常に明示出来ますが、2回目((2)と示す箇所)は
    次のエラーメッセージが出ます。
    ORACLE ERROR msg => SQL-02122: データベースへ接続でのOPENまたはPREPAREが無効です。
    そこで、(2)の箇所をコメントにして、(3)で示す箇所の記述を有効、つまり「_select_usr」関数の
    呼び出しを無効にし、EXEC SQL AT句を直に書き込んで実行すると、正常に別のユーザを明示して
    くれます。
    要は、関数を用いて、ユーザの切り替えが出来る様にしたいのですが、正常に実行出来る方法が
    ありましたら、ご教示頂きたく存じます。
    よろしくお願い致します。
    【環境仕様】
    クライアントOS : Windows7 Professional SP1
    Oracle : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 (Linuxサーバ)
    開発ツール : Microsoft Visual Studio 2005 Version 8.0.50727.42
    Microsoft .NET Framework Version 2.0.50727 SP2
    Microsoft Visual C++ 2005
    Pro*C/C++(PC) : Pro*C/C++: Release 10.2.0.1.0
    【ソースコード】
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include "sqlca.h"
    #include "sqlda.h"
    void* db_error_handler_ptr();
    extern void truncate_blank(char *a);
    static     char *current_dbn;
    static     FILE     *fp;
    static void _connect( char* uid, char* pwd, char* host, char* dbn )
         EXEC SQL CONNECT :uid IDENTIFIED BY :pwd AT :dbn USING :host;
         fprintf(fp, "connect scima[%s] sqlcode[%d]\n", uid, sqlca.sqlcode );
    void _disconnect(char *dbn)
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL AT :dbn ROLLBACK WORK RELEASE;
         fprintf(fp, "disconnect dbn[%s] sqlcode[%d]\n", dbn, sqlca.sqlcode );
    void ora_sql_error(char *file, int line)
         char buf[512], *all_msg;
         int buf_len, msg_len;
         if (sqlca.sqlcode == -1405) {
              return;
         } else {
              buf_len = sizeof(buf);
              sqlglm(buf, &buf_len, &msg_len);
              buf[msg_len] = '\0';
              fprintf(fp, "ORACLE ERROR msg => %s\n", buf );
    static int selectusr( char* dbn, char* uid )
         int          rtn;
         char     u[56];
         EXEC SQL AT :dbn SELECT USER INTO :u FROM DUAL;
         rtn = 1;
         if (sqlca.sqlcode != 0) {
              if (sqlca.sqlcode == -1012) {
                   rtn = -1;
              ora_sql_error(__FILE__, __LINE__);
         } else {
              rtn = 0;
              truncate_blank(u);
              strcpy( uid, u );
              fprintf(fp, "select scima[%s]\n", uid );
         return( rtn );
    void main()
         char*     uid1="UID1";
         char*     pwd1="PWD1";
         char*     name1="orcl";
         char*     db_name1="DB1";
         char*     uid2="UID2";
         char*     pwd2="PWD2";
         char*     name2="orcl";
         char*     db_name2="DB2";
         char     u[56];
         fp = fopen("***.txt", "w");
         if( !fp ) exit( 1 );
         connect( uid1, pwd1, name1, dbname1 );
         connect( uid2, pwd2, name2, dbname2 );
    /*** (1) ↓ ***/
         if( selectusr( db_name1, u )!=0 ){
              exit( 1 );
         fprintf( fp, "current scima(1) : [%s] \n", u );
    /*** (1) ↑ ***/
    /*** (2) ↓ ***/
         if( selectusr( db_name2, u )!=0 ){
              exit( 1 );
         fprintf( fp, "current scima(2) : [%s] \n", u );
    /*** (2) ↑ ***/
    /*** (3) ↓ ***/
         EXEC SQL AT :db_name2 SELECT USER INTO :u FROM DUAL;
         if (sqlca.sqlcode != 0) {
              if (sqlca.sqlcode == -1012) {
              ora_sql_error(__FILE__, __LINE__);
              exit( 1 );
         } else {
              truncate_blank(u);
              fprintf( fp, "current scima(3) : [%s] \n", u );
    /*** (3) ↑ ***/
         disconnect(dbname1);
         disconnect(dbname2);
         if(fp) fclose(fp);
    }

    Matsuoka様
    ご教示有難うございました。
    コンテキストの方法でやってみようかと思ったところ、社の者が、プリコンパイラのオプションhold_cursorを「yes」にしていたのを「no」に切り替えたら、出来たんだそうです。とりあえず、それでやってみますが、何か問題あれば、コンテキストの方法でやってみたいと思います。
    有難うございました。

  • Convert number to char

    Hi,
    I need to format numbers when converting it to char.
    I need to show the number with a precision of 3, and when between -1 and 1 to show the 0.
    ex:
    0.234
    -0.234
    1.220
    not .234
    thanks in advance

    I need to show the number with a precision of 3, and when between -1 and 1 to show the 0.This ?
    SQL> with t as (
    select 0.234 n from dual union all
    select -0.234 from dual union all
    select  13.22 from dual union all
    select 1.220 from dual
    select n, to_char(n, '990.000')  n2 from t
             N N2     
          ,234    0.234
        -0,234   -0.234
         13,22   13.220
          1,22    1.220
    4 rows selected.

  • Create data base table with EXEC SQL

    Hello,
    I nead to create o data base table with EXEC SQL in an Abap program.
    My code is :
    TRY.
       EXEC SQL.
          CREATE table zt_hello ( mandt char(4) NOT NULL,
                                  kunnr char(10) NOT NULL,
                                  PRIMARY KEY (mandt, kunnr) )
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO exc_ref.
        error_text = exc_ref->get_text( ).
    ENDTRY.
    IF sy-subrc = 0.
      COMMIT WORK.
    ENDIF.
    But it still not working.
    Can you help me please.
    Thanks.
    Edited by: widad soubhi on Jul 14, 2010 5:26 PM

    Please refer this code
    REPORT z_struct_create .
    DATA: my_row(500) TYPE c,
    my_file_1 LIKE my_row OCCURS 0 WITH HEADER LINE.
    DATA: dd02v TYPE dd02v.
    DATA: my_file_tab1 LIKE dd03p OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text
    NO INTERVALS.
    PARAMETERS:
    name TYPE ddobjname,
    testo TYPE text40,
    file_1 LIKE rlgrap-filename.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN END OF BLOCK blk.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_1.
    PERFORM file_selection USING file_1.
    INITIALIZATION.
    text = text-001.
    START-OF-SELECTION.
    IF file_1 IS INITIAL.
    MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 001.
    EXIT.
    ENDIF.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = file_1
    filetype = 'ASC'
    TABLES
    data_tab = my_file_1.
    IF sy-subrc 0.
    MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 002.
    EXIT.
    ENDIF.
    LOOP AT my_file_1.
    IF sy-tabix > 1.
    CLEAR my_file_tab1.
    SPLIT my_file_1 AT ';' INTO
    my_file_tab1-fieldname
    my_file_tab1-datatype
    my_file_tab1-leng
    my_file_tab1-decimals
    my_file_tab1-ddtext
    my_file_tab1-inttype = 'C'.
    my_file_tab1-INTLEN = my_file_tab1-leng.
    my_file_tab1-tabname = name.
    my_file_tab1-position = sy-tabix - 1.
    my_file_tab1-ddlanguage = sy-langu.
    my_file_tab1-OUTPUTLEN = my_file_tab1-leng.
    APPEND my_file_tab1.
    ENDIF.
    ENDLOOP.
    dd02v-tabname = name.
    dd02v-ddlanguage = sy-langu.
    dd02v-tabclass = 'INTTAB'.
    dd02v-DDTEXT = testo.
    dd02v-MASTERLANG = sy-langu.
    IF NOT my_file_tab1[] IS INITIAL.
    CALL FUNCTION 'DDIF_TABL_PUT'
    EXPORTING
    name = name
    dd02v_wa = dd02v
    TABLES
    dd03p_tab = my_file_tab1
    EXCEPTIONS
    tabl_not_found = 1
    name_inconsistent = 2
    tabl_inconsistent = 3
    put_failure = 4
    put_refused = 5
    OTHERS = 6
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ELSE.
    MESSAGE ID 'Z0017_BDI' TYPE 'I' NUMBER 003.
    EXIT.
    ENDIF.
    *& Form file_selection
    -->P_FILE_1 text
    FORM file_selection USING p_file.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    def_filename = ''
    def_path = 'c:\'
    mask = ',.,..'
    mode = '0'
    title = 'Selezione file'
    IMPORTING
    filename = p_file
    RC = RCODE
    EXCEPTIONS
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    OTHERS = 5.
    ENDFORM. " file_selection
    File Template:
    Fieldname;Data Type;Lentgh;Dec.;Descr.
    FIELD1;CHAR;000020;000000;my field 1
    FIELD2;CHAR;000008;000000;my field 2
    FIELD3;CHAR;000007;000000;my field 3
    FIELD4;CHAR;000006;000000;my field 4

  • SQL error 3113 occurred when executing EXEC SQL.

    Hi,
    We are facing one typical problem, One background is failing regularly with
    below dump. as we now got all notes giving information, if database  restarted
    taking backup, these type of failures occur, but our database is only down for backup once in a week, but it is failing with frequenly.
    in this two servers are located in different place, in this job tries to connect
    another server to get material statistics.
    It is giving some error message in sm21 with
    SQL error 3113 occurred when executing EXEC SQL.
    work procees in reconnect mode.
    all notes saying these types of dump occur when database restared, but this dump
    even though database is up.
    below is short dump, please can anyone help me from this problem.
    ABAP runtime errors    DBIF_DSQL2_SQL_ERROR
          Occurred on    08.01.2007 at 00:30:28
    >> Short dump has not been completely stored. It is too big.
    SQL error 3113 occurred when executing EXEC SQL.
    What happened?
    The error occurred in the current database connection "AZ1".
    What can you do?
    Note the actions and input that caused the error.
    Inform your SAP system administrator.
    You can print out this message by choosing "Print". Transaction ST22
    allows you to display and manage termination messages, including keeping
    them beyond their normal deletion date.
    Error analysis
    How to correct the error
    Database error text........: "ORA-03113: end-of-file on communication channel#"
    Triggering SQL statement...: "select mara.groes, mara.brgew, mara.ntgew,
    mara.gewei, mara.volum, mara.voleh, mara.mstae, mara.mstde, mara.prdha,
    marc.matnr, marc.werks, marc.mmsta, marc.mmstd from sapr3.mara, sapr3.m
    where sapr3.mara.mandt = sapr3.marc.mandt and sapr3.mara.matnr =
    Internal call code.........: "[DBDS/NEW DSQL]"
    Please check the entries in the system log (Transaction SM21).
    If the error occurred in a non-modified SAP program, you may be
    able to find a solution in the SAP note system.
    If you have access to the note system yourself, use the following
    search criteria:
    "DBIF_DSQL2_SQL_ERROR"
    "ZM2431216 " or "ZM2431216 "
    "EXTRACT_GENERAL_DATA"
    If you cannot solve the problem yourself, please send the
    following documents to SAP:
    1. A hard copy print describing the problem.
      To obtain this, select the "Print" function on the current screen.
    2. A suitable hardcopy prinout of the system log.
      To obtain this, call the system log with Transaction SM21
      and select the "Print" function to print out the relevant
      part.
    3. If the programs are your own programs or modified SAP programs,
      supply the source code.
      To do this, you can either use the "PRINT" command in th
      print the programs using the report RSINCL00.
    4. Details regarding the conditions under which the error o
      or which actions and input led to the error.
    System environment
    SAP Release.............. "46C"
    Application server....... "essceu3"
    Network address.......... "172.19.119.198"
    Operating system......... "AIX"
    Release.................. "5.3"
    Hardware type............ "00C7ADBD4C00"
    Database server.......... "ukblx176"
    Database type............ "ORACLE"
    Database name............ "EU3"
    Database owner........... "SAPR3"
    Character set............ "es_ES.ISO8859-1"
    SAP kernel............... "46D"
    Created on............... "Jul 9 2006 20:26:33"
    Created in............... "AIX 1 5 00447C4A4C00"
    Database version......... "OCI_920__OCI_7_API "
    Patch level.............. "2257"
    Patch text............... " "
    Supported environment....
    Database................. "ORACLE 8.0.5.., ORACLE 8.0.6.., ORACLE
    8.1.6.., ORACLE 8.1.7.., ORACLE 9.2.0.., ORACLE 10.2.0.."
    SAP database version..... "46D"
    Operating system......... "AIX 1 4, AIX 2 4, AIX 3 4, AIX 1 5, AIX 2 5, AIX 3
    5, , System build information:,                                      , LCHN :
    841480"
    User, transaction...
    Client.............. 600
    User................ "MPZMMES"
    Language key........ "S"
    Transaction......... " "
    Program............. "ZM2431216 "
    Screen.............. "SAPMSSY0 1000"
    Screen line......... 6
    Information on where termination occurred
    The termination occurred in the ABAP/4 program "ZM2431216 " in
    "EXTRACT_GENERAL_DATA".
    The main program was "ZM2431216 ".
    The termination occurred in line 980
    of the source code of program "ZM2431216 " (when callin
    The program "ZM2431216 " was started as a background jo
    Source code extract
    009500              mara.ntgew,
    009510              mara.gewei,
    009520              mara.volum,
    009530              mara.voleh,
    009540              mara.mstae,
    009550              mara.mstde,
    009560              mara.prdha,
    009570              marc.matnr,
    009580              marc.werks,
    009590              marc.mmsta,
    009600              marc.mmstd
    009610        into :w_ops-groes,
    009620              :w_ops-brgew,
    009630              :w_ops-ntgew,
    009640              :w_ops-gewei,
    009650              :w_ops-volum,
    009660              :w_ops-voleh,
    009670              :w_ops-mstae,
    009680              :w_ops-mstde,
    009690              :w_ops-prdha,
    009700              :w_ops-matnr,
    009710              :w_ops-werks,
    009720              :w_ops-mmsta,
    009730              :w_ops-mmstd
    009740        from sapr3.mara, sapr3.marc
    009750        where sapr3.mara.mandt = sapr3.marc.mandt
    009760          and sapr3.mara.matnr = sapr3.marc.matnr
    009770          and sapr3.mara.mandt = :p_mandt
    009780          and sapr3.mara.matnr = :w_ebs-matnr
    009790          and sapr3.marc.werks = :p_owerks
        >    ENDEXEC.
    009810  endform.                    " extract_general_data
    009820  *&
    009830  *&      Form  append_i_ops
    009840  *&
    009850  *      Appends W_OPS to I_OPS
    009860  *
    009870  form append_i_ops.
    009880    append w_ops to i_ops.
    009890  endform.                    " append_i_ops
    009900  *&
    009910  *&      Form  extract_material_description
    009920  *&
    009930  *      Extracts a Material Description from the remote database an
    009940  *      modifies the current record in I_OPS.
    009950  *
    009960  *        >P_SPRAS  Language Key
    009970  *
    009980  form extract_material_description using    p_spras.
    009990    EXEC sql performing set_langauge.
    Contents of system fields
    SY field contents..................... SY field contents............
    SY-SUBRC 0                            SY-INDEX 0
    SY-TABIX 1                            SY-DBCNT 1
    SY-FDPOS 18                            SY-LSIND 0
    SY-PAGNO 0                            SY-LINNO 1
    SY-COLNO 1
    Chosen variables
    Name.......................... Contents.1........2........3....+..
    W_EBS-PRAT4
                                  2
                                  0
    W_OPS-GROES
                                  22222222222222222222222222222222
                                  00000000000000000000000000000000
    W_OPS-BRGEW                    #######
                                  0000000
                                  000000C
    W_OPS-NTGEW                    #######
                                  0000000
                                  000000C
    regards,
    krishnaiah.

    Hi,
    This is usually a SERVER SIDE DATABASE PROBLEM or SQLNET LISTENER (server side) PROBLEM.  The client side should initially be ignored and instead the server should be investigated. In rare cases, this can be caused by client
    side memory or other resource problem, or a DLL version mismatch, but this is
    unlikely.
    Enlist the assistance of your DBA.  Then reproduce the ORA-3113 error on your
    client application.  Ask your DBA to look at the database side Alert.log and
    trace files and look for ANY activity.  Any activity that coincides with your
    ORA-3113 will be a clue.
    REgards
    Vinod

Maybe you are looking for

  • Lost all of my icons in left hand window.

    Here's one for you techies! Working away merrily the other night, when I decided that I needed a multiway power socket in my room. Trouble was, my G4 iMac (flat screen) was plugged into the power socket. Logged out, shut down, waited until the hard d

  • There is a serious problem of iPhone 5's internet connection, both 3G and Wifi (I have not tested on LTE)

    The Wifi and 3G speed is even lower than iPhone 4s even Apple claimed that iPhone 5 is equipped with Ultrafast wireless. The data shown by Speedtest show that iphone 4s get a 20Mbps download speed while iPhone 5 is 9Mbps, which testing in same area c

  • Error message Insufficient Credit

    Hello, I am trying to call a mobile phone in/from the Philippines from Mexico but when i dial the phone I get a message that says 'insufficient credit' even though I have all 60 minutes left from my World minutes for Office 365 subscription. What exa

  • SQL Expression fields do not display when no records are returned

    I have a report that uses SQl expression fields to summarize in the Report footer.  When the main report does not contain any records the SQL expression fields are blank. Is there a way to force these SQL expression fields to be evaluated evn when th

  • Love the Cloud Idea, but I have Many questions about it

    Hi, I love the Adobe Cloud Idea, but I was wondering if it is the right for me. I have a very peculiar situation, my job takes me to many different places around the world. - My Next job is taking me to Peru and I noticed that it is not on the availa