To truncate n SubString

good evening. i'm looking for a particular example of coding specifically targeted to this purpose:-
1) Truncate from Side A(where it's a record document listing a few string values) to a single value string(in Side B)
2) And to convert the single value string(in Side B) back to a record document with multiple string values(in Side A). [would substring be used here?]
thanks!

I'd make 2 methods for Record: toString() and fromString()
ie,
public String toString()
    return string1 + ":" + string2 + ":" + string3;
public static Record fromString(String data) throws InvalidRecordException
    try
        StringTokenizer stk = new StringTokenizer(data,":");
        return new Record(stk.nextToken(), stk.nextToken(), stk.nextToken());
    catch(Exception e)
        throw new InvalidRecordException();
}Something like that. Depends on what the variables are. Also if you want to use toString() for displaying your object, you might want to make it slightly more readable, maybe using ", " instead of ":"
Hope this helps,
Radish21

Similar Messages

  • Text display, truncate with "...", how to?

    I would like to display long text fields in a truncated format, limited to a certain length. If the length is within the limit, display normally. If the length is > limit, cut it off and append "..." .
    This is the way the Feedback field is displayed in Apex Team Development, on pls/apex/f?p=4800:8000. It looks like they set the limit at 100 characters. For example:
    Normal:
    Are the menu paths what's configured in EBS, or paths where there are violations?
    Truncated:
    Reconcile the counts to p.6 Violations' reconcile counts report. Should work at the summary level b...
    When I inspect that display element, here's what I find.
    The unexpanded version is: <td align="left" headers="FEEDBACK_COMMENT">...</td>
    When I expand the element I see the full text: <td align="left" headers="FEEDBACK_COMMENT">Reconcile the counts to p.6 Violations' reconcile counts report. Should work at the summary level b...</td>
    Any help or pointers would be appreciated.

    Andy,
    Thanks for the pointer. The discussion included the REGEXP_SUBSTR function. Which suggested the SUBSTR function to truncate the field, which is all I need.
    So my simple solution can be to select the long text field twice in the interactive report, once full length, and once truncated by SUBSTR concatenated with '...'. Then the user can make reports with either, and the single full record view will have both.
    Skip

  • Flat file truncation issue

    I am attempting to perform a fairly standard operation, extract a table to a flat file.
    I have set all the schemas, models and interfaces, and the file is produced how I want it, apart from one thing. In the source, one field is 100 characters long, and in the output, it needs to be 25.
    I have set the destination model to have a column physical and logical length of 25.
    Looking at the documentation presented at http://docs.oracle.com/cd/E25054_01/integrate.1111/e12644/files.htm - this suggests that setting the file driver up to truncate fields should solve the issue.
    However, building a new file driver using the string 'jdbc:snps:dbfile?TRUNC_FIXED_STRINGS=TRUE&TRUNC_DEL_STRINGS=TRUE' does not appear to truncate the output.
    I noticed a discrepancy in the documentation - the page above notes 'Truncates strings to the field size for fixed files'. The help tooltip in ODI notes 'Truncates the strings from the fixed files to the field size'. Which might explain the observed lack of truncation.
    My question is - what is the way to enforce field sizes in a flat file output?
    I could truncate the fields separately in each of the mapping statements using substr, but that seems counter-intuitive, and losing the benefits of the tool.
    Using ODI Version:
    Standalone Edition Version 11.1.1 - Build ODI_11.1.1.5.0_GENERIC_110422.1001

    bump
    If this is an elementary issue, please let me know what I've missed in the manual.

  • Assign substitution variable to another substitution variable with truncation of value

    I launch a sql*plus .sql script by way of a concurent job. The concurrent job provides a date paramenter to the script.  Job log shows the date passed to scrpit as:
    Arguments
    2013/09/01 00:00:00
    For cosmetic purposes in the ouput's heading, I want to convert/truncate the character string to an end-user format of 2013/09/01.
    Trying to simply change one substitution variable
    (below is not working, but hopefully telegraphs my intention:
    UnDefine Low_date
    Define Low_date = '2013-09-01 00:00:00'
    UnDefine Low_date_10
    Define Low_date_10 = 'yyyy-mm-ds'
    select substr('&Low_Date',1,10) into &Low_date_10 from dual;
    prompt "Variable value is: &Low_date_10"
    WHICH PRODUCES:
    old:select substr('&Low_Date',1,10) into &Low_date_10 from dual
    new:select substr('2013-09-01 00:00:00',1,10) into yyyy-mm-ds from dual
    Error starting at line 8 in command:
    select substr('2013-09-01 00:00:00',1,10) into yyyy-mm-ds from dual
    Error at Command Line:8 Column:55
    Error report:
    SQL Error: ORA-00905: missing keyword
    00905. 00000 -  "missing keyword"
    *Cause:   
    *Action:
    old:prompt "Variable value is: &Low_date_10"
    new:prompt "Variable value is: yyyy-mm-ds"
    "Variable value is: yyyy-mm-dd"
    "I need to get to "Variable value is: 2013/09/01"

    Hi,
    SELECT ... INTO only works in PL/SQL.
    In SQL*Plus, you can use COLUMN ... NEW_VALUE, like this:
    DEFINE  low_date = '2013-09-01 00:00:00'
    COLUMN low_date_10_col        NEW_VALUE  low_date_10
    SELECT  REPLACE ( SUBSTR ( '&Low_Date', 1, 10)
                    )    AS low_date_10_col
    FROM  dual;
    PROMPT  Variable value is: &Low_date_10

  • BIP truncating long varchar2 values?

    Okay, I readily admit I'm new to BIP, and I may well be making a stupid newbie mistake here.
    I have a relatively simple query defined for a report:
    select cio_s_num, potential_source
    from cio_s_format
    order by cio_s_numwhich is hitting an Oracle 10g schema/table. The 'potential_source' column is a varchar2(500), and there are values that vary in length from 2 chars to 250+.
    When I save this query, and view the output in 'Data' format (aka the generated XML), BIP is truncating all the potential_source values at 175 characters. If I put together a template and generate PDF or HTML output, I see the same truncation.
    The same table and query can be run in SQL*Plus, or in an Apex application, without any truncation problems.
    I've checked for strange/unprintable characters in the data, but found nothing unusual.
    I've tried doing a to_clob() conversion in the query - no change in behavior.
    I've tried outputting length(potential_source) -- it's correct for shorter values but never greater than 175.
    I've tried using substr() to fetch the string in sections -- apparently it sees no data beyond 175.
    Running BIP 10.1.3.4, querying against Oracle 10g.
    Is this a known limitation of BIP that my searches didn't uncover? A bug? A stupid user trick?
    Thanks

    New piece of information to throw in the mix -- a DBA checked a change log, and the POTENTIAL_SOURCE column in the table was at one point altered from varchar2(175) to varchar2(500). The table wasn't rebuilt or anything, a simple ALTER TABLE .. MODIFY command was used.
    Could this be causing the data read problems -- whatever software/driver BI is using to talk to Oracle doesn't look for the "... oh, and there might be more data for that field over HERE" flag?
    I've also tried adding a second long varchar2 column to the query (one our DBA has no record of previous altering), and the second column is NOT truncated. So the general functionality seems fine in our environment, it's some related to this data and/or table.

  • Photoshop CS6 using javaScript to truncate alpha channel name

    Hello,
    I'm a production artist and I work with PSD files that were created in Adobe Scene7 Image Authoring Tool. These PSDs contain a background layer along with 1-20 alpha channels. My script has to make a new blank layer for every alpha channel in the document. Then it fills the new layer with light gray. So far, my code accomplishes this. However, I'd like to apply the name of the alpha channel to the layer, but I need the name to be truncated. Every alpha channel starts with one or more characters followed by a backslash and then finishes with one or more characters. Here's an example:
    An alpha channel might be named:  Floor\floor
    In this example I need my layer name to be just:  floor. This means all character to the left of the backslash, including the backslash itself needs to be discarded. I was using the subSring() statement to do this. When I try to step through the code, line by line in ExtendScript, I immediately get an error that says Unterminated String Constant and Line 31 of my code is highlighted. I suspect it doesn't like the way I wrote the backslash character, although I surrounded it in double quotes to define it as a string.
    Can anyone tell me why I'm getting this error?
    Below is my code with lots of comments to walk you through the process. I wrote where the error occurs in red type.
    I'm new to JavaScript so I'm not sure my while loop is accurate.
    #target photoshop
    // The #target photoshop makes the script run in PS.
    // declare variable to contain the active document
    var myDoc=app.activeDocument;
    // declare variable to contain the number of alpha channels, excluding the RGB channels
    var alphaChan = myDoc.channels.length - 3;
    alert(alphaChan + " alpha channels exist");
    // create loop to make new layers based on number of alpha channels, fill layer with gray and apply alpha channel name to new layer
    for (a=0 ; a<alphaChan ; a+=1){
    // make new blank layer
    myDoc.artLayers.add();
    // fill blank layer with gray
    var color = new SolidColor();
    color.rgb.red = 161;
    color.rgb.green = 161;
    color.rgb.blue= 161;
    myDoc.selection.fill(color);
    //variable stores alpha channel name
    var alphaName = myDoc.channels[3+a];
    // variable stores lenght of alpha channel name
    var lz = alphaName.length;
    // declare index variable to initialize position of 1st  character of alpha channel name
    var x= 0 ;
    // truncate alpha channel name by removing all characters preceding the "\" symbol
    while (alphaName.subString(x) != "\"){          (ExtendScript gives an error for this line and highlights the backslash and surrounding quotation marks)
        alphaName = alphaName.subString((x+1),z);
        x+=1;
        z-=1;
    return alphaName;
    // remove the backslash from alpha channel name
    alphaName = alphaName.subString((x+1),z);
    //  apply truncated alpha channel name to corresponding layer
    myDoc.artLayers[a].name = alphaName;

    while (alphaName.subString(x) != "\"){ 
    should be
    while (alphaName.subString(x) != "\\"){ 

  • Truncating last character in a string

    I am making a dialpad. It is just for display so I am using a
    string for the numbers selected. I am trying to make a back button
    that would clear the last number added. I tried mystring.length-1
    but that doesn't seem to be doing the trick. Is there a simple way
    to truncate the last character in a string, of variable
    length??

    Here's an example
    var someStr="asdfasdf saf asdf sadfas dfs fsa asf";
    while (someStr.length) {
    someStr = someStr.substring(0,someStr.length-1)
    trace(someStr);
    }

  • XSL and string truncation

    Hello
    i am creating a XSL to transform some XML information into a CiscoIPPhoneMarkupLanguage document (CIPML). CIPML's schema restricts several element's lenght. For instance, a CiscoIPPhoneMenu/MenuItem/Name must be no more than 64 characters long. I would like that the XSL stylesheet handle the truncation of (eventual) extra characters, but I did not see how it is possible in the w3c TRs. Do you know how?
    THx

    I don't see the Java connection in this question, but XSL does have a substring function.

  • Regarding String truncation

    Hello all,
    I have got a small problem. Hope you will help me.
    I have got a text String which contains both single byte characters and multi-byte characters mixed up(English characters and non-english characters) which i need to insert into database table. Now the database column is set to store a text of maximum length of 100 bytes so it is required to truncate the string before insertion. Now the problem is when i extract the first 100 bytes from the string, the last character of the string sometimes gets changed( due to extracting only first byte of multi-byte character). The dumbest solution I thought to get around this is something like this:
                    //Here remarks contains the string value
         if (null!= remarks && remarks.getBytes().length > 100 ) {
                          while (remarks.getBytes().length > 100) {
                               remarks = remarks.substring(0, remarks.length()-1 );
                     }I am wondering is there any other elegant solution for this as the loop part is time-consuming and moreover, i am inserting the records in a count of thousands.

    Thanks for your reply
    Why do you have to do that on your own? It's the databases task to correctly truncate a String, if necessary (and inform you of the fact by issuing a Warning).
    But when i insert a string of size greater than 100 bytes i am getting an SQL Exception.
    Also, is the size of the text field really restricted by the number of bytes instead of the number of characters? I've seen that in some DBs (can't remember which ones), but it's a pretty bad idea and fortunately not all do it that way.
    I am using Oracle9i and the size of text field is restricted by the number of bytes.
    Also, your code assumes that the database uses the same encoding as the default locale of the machine running your code. Workaround: find out the encoding of the Database and use that when calling getBytes().Points taken. Thanks.

  • File_To_RT data truncation ODI error ORA-12899: value too large for colum

    Hi,
    Could you please provide me some idea so that I can truncate the source data grater than max length before inserting into target table.
    Prtoblem details:-
    For my scenario read data from source .txt file and insert the data into target table.suppose source file data length exceeds max col length of the target table.Then How will I truncate the data so that data migration will be successful and also can avoid the ODI error " ORA-12899: value too large for column".
    Thanks
    Anindya

    Bhabani wrote:
    In which step you are getting this error ? If its loading step then try increasing the length for that column from datastore and use substr in the mapping expression.Hi Bhabani,
    You are right.It is for Loading SrcSet0 Load data.I have increased the column length for target table data store
    and then apply the substring function but it results the same.
    If you wanted to say to increase the length for source file data store then please tell me which length ?Physical length or
    logical length?
    Thanks
    Anindya

  • Truncate row output on report

    I have a report which outputs 14 columns so the width on the columns is limited. In the report I allow csv output. However, the output on some of the columns can contain more than 1000 characters. The landscape quickly becomes crowded.
    So I used substr(details, 0, 250) for those 2 columns in my query but when I export it also truncates the output on the csv file.
    Is there a way supported by APEX that will allow me to truncate the number of characters displayed per column on the report but include all information when exported to a csv file?

    One way could be to write your own export program, there is a thread on the forum that tells you exactly how do write your own export to CSV functionality. Sorry for not remembering the exact thread URL
    Cheers,
    Andy

  • Recordset truncating field data

    Hi
    I'm using a recordset to return a field within a particular table which contains a large amount of text, which I need to output to a text file. Currently I am just using the recordset to output the field and then set the text file to contain this value, however the recordset object seems to be truncating to text to around 32000 characters (32KB).
    I've had a look around the forum and did see that someone thought this was a problem with the DI and that the recordset object cannot return text greater than 32000 characters.
    Is this so? And if so are there any workarounds using the DI or would I have to use an object such OLEDB?
    Thanks
    Steve

    Hi Steven,
    You could use an OLEDB connection to read the data. The only issue with this is that you can't pass the database connection properties from the DI API to your OLEDB connection so you'd have to store them somewhere in the database or in an external data store (eg config file or registry) and preferably in an encrypted format.
    There are workarounds for getting past the 32K limit. You can use the Substring command as part of your query to split the ntext data in to smaller strings which won't be truncated by the Recordset object. You can then recombine them afterwards.
    eg
    SELECT
         substring(U_MyField, 1, 4000) as Sub1,
         substring(U_MyField, 4001, 4000) as Sub2,
         substring(U_MyField, 8001, 4000) as Sub3
         --- etc etc
    FROM [@MYTABLE]
    Note that the substring command has a max length limit of 4000 characters.
    If you want to get clever you can query the field to find out the maximum length in your field:
    select max(datalength(U_MyField)) / 2 from [@MYTABLE]
    Note you have to divide by 2 to get the character length as datalength returns the number of bytes and it's 2 bytes per character in an ntext field.
    Once you know the max length you can dynamically create your query so it will always have enough substrings to retrieve all the data.
    Hope that makes sense.
    Kind Regards,
    Owen

  • ORA-12899 : Does it exist an option to truncate automaticly the data too...

    Hi,
    I work on a migration project : Sybase to Oracle 10g.
    There are a lot of request INSERT writed in Sybase with data too long to be insert in a table.
    Example :
    create table MyTable (txt varchar(10))
    insert into MyTable values ('AAAAAAAAAAAAAAAAA');
    So, i have lot of error ORA-12899 ...
    With Sybase, there isn't error because the data are automaticly truncated.
    Does it exist an option with Oracle to have the same behavior ? Without option, i have to add substr in many request.
    Any idea ?

    Here is another possibility you may want to consider,
    1. make the column generously large, enough that you can be sure it accommodates the longest string.
    2. load the data
    3. once the data is loaded write a simple query that tells you the length of the longest string that got loaded in the column
    4. alter the column to be of a more reasonable size considering step 3.
    This way, no need to substr everywhere and truncate values that should not have been truncated in the first place. If you do need to end up truncating the values, it will still be easier to do it once the data is loaded in a table than it is to cherrypick statements to modify in script.
    HTH,
    John.

  • ORA-12899 - is it possible to truncate automatically

    I know why I am getting ORA-12899. Instead of rolling back the transaction, I am wondering if it is possible to let Oracle truncate data automatically so that update/insert succeeds. There are cases that auto-truncation is acceptable.
    I am using Oracle 10 with Hibernate.
    Thanks in advance.

    Well,
    >
    ORA-12899:
    value too large for column string (actual: string, maximum: string)
    Cause:     An attempt was made to insert or update a column with a value which is too wide for the width of the destination column. The name of the column is given, along with the actual width of the value, and the maximum allowed width of the column. Note that widths are reported in characters if character length semantics are in effect for the column, otherwise widths are reported in bytes.
    Action:     Examine the SQL statement for correctness. Check source and destination column data types. Either make the destination column wider, or use a subset of the source column (i.e. use substring).>
    Now can you just tell what do you mean by "auto truncate" and how it does relate to this error? Also mention your db versio and o/s/.
    HTH
    Aman....

  • String truncation

    is there an easy way to remove x ammount of characters from a
    string value??
    IE:
    var greeting = "hello";
    (truncate 3 char from the end);
    trace(greeting) // "he"

    you can use the substr() or substring() methods of
    strings.

Maybe you are looking for