String Comparision in pl/sql

Hi,
i executed the below code and found that output should be 5 but it shows 7(always else part). it is not comparing string in case. can anybody state the reason.
declare
check_in_date date;
var_day varchar2(11);
rate_id number;
begin
check_in_date := '23-mar-2013';
select to_char(check_in_date, 'DAY') into var_day from dual;
dbms_output.put_line(var_day);
select case
when VAR_DAY = 'SATURDAY' THEN
5
WHEN VAR_DAY = 'SUNDAY' THEN
6
ELSE
7
END
into rate_id
from dual;
DBMS_OUTPUT.PUT_LINE(rate_id);
end;
Thanks.
Vipin

Change this
select to_char(check_in_date, 'DAY') into var_day from dual;as
select to_char(check_in_date, 'fmDAY') into var_day from dual;You need to use the "fm" (format model) specificaton otherwise the value will be right padded with space for the max size.
SQL> select '"' || to_char(sysdate+level, 'DAY') || '"' without_fm,
  2         '"' || to_char(sysdate+level, 'fmDAY') || '"' with_fm
  3    from dual
  4  connect by level <= 7;
WITHOUT_FM  WITH_FM
"FRIDAY   " "FRIDAY"
"SATURDAY " "SATURDAY"
"SUNDAY   " "SUNDAY"
"MONDAY   " "MONDAY"
"TUESDAY  " "TUESDAY"
"WEDNESDAY" "WEDNESDAY"
"THURSDAY " "THURSDAY"
7 rows selected.

Similar Messages

  • String Comparision in XSLT Mapping

    HI All,
    Can any one suggest me to compare the two strings in XSLT mapping.Please let me know is there any string comparision function in xslt?
    Thanks
    Pullarao

    Hi Pullaro!
    It depends what you want to do with the comparison
    E.g. you can use a simple xsl-if Tag to compare a value
    and then take action.
    If your XML looks like this:
    <root>
      <child><b>value1</b></child>
      <child>value2</child>
    </root>
    you can make an expression like this and take action on it:
    <xsl:if test="<b>//child = 'value1'</b>">
        <i>.. Do what you want to do here..</i>
    </xsl:if>
    With kind regards
                 Sebastian

  • Execute a string containing a PL/SQL block

    Hi,
    I would like to build a string containing a PL/SQL block and execute it dynamically. Is there way to do this.
    Note - The reason I want to this is because, based on certain table data dictionary views the declaration section of the PL/SQL block that I am building might vary
    I tried to use EXECUTE IMMEDIATE, it didn't work, pls let me know if I am missing something.
    DECLARE
    v_str VARCHAR2(1000);
    BEGIN
    v_str := 'BEGIN NULL; END';
    EXECUTE IMMEDIATE v_str;
    END;
    /

    Hi,
    Just happened to find it. EXECUTE IMMEDIATE can be used, the bug with my code was I didn't have a ; after the END statement. Corrected code is below, thanks for your time
    DECLARE
    v_str VARCHAR2(1000);
    BEGIN
    v_str := 'BEGIN NULL; END;';
    EXECUTE IMMEDIATE v_str;
    END;
    /

  • [OT] User-Defined string Functions  Oracle PL/SQL

    Ladies and Gentlemen,
    I am pleased to offer the following string functions Oracle PL/SQL:
    GETALLWORDS(): Inserts the words from a string into the table.
    GETWORDCOUNT(): Counts the words in a string.
    GETWORDNUM(): Returns a specified word from a string.
    OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
    OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
    PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
    STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
    STRFILTER(): Removes all characters from a string except those specified.
    RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RAT() is case-sensitive. RAT similar to the PL/SQL function INSTR.
    ATC(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (including overlaps). The search performed by ATC() is case-insensitive. ATC similar to the PL/SQL function INSTR.
    RATC(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RATC() is case-insensitive. RATC similar to the PL/SQL function INSTR.
    AT2(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (excluding overlaps). The search performed by AT2() is case-sensitive. AT2 similar to the PL/SQL function INSTR.
    REPLICATE(): Returns a character string that contains a specified character expression repeated a specified number of times.
    ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).
    Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, MS SQL SERVER 2005 SQLCLR.
    More than 8000 people have already downloaded my functions. I hope you will find them useful as well.
    For more information about string UDFs Oracle PL/SQL please visit the
    http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29233
    Please, download the file
    http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29233
    With the best regards.

    >
    I am using the Oracle Data Provider in vs2012. I am having trouble calling a function that returns an object type defined.
    >
    Returning a collection like that is a bad idea to begin with. That isn't scaleable and wastes memory.
    Either return a REF CURSOR and let the client FETCH the rows or use a PIPELINED function and let the client query it like they would a table.
    Here is an example similar to yours that uses a PIPELINED function.
    create or replace
        package pkg2
          as
            CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp);
            type pkg_emp_table_type is table of emp_cur%rowtype;
            function get_emp(
                             p_deptno number
              return pkg_emp_table_type
              pipelined;
      end;
    create or replace
        package body pkg2
          as
            function get_emp(
                             p_deptno number
              return pkg_emp_table_type
              pipelined
              is
              begin
                  for v_emp_rec in (SELECT empno, ename, job, mgr, deptno
                                    FROM emp where deptno = p_deptno) loop
                    pipe row(v_emp_rec);
                  end loop;
              end;
      end;
    select * from table(pkg2.get_emp(20));
           EMPNO ENAME      JOB              MGR     DEPTNO
            7369 DALLAS     CLERK2          7902         20
            7566 DALLAS     MANAGER         7839         20
            7788 DALLAS     ANALYST         7566         20
            7876 DALLAS     CLERK           7788         20
            7902 DALLAS     ANALYST         7566         20

  • String comparision using tokens (challenging question)

    Hello, everyone.
    i am having a problem with string comparision.
    for example, the input file is:
    each line is an input line (string)
    1)a x
    2)b c x
    3)a b x
    4)a b y
    5)a b c x
    in above example a,b,c,x,y are strings(tokens)
    in above example
    line 1 ,3,5 has token "a" common and class "x" is also common
    if this condition is satisfied,
    line 1 should be send to general file (output file 1) and
    line 3 and 5 should be send to specific file (output file 2)
    rest of the lines should be send to third file.
    remember in line 4, token "a" is same when compared with line1
    but it has a different class (y) .this line will go the third file. this is where line 3 and 4 differs.
    i have read this file into an string array.
    how to proceed further.
    i am new to java programming.
    cheers in advance.

    Well, first off, I'm assuming that you keep the first string as the first token and the class name as your last token, then you tokenize everything using StringTokenizer. the code would look something like this. You could also use countTokens() to know how many tokens are in a tokenizer.
    My approach would be the following:
    1. Create an array of Strings to hold each line (you already did that)
    2. Go through the array, one line at a time, tokenize the String, figure out the first and last tokens
    3. Write it to the corresponding file.
    The code would be something as follows
    String ClassToLookFor, StringToLookFor; // holds which class and first string to look for
    String firstToken, lastToken; //used in checking each element with first one
    boolean firstFound = false;  // First instance of Class name and first thread combo found
    public static void main(String args[])
    StringTokenizer tokenizer;
    int tokenizerLength;
    // read in array of Strings, store it into lines or something
    int endOfRun = lines.length;
    for (int i = 0; i<endOfRun; i++)
    tokenizer = new StringTokenizer(lines);
    tokenizerLength = tokenizer.countTokens();
    if(!firstFound)
    // store the information (StringToLookFor and ClassToLookFor) and write the line to the corresponding file
    else
    firstToken = tokenizer.next();
    int runThru;
    while(runThru < (tokenizerLength - 2)) {tokenizer.next();} // going to the last token
    lastToken = tokenizer.next();
    if (firstToken.equals(StringToLookFor) && lastToken.equals(ClassToLookFor))
    {write lines[i] to second file}
    else
    {write lines[i] to third file}
    hope that helps ...

  • Escaping a whole string variable in T-SQL

    Hi,
    is it possible to escape o whole string variable in T-SQL like it is possible in PowerShell?
    In PowerShell it works like this:
    $PSstring = @'
    Text with single quotes like ' or double quotes " or even an & or %.
    And new line.
    Any chance to escape it in T-SQL like in PowerShell above?
    Regards,
    Stefan
    www.sc-orchestrator.eu ,
    Blog sc-orchestrator.eu

    Pretty sure the OP wants to escape the variable name itself to have a variable called 
    Text with single quotes like ' or double quotes " or even an & or %.
    And new line.
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • How to split the string by datetime in sql

    Hi,
    How to split the string by datetime in sql, I've a table with comments column stores comments by datetime, while selecting I want to split and show as in rows by each jobref.
    can anyone help me in this please.
    Thanks,

    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call  logged   (28/10/2014 14:56:58) xyz ..... call updated   (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call  logged   (29/10/2014 14:56:58) xyz ..... call updated   (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call  logged   (30/10/2014 14:56:58) xyz ..... call updated  
    output:
    1) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910201'
     2) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910201'
    3) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910201'
    4) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910202'
     5) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910202'
    6) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910202'
    7) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910203'
     8) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910203'
    Thanks,
    See this illustration
    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated','Vi2910203'
    SELECT LEFT(p.u.value('.[1]','varchar(max)'),CHARINDEX(')',p.u.value('.[1]','varchar(max)'))-1) AS [Date],
    '(' + p.u.value('.[1]','varchar(max)') AS comments,
    lbiref
    FROM
    SELECT lbiref,CAST('<Root>' + STUFF(REPLACE(comments,'(','</Data><Data>'),1,7,'') + '</Data></Root>' AS XML) AS x
    FROM @callcentre c
    )t
    CROSS APPLY x.nodes('/Root/Data')p(u)
    and the output
    Date comments lbiref
    28/10/2014 14:56:14 (28/10/2014 14:56:14) xyz ..... call logged Vi2910201
    28/10/2014 14:56:58 (28/10/2014 14:56:58) xyz ..... call updated Vi2910201
    28/10/2014 14:57:41 (28/10/2014 14:57:41)xyz ..... call updated Vi2910201
    29/10/2014 14:56:14 (29/10/2014 14:56:14) xyz ..... call logged Vi2910202
    29/10/2014 14:56:58 (29/10/2014 14:56:58) xyz ..... call updated Vi2910202
    29/10/2014 14:57:41 (29/10/2014 14:57:41)xyz ..... call updated Vi2910202
    30/10/2014 14:56:14 (30/10/2014 14:56:14) xyz ..... call logged Vi2910203
    30/10/2014 14:56:58 (30/10/2014 14:56:58) xyz ..... call updated Vi2910203
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to get prepared string before sending to sql

    Hi
    I want the prepared string before sending to Sql (After substitution and setXXX), is it possible to do this? if yes, how ?
    PreparedStatement ps = cn.prepareStatement("select * from table1 where name= ''?'' ");
    ps.setString(1, "mytable")
    <-- I want the prepared string before sending to Sql (After substitution and setXXX) -->
    ResultSet rs = ps.executeQuery();
    Thanks
    Ali

    As I mentioned, I want Sql Text before execution
    n (getting resultSet), and after whole of setXXXs,No way, I believe.
    I have tried in many ways, let me put down my work.
    String query = "'Select * from dept where deptno=?'";
    System.out.println("Before : "+query);
    PreparedStatement ps = con.prepareStatement("select "+query+",? from Dual");
    ps.setInt(1,50);
    ResultSet rs = ps.executeQuery();
    if(rs.next()) {
    System.out.println("After : "+rs.getString(1));
    ps.close();
    con.close();I have tried in these lines, to capture the sql query, but it is failing at execution and the exception is 'bind variable not found'. So, I think you need to implement your own class to construct this query. Getting the details from DatabaseMetadata to see how the driver's setter methods works and you can use the same logic in your custom class.
    Good luck.

  • Row comparision in PL/SQL

    Hi
    I want do row comparision in pl/sql using if condition.
    I have data in pl-sql table.
    Lead/Lag function can be used in sql only??
    If i want to compare row without writing query, is there any
    option available??
    Thanks in advance.

    To tag onto Blu's coments... just what are your data doing in a "PL/SQL table" and not in a proper and real Oracle table?
    Oracle most basic core feature that makes Oracle in "the" RDBMS on this planet is its ability to crunch data. With a rich feature set of diverse indexes, partitioning, clustering, IOTs, etc.
    Now why would you want not to use that, and instead stuff data into an array in a programming language? What benefits are there dealing with a very rigid and very primitive data structure such as an array.. when you have Oracle tables to use?
    This does not imply that arrays are "bad things".. not at all. These are (primitive) data management tools within the context of dealing with local programming data.
    But as soon as you want to run SQLs on it.. or view with envy the SQL functions that are available for crunching data.. that tells me that your data is very much in the wrong place. It should be inside Oracle (as a table or temp table).. not inside an array in PL/SQL (or in an array in any other language for that matter).

  • Strings comparision and get unique string in pure sql,

    Dear all,
    Here is two strings
    S1='A,B,C,D,F';
    s2='C,F,H,B,A,K';
    output should be like unique string values ..
    S3= A,B,C,D,F,H,K;
    How to get this in pure sql..
    thanks in advance,
    Roots

    Hi,
    In a relational database, each column of each row should store one value, not a repleating group of values, such as a delimited list. This is so basic to database design that it is called "First Normal Form". You don't have to follow rules like this, but, if you don't, your code will be complicated, inefficient, and error-prone. It sould be best to re-design your application so that each value was on a separate row.
    If you can't do that, then you can start by splitting your delimitd lists into separate rows. Then you can easily fond the distinct values, and use any String Aggregation technique to combine the results into one output row.
    Here's one way to do all that:
    WITH     got_params     AS
         SELECT     'A,B,C,D,F' AS str, 1 AS str_id     FROM dual     UNION ALL
         SELECT     'C,F,H,B,A,K',          2            FROM dual
    ,     got_part_cnt     AS
         SELECT     str
         ,     1 + LENGTH (str)
                - LENGTH (REPLACE (str, ','))     AS part_cnt
         FROM    got_params
    ,     cntr          AS
         SELECT     LEVEL     AS n
         FROM     (
                  SELECT  MAX (part_cnt)     AS max_part_cnt
                  FROM    got_part_cnt
         CONNECT BY     LEVEL     <= max_part_cnt
    ,     got_substr     AS
         SELECT DISTINCT
                REGEXP_SUBSTR ( p.str
                               , '[^,]+'
                        , 1
                        , c.n
                        )          AS sub_str
         FROM    got_part_cnt p
         JOIN     cntr          c  ON     c.n     <= p.part_cnt
    ,     got_r_num     AS
         SELECT     sub_str
         ,     ROW_NUMBER () OVER (ORDER BY  sub_str)     AS r_num
         ,     ROWNUM                                        AS r
         FROM     got_substr
    SELECT     MIN ( SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
                          , 2
             )          AS unique_sub_strs
    FROM    got_r_num
    WHERE     CONNECT_BY_ISLEAF     = 1
    -- START WITH     r_num     = 1
    CONNECT BY     r_num     = 1 + PRIOR r_num
    ;This works in Oracle 10.2.0.2.0 Express Edition, which is the only database I can use right now. For the main query, you should be able to say:
    SELECT     SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
                , 2
                )     AS unique_sub_strs
    FROM    got_r_num
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     r_num     = 1
    CONNECT BY     r_num     = 1 + PRIOR r_num
    ;but, when I try that on my database, I only get 'A,B' as the output. CONNECT BY is very buggy in Oracle 10.2; if you have Oracle 10.1, the simpler form might work.
    The query above can be shortened some, but I wrote it this way to make it easier to understand.
    You can, for example, combine the sub-queries got_sub_str and got_r_num. If you do, use DENSE_RANK instead of ROW_NUMBER.
    This does not assume that the sub-qtrings are all 1-character long. If they are, then the query can be simplified.
    For more about string aggregation, see
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php

  • QSUF (Query string url filter) and SQL Server reporting services report viewer parameters

    Hi,
    this is my issue:
    I have a SQL Server reporting services web part on a page with a report with 1 parameter, lets say it's a client list
    Then i have a QSUF that will be used to filter the clients list through the URL
    However, once i connect the filter and the report viewer web part, the parameter goes away and is no longer accessible
    I'd like to somehow keep the parameter visible, in case there is no parameter sent through the URL, i would like the user to be able to choose a client from the parameter drop down list
    I saw that there is a "send empty if no values are passed" option, but i can't seem to get this working properly and i don't know if this option will make the parameter visible again
    Any help would be appreciated
    Thanks.

    Hi,
    According to your post, my understanding is that the query string url filter web part not worked well with SQL server reproting services web part.
    Did you use the Wiki page layout in your environment?
    You can change the page to a web part page, then check whether it work.
    There is a similar thread for your reference.
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/4d7584e3-8e1a-48bf-9346-32f8cb480dd1/query-string-url-filter-web-part?forum=sharepointgeneralprevious
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Highlight search string in a pl/sql report

    Hi all,
    I followed the example of QBE by Scott Spendolini. I got it working. But I am trying to add the highlight search string functionality, in the report created. The report is created from a dynamic pl/sql query. Can you give me any ideas or an example? Thank you for your time in advance,
    Rgds,
    Suma.

    Hi Suma,
    Your Search button runs a process called "RUN_REPORT". Presumably, this process picks up the values from the tabular form to construct the new SQL statement.
    Given that you don't have a normal report definition - ie one that you can use the Highlight Words option - the only other possibility is to adjust the SQL query results.
    Let's assume that you have in your RUN_REPORT process a variable called vJOB that holds the JOB value from your QBE grid. Your SQL statement could then be adjusted to something like:
    SELECT EMPNO,
    ENAME,
    '&lt;span style="color:red"&gt;' || JOB || '&lt;/span&gt;',
    etc
    FROM EMPTABLE
    WHERE JOB = vJOB;
    Obviously, without seeing your code, I can not say exactly how it should be constructed to highlight the word(s), but the above should give you an idea of what you need to do. If you're still not sure, can you please paste into this thread the RUN_REPORT code.
    Regards
    Andy

  • Send String[][] type to pl/sql procedure from function in App.module

    Hi,
    I use jdveloper 11.1.1.3.0
    I have a pl/sql procedure. the input type argument is 2-dimensional array(TAR) :
    types:
    create or replace TYPE ARRAYWEB as varray(160) of VARCHAR2(200);
    create or replace TYPE TAR as table of ARRAYWEB;
    Procedure:
    PROCEDURE testi(info IN TAR )
    I want to send type String[][] to this procedure from a function in Application module:
    1: String[][] str;
    2: CallableStatement plsqlBlock = null;
    3: String statement = "BEGIN testi(:1); END;";
    4: plsqlBlock = getDBTransaction().createCallableStatement(statement, 0);
    5: plsqlBlock.setArray(1, str); //get error
    6: plsqlBlock.executeUpdate();
    but in line 5 I don't know what type I should use, and this type(Array) doesn't work
    Habib

    Maybe this can help: http://www.devx.com/tips/Tip/22034
    Dario

  • String comparision in reverse order

    Hi all
    i want a logic in plsql which compares string and substring
    and soon from last digit in the number to first digit.
    If condition mets gives out put
    for example my input is
    INPUT = 1234567890
    TO COMPARE WITH a column has list of values like
    1234560000
    1234567000
    1234567800....soon
    so now the condition is
    the input 1234567890 should match with the column value
    1234567890
    if value is not there it should match with
    123456789
    if not 12345678 soon till 1 in reverse comparision

    In SQL:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '123456' col1 FROM dual)
      2  SELECT col1,inp,lvl FROM
      3  (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
      4  dual CONNECT BY level <= LENGTH(:my_num)) x,t
      5* WHERE t.col1 = x.inp
    SQL> /
    COL1   INP               LVL
    123456 123456              6
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '1234567890' col1 FROM dual)
      2  SELECT col1,inp,lvl FROM
      3  (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
      4  dual CONNECT BY level <= LENGTH(:my_num) + 1) x,t
      5* WHERE t.col1 = x.inp
    SQL> /
    COL1       INP               LVL
    1234567890 1234567890         10
    -- in plsql
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2  my_val VARCHAR2(100) := NULL;
      3  BEGIN
      4  FOR I IN REVERSE 1..LENGTH(:my_num) LOOP
      5  DBMS_OUTPUt.PUT_LINE('substring value:'||SUBSTR(:my_num,1,I));
      6  BEGIN
      7  SELECT '123456' INTO my_Val FROM dual WHERE '123456' = SUBSTR(:my_num,1,I);
      8  EXCEPTION
      9  WHEN NO_DATA_FOUND THEN
    10  NULL;
    11  END;
    12  EXIT WHEN my_Val IS NOT NULL;
    13  END LOOP;
    14  DBMS_OUTPUT.PUT_LINE('matched value:'||my_val);
    15* END;
    SQL> /
    substring value:1234567890
    substring value:123456789
    substring value:12345678
    substring value:1234567
    substring value:123456
    matched value:123456
    PL/SQL procedure successfully completed.
    SQL> print :my_num
    MY_NUM
    1234567890

  • String Truncation Exception in SQL Server

    I get an error when issuing an updateRow() after updateString("String Field", "Test"). My exception is:
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]String data
    , right truncation
    at sun.jdbc.odbc.JdbcOdbcResultSet.setPos(JdbcOdbcResultSet.java:5068)
    at sun.jdbc.odbc.JdbcOdbcResultSet.updateRow(JdbcOdbcResultSet.java:4053
    at exuberance.remote.JDBCClient.setFieldValue(JDBCClient.java:446)
    I believe this occurs because Java stores strings in Unicode (2 bytes), but I'm not positive. Any help would be much appreciated.

    You are passing a string that is too big.
    Possibilities:
    -String you are passing is bigger than field it is being inserted into.
    -Total length of SQL call exceeds the max len limit (8000?, 2174?)
    -The string is a actually a 'blob' type of string (greater than 8000 on MS SQL?) and you need to use the same sort of handling for blobs to pass it.

Maybe you are looking for