BITAND for strings

Hello

I need a function to group in a match pattern strings, for example, I have following values and want the following results:

Valuedesired result
01060110106011
0101011010_011
0102011010_011
0103011010_011
0104011010_011
01020128880102012888
010301288801030__888
010301488801030__888
010601201001060__010
010601204201060__010
010601204401060__010
0106012066

01060__010

___ Corresponding gaps are more on position 5-7 and the last 3 or 3 prior to the last 3, but all combinations are possible.

NEEA a function similar to the BITAND function, but for strings. I found no function fitting and speculation, that it must be coded in PL/SQL

I would try to convert the strings to a long binary string, then use the BINAND function, then convert back an own upward.

Any advise or hint or would it be a good way?

sincerely

Custom looking at aggregate function I realize that I am always on the wrong train to slove this. I still need all records of entry as a result, but the aggregate functions return a step all the lines.

So I can't used features custom aggregation, right? I have to write a pl/sql procedure that delivers records as a table or a query right?

User-defined aggregate functions are also activated for analytics.

This is what you need here.

create or replace type patternAggrImpl as object (
  pattern varchar2(4000)
, static function find_match (str1 in varchar2, str2 in varchar2, pad in varchar2 default '_') return varchar2
, static function ODCIAggregateInitialize (ctx in out patternAggrImpl) return number
, member function ODCIAggregateIterate (self in out patternAggrImpl, str in varchar2) return number
, member function ODCIAggregateTerminate (self in patternAggrImpl, returnValue out varchar2, flags in   number) return number
, member function ODCIAggregateMerge (self in out patternAggrImpl, ctx2 in patternAggrImpl) return number
);
/

create or replace type body patternAggrImpl is

  static function find_match (str1 in varchar2, str2 in varchar2, pad in varchar2 default '_') return varchar2
  is
    c          varchar2(1);
    l_pattern  varchar2(4000);
  begin
    if str2 is null then
      l_pattern := str1;
    else
      for i in 1 .. greatest(length(str1), length (str2)) loop
        c := substr (str1, i, 1);
        l_pattern := l_pattern ||
                     case when c = substr(str2, i, 1) then  c else  pad end;
      end loop;
    end if;

    return  l_pattern;
  end;

  static function ODCIAggregateInitialize (
    ctx in out patternAggrImpl
  ) return number
  is
  begin
    ctx := patternAggrImpl(null);
    return ODCIConst.SUCCESS;
  end;

  member function ODCIAggregateIterate (
    self  in out patternAggrImpl
  , str   in     varchar2
  )
  return number
  is
  begin
    self.pattern := patternAggrImpl.find_match(str, self.pattern);
    return ODCIConst.SUCCESS;
  end;

  member function ODCIAggregateTerminate (
    self        in  patternAggrImpl
  , returnValue out varchar2
  , flags       in  number
  )
  return number
  is
  begin
    returnvalue := self.pattern;
    return ODCIConst.SUCCESS;
  end;

  member function ODCIAggregateMerge (
    self in out patternAggrImpl
  , ctx2 in     patternAggrImpl
  )
  return number
  is
  begin
    self.pattern := patternAggrImpl.find_match(self.pattern, ctx2.pattern);
    return ODCIConst.SUCCESS;
  end;

end;
/

create or replace function getPattern (
  p_str in varchar2
)
return varchar2
parallel_enable
aggregate using patternAggrImpl;
/

Query:

select grp
     , bnr
     , getPattern(bnr) over(partition by grp) as pattern
from test ;

GRP      BNR          PATTERN
-------- ------------ -------------
a        6030054010   6030___010
a        6030057010   6030___010
a        6030061010   6030___010
a        6030063010   6030___010
a        6030071010   6030___010
a        6030111010   6030___010
a        6030400010   6030___010
b        6030054034   60300__034
b        6030061034   60300__034
b        6030057034   60300__034
c        6040054034   60400__034
c                     60400__034
c        6040061034   60400__034
d        6130057      61300_____
d        6130054034   61300_____
d        6130061      61300_____

Tags: Database

Similar Questions

  • Is there a bug in CVI 2010 SetTableCellRangeVals and SetTableCellRangeAttribute for strings - particularly in 64-bit mode?

    It seems that I can't get SetTableCellRangeVals to publish string data to a table in 32-bit mode, I can't SetTableCellRangeAttribute to work for arrays of strings and now it seems numbers either. I just get garbage - it could be my code, however.

    Worse in 64-bit mode, I can't seem to post anything (for strings at least), but get a GP fault instead.

    I played with the size of the pointer in the array of strings (from 4 to 8 bytes

    The heart of the test code is here but the files are attached as well.

    int CVICALLBACK Test_callback (int, int int event, control panel,
    void * callbackData, int eventData1, int eventData2)
    {
    int i, numrows = 10, byattrib;
    int bit32 = 1;
    Double * dbl_array;
    char * string_array, * string;
    Rect a_rect;
     
    switch (event)
    {
    case EVENT_COMMIT:
    GetCtrlVal (main_handle, PANEL_BYATTRIB, & byattrib);
    String = malloc (50 * sizeof (char));
    If (bit32)
    string_array = malloc (4 * numrows * sizeof (char));
    on the other
    string_array = malloc (8 * numrows * sizeof (char));
    for (i = 0; i< numrows;="">
    string_array [i] = malloc (50 * sizeof (char));
    dbl_array = malloc (numrows * sizeof (double));
       
    for (i = 0; i< numrows;="">
    {
    dbl_array [i] = i * I * 3.1416.
    FMT (string, "The value is %f", dbl_array [i]);
    strcpy ([i] string_array, string);
    }
       
    a_rect. Top = 1;
    a_rect. Left = 1;
    a_rect. Height = numrows;
    a_rect. Width = 1;
       
    status = DeleteTableRows (main_handle, PANEL_TABLE, 1, -1);
       
    status = InsertTableRows (main_handle, PANEL_TABLE,-1, numrows, VAL_USE_MASTER_CELL_TYPE);
       
    If (byattrib)
    {
    status = SetTableCellRangeAttribute (main_handle, PANEL_TABLE, a_rect, ATTR_CTRL_VAL, dbl_array);
       
    a_rect. Left = 2;
    status = SetTableCellRangeAttribute (main_handle, PANEL_TABLE, a_rect, ATTR_CTRL_VAL, string_array);
    }
       
    on the other
    {
    status = SetTableCellRangeVals (main_handle, PANEL_TABLE, a_rect, dbl_array, VAL_ROW_MAJOR);
       
    a_rect. Left = 2;
    status = SetTableCellRangeVals (main_handle, PANEL_TABLE, a_rect, string_array, VAL_ROW_MAJOR);
    }
       
    free (string);
    for (i = 0; i< numrows;="">
    free (string_array [i]);
    free (string_array);
    free (dbl_array);
    break;
    }
    return 0;
    }

    Thanks for any help,

    Greg

    Greg-

    Certainly, you have found a bug.  However, I think that the issues that you run in a SetTableCellRangeAttribute are the result of a misunderstanding of the function.  This function, when you use it to set the value, sets the values of all the cells in the range to the same value.  Therefore, the var_args parameter must be the value that you want to set all cells to and not a pointer to an array of values.  In your code, you would need dereference the berries, and then, you would see that all the cells are the same value, which is the expected behavior.

    I created a bug report for the accident which follows from the definition of values on string cell types in 64 - bit with ID 284842.  This bug will be fixed in the next version of maintenace of the CVI.  In the meantime, you should be able to use SetTableCellVal to set the value of each cell individually in 64-bit.

    I'm sorry for the inconvenience-

    NickB

    National Instruments

  • Create endpoint network Stream - pre-allocation for strings

    Hello

    I would use really allocation entry mode to pre-allocate memory on my RT goal. My concern is how to allocate memory for the size of the string.

    Because of the documentation

    "pre-allocate specifies that memory allocation buffer occurs when the end point is created. Wired for the type of input data determines the amount of memory allocated for each item. If a greater element is added to the buffer during execution, the extra memory is allocated dynamically. "

    I understand that if I am wiring constant string to the category data, 40 to the size of the buffer I receive buffer to 40 channels. String but how long? A single character?

    I don't want to let the Manager of memory to run after the creation of endpoint, so I would allow large memory space (for example 40 string, 10 characters each).

    Is it possible to do constant connection string (for example with 10 characters) or I have to put my string specific to the cluster size?

    Another question of trival perhaps, is - it possible to check what size buffer was allocated by this VI?

    Kamil

    Hello

    Here is some additional information on the allocation of memory for network streams:

    http://www.NI.com/white-paper/12267/en/

    My guess is that in order to pre-allocate buffers to not scalar data types, you'll write 'false' elements of the size desired in the stream to read or to flush out these elements "dummy" bevore using the flow in normally.

    Best regards!

  • How to type work of casting for string to U16

    Hello

    Sorry for typing on the same subject, but I still don't understant what do happen when I type the 2-byte in U16 distribution chain. Could you please explain me this?

    Kind regards

    __behemot_

    Hello

    All ASCII characters are represented by 8 bits in memory. If you imagine these 8 bits, you can concatenate the. Who will be the 16-bit long integer (in this case, when you have a chain of 2 elements) and of course not signed, because there is no defined sign in ASCII values.

    So the two integers and character are represented in the same way in the memory, but LabVIEW knows what type is stored in variable. If you working with ASCII characters you'd have numbers, you must convert it in full then you can multiply it and etc. For example, if you want to change 'a' to 'A', you can convert it to integer U8 you must subtract 20 from her and typecast to character (string 1 element).

    I hope that this will help you understand the type cast. If you have any other questions, please write again.

    Kind regards

    Peter

  • How to allocate memory for string

    How to allocate memory in LabVIEW for char []?

    The table is:

    char ProjectName [260].

    I still have 4 lu byte string Unflatten, suggestions?

    TIA.


  • Poor supported for string functions in ExtendScript Javascript?

    Differences between JS and JSX is really annoying during the development of the panels, as some things work for one language and not the other.
    I just noticed that the endsWith () - string function does not work in JSX. I'm just checking if a layer name ends with a special character, like this:

    alert("lolk_".endsWith("_"));
    

    This will stop executing the script. Come on! Do I really need to use a regular expression for this kind of things super simple? This is ridiculus!

    [PS script] ExtendScript supported ECMAScript 6th version | Community customer Photoshop family

  • How to search for strings of characters defined, including accents in sqlplus?

    Hello

    the task is to find all the entries in the table produced in coloumn txtvi [defined as: VARCHAR2 (40 BYTE)] where the chain consists not only of these characters:

    -_ #., 0 - 9 a - za - zaouaou)

    The result set should be stored with characters that are not allowed.

    Example "Ziel/result" is not allowed; the "/" is not in the above defined characters

    DB-Version: 10.2.0.4.0

    NLS settings have the value:

    NLS_LANGUAGE AMERICAN

    NLS_CHARACTERSET UTF8

    First attempt was to use regular expressions in sqlplus:

    Select txtvi from product including the no regexp_like (txtvi,'^ [-_ #., 0 - 9 a - za - zaouaou ()] + $') order of txtvi.

    All combinations in the regexp_like has not given the correct result. As a result all games I found permits strings with accents.

    That would be the problem?

    Now, I started to watch all the channels with the German umlaut 'a' only.

    I've known that there are several titles with 'a '. An example: '% Fahrgastzahler % '.

    I started sqlplus in shell Korn on AIX 6.1 ($nls_lang = AMERICAN_AMERICA. UTF8)

    to find all strings containing a German umlaut:

    SQL > select txtvi from product where txtvi like '% a % ';

    ERROR:

    ORA-01756: city not properly finished chain

    I thought to do a simpler test:

    SQL > select 'a' twice.

    ERROR:

    ORA-01756: city not properly finished chain

    With 'o'.

    SQL > select 'o' double;

    '

    -

    o

    With

    SQL > select text product where the text like "% number % ';

    TXTVI

    ----------------------------------------

    Fahrgastzahlung #27N0

    Investigation Fahrgastzahler

    Great, there is a result. But it is not a solution. I'll find all rows with accents.

    Why is there an error ora-01756? I get the same error with the German ss, but u works as o.

    Only a problem in point 10.2?

    A test more in DB-Version: 11.2.0.3.0 with NLS_CHARACTERSET AL32UTF8

    and sqlplus ($nls_lang = AMERICAN_AMERICA. UTF8)

    SQL > select 'o' double;

    '�'

    ---------

    is

    SQL > select 'a' twice.

    ERROR:

    ORA-01756: city not properly finished chain

    No possible use of sqldeveloper:

    The sqldeveloper on a Win7 customer were not properly demonstrating accents. Results of German umlauts are empty every time.

    Yes, there is a problem with accents.

    Any idea how this problem can be solved?

    My suspicions were confirmed. The result of DUMPING indicates that problematic content is encoded in WE8ISO8859P1/WE8MSWIN1252 and not in UTF8, as it should. You see that the binary code of 'u' is 0xFC and for "O" 0xD6. Here's the WE8ISO8859P1/WE8MSWIN1252 codes, not UTF8 codes.

    Similarly, the test with "od" shows the code for "o" as 0xF6 on your terminal. It is, once again, a code WE8ISO8859P1/WE8MSWIN1252 and not UTF8 code, so the value of NLS_LANG is incorrect. Character set NLS_LANG must match the source of data, not the database character set. You correctly see the umlauts on the screen, because the screen is configured to WE8ISO8859P1 or WE8MSWIN1252 and these codes are retrieved not converted (NLS_LANG = DB charset).

    You should:

    1 recode your data to the right encoding, for example with the UPDATE tab1 SET col1 = CONVERT(col1,'UTF8','WE8MSWIN1252') WHERE... Note that this conversion be done several longer strings, so you must make sure that they will always go in the target column and you do not get errors "value too long."

    2. review and correct the NLS_LANG value for all customers. The mentioned AIX session should run with NLS_LANG value WE8ISO8859P1. You will see the data correctly with this setting once the data are converted as described in 1 above.

    Your tests research should work much better with a correct database.

    Thank you

    Sergiusz

  • Generic search for string

    PLEASE HELP ME...

    I HAVE A TABLE THAT IS

    WITH T AS

    (

    SELECT "MS 16 MM ARCHING HORN" DOUBLE NAME

    UNION ALL

    SELECT "MS 16 MM ARCHING HORN" DOUBLE NAME

    UNION ALL

    SELECT "EN-8 HEX LOCK NUT M20" DOUBLE NAME

    UNION ALL

    SELECT "EN-8 HEX LOCK NUT M20" DOUBLE NAME)

    SELECT * FROM T

    CASE 1->

    WHEN I SEARCH FOR "HORN ARCHING."

    SO I WANT TO OUTPUT LIKE

    OUTPUT-

    1-MS 16 MM ARCHING HORN

    THE 16 MM 2 MS ARCHING HORN

    CASE 2->

    WHEN I SEARCH FOR "NUT M20 LOCK,"

    SO I WANT TO OUTPUT LIKE

    OUTPUT-

    1 EN-8 M20 HEXAGONAL LOCKNUT

    2 EN-8 M20 HEXAGONAL LOCKNUT

    Hello

    Here's one way:

    VARIABLE target_words VARCHAR2 (50)
    EXEC: target_words: = 'HORN ARQUANT ';

    WITH all_targets AS
    (
    SELECT "%" | REGEXP_SUBSTR (: target_words)
    , '[^ ]+'
    1
    LEVEL
    )
    || '%' AS target
    , (MAX LEVEL) (AS target_cnt)
    OF the double
    CONNECTION OF REGEXP_SUBSTR (: target_words)
    , '[^ ]+'
    1
    LEVEL
    ) IS NOT NULL
    )
    SELECT DENSE_RANK () OVER (ORDER BY t.ROWID) n
    MIN (t.nom) AS the name
    T
    JOIN all_targets a ON ' ' | t.Nom
    || ' ' AS a.target
    GROUP BY t.ROWID
    HAVING COUNT (DISTINCT a.target) = MIN (a.target_cnt)
    ORDER BY n
    ;

    This assumes that the words in the target string are unique, that is, it will not be entered as "HORN HORN HORN".  It's not serious if the t.nom words are not unique; in other words, there is no problem if name = "MS 16 MM HORN ARCHING HORN HORN".

    It is not that there is something unique about each line in t.  If t is a real table, then it should really have a primary key, but, otherwise, it will automatically have a unique ROWID (which is what I assumed above).  If t is not a real table and lacks a unique key, you can use the ROW_NUMBER analytic to assign a unique number to each line.  If t is something unique for each line, yopu should use it instead of ROWID.

  • How to get the same functionality for string as java in oracle 10g

    Example:

    In java, if I use
    -> > >
    String.format ("% 03d", 11) then he will give me the result 011
    String.format ("% 03d", 1111) then he will give me the result 1111

    I need also same result in Oracle for a stored procedure. I used to_char() and lpad() function but could not get the desirable.

    I'm new on this. Please forgive for this silly question and help me.

    Or with the prefix "FM", which makes the FILLING for us:

    to_char(col1, 'fm9999099')
    
  • for strings line continuation character?

    In the compiled code, there is a line for the string continuation character? I know I could create a variable and it concatenates himself additional text on each line, but is there something like the following:
    create or replace procedure throw_long_error
    as
    begin
      raise_application_error (-20500, 'You made the mistake of running this procedure and now you have to deal with
                                         a really, really, really, really long error message which informs you of the
                                         unfortunate circumstances within which you now reside.');
    end throw_long_error;
    While the above code compiles and runs, you get line breaks in error output. I had rather he comes out as a string without these Chr (10) | Chr (13) silently included in it.
    BEGIN throw_long_error; END;
    Error at line 1
    ORA-20500: You made the mistake of running this procedure and now you have to deal with
                                         a really, really, really, really long error message which informs you of the
                                         unfortunate circumstances within which you now reside.
    ORA-06512: at "FORBESC.THROW_LONG_ERROR", line 4
    ORA-06512: at line 1
    -= CF

    Why not concatenate the error message so that it envelops of course, unless I misunderstood?

      raise_application_error (-20500, 'You made the mistake of running this procedure and now you have to deal with'
                                         ||' a really, really, really, really long error message which informs you of the'
                                         ||' unfortunate circumstances within which you now reside.');
    
    ERROR at line 1:
    ORA-20500: You made the mistake of running this procedure and now you have to
    deal with a really, really, really, really long error message which informs you
    of the unfortunate circumstances within which you now reside.
    ORA-06512: at line 2
    
  • Search for string in SQL Developer

    Hello

    I am trying to run a search function in SQL Developer, which locates a string in database objects. I can't find out how to do it-if it is possible. I just saw that I can search for objects not strings in their breast. How to find all the procedures/functions which includes a specific string?

    Concerning
    Marika

    Reports | All reports | DataDictionary reports | PL/SQL | Search the Source Code

  • No available comparison for string test?

    I have a string value, I read a USE and I want to connect the value but don't make any comparison of pass/fail. On a test of numerical limit there is the Option no comparison but not so much on string test. I tried to use additional results and documentation of the value, but it transforms into an element of the 2 line and the measure is no longer in the measurement column. Is there a way to make a measure of string looks like the digital limit with no. comparison test?

    Thank you

    JVH

    JVH,

    In the past I just write the value measured at the limit value. This looks like an addition of ideas of forms.

  • Change flag for string

    I have a string indicator that reads from a file and display the contents of the file to the user.

    I would like the user to be able to change the content displayed. How do I do that?

    I can't write in a good indicator? unless it is a control

    Fix.  Make a control.  To put data into a control programmatically, write in a local variable of it.

  • menu ring for string table cluster

    Hello

    I would like to know how to the selections of transfer on a menu of the ring group in an array of strings?

    here a start vi

    Best regards

    Tinnitus

    Tinnitus says:

    here a start vi

    This isn't really much of a departure...

    aeastet:

    I think that tinnitus is actually just the displayed values, rather than the complete list of values. In this case, you actually wish the property of RingText.Text. Also, you need not to use the array to build with a shift register. AutoIndex just output values. If you need to get all possible values, you can simply remodel the 2D table resulting in a 1 d table after the loop.

  • How to handle parsing JSON with Java for String and String []?

    I have a string of JSON (sample) as follows and I created a POJO Mapper using Jackson to manage the same, but as I saw the data I noticed the problem mentioned

    How should I treat the underside of change of the data of String() string in my class Mapper POJO of ideas would be helpful

    < code >

    @JsonIgnoreProperties(ignoreUnknown = true)
    public class Ref implements Serializable {
    
    @JsonProperty("BBT")
      private String BBT;
    
    .... more code here
    
    
    
    //Sample 1
    "Ref": {
          "ISN": "AEBDC44",
          "CCD": "213128908338",
          "BGID": "XCAS3213213",
          "BBS": "23123123",
          "BBT": "CCC",
          "WRT": "POP91230",
          "SDL": "290123",
          "BUN": "ZZRET10PV4",
          "BCSP": "ZZRET10PV4",
          "CSP": "ZZRET10PV4"
        }
    
    //Sample 2
    "Ref": {
          "ISN": "AEBDC44",
          "CCD": "213128908338",
          "BGID": "XCAS3213213",
          "BBS": "23123123",
          "BBT": ["CCC","AAA"],         //Sometimes recevied as an String array instead of String
          "WRT": "POP91230",
          "SDL": "290123",
          "BUN": "ZZRET10PV4",
          "BCSP": "ZZRET10PV4",
          "CSP": "ZZRET10PV4"
        }
    

    < code >

    Found the solution.

    Thank you seems in any case this forum is not very active over after stackoverflow etc. dominating the WRT forums programming and all

    In the case of some1 should

    Change return type

    Converted to object.

Maybe you are looking for

  • lost my iphone6s

    I lost my phone for a week. I want to search my iphone 6 s, 64GB,. my phone details are as follows: IMEI number: *. Serial number: F4 * RXY Reference No..  MKQC2LL/A NO. ICCID *. What should I do to track my phone? Kindly help me. < personal informat

  • Satellite A300-1IK - impossible to update Vista

    Hello I recently reset my Satellite A300 to its default values by using the utility HDDRecovery. Now, the OS is Vista Home Premium SP1, but I'm not able to update vista drivers or get the upgrade to SP2, so I was struck with my SP1 default. I tried i

  • Alert-is this Message from Apple for real?

    This message just popped up. Actors it look legit or is it a scam? I immediately close Safari when it appeared.

  • Operating system has been installed on the D drive

    Original title: recovery I used my windows xp system restore disk... but he has everything installed on drive D instead of C... now, what I'm trying to install wants to install on D... So it is now nearly full and there is almost nothing about it...

  • Film Windows maker-impossible to edit clip

    Director of Windows (edit a clip) I try to use windows movie maker... but there is a clip that I can't change.  Whenever this clip comes up it shows the name of the person in the photo and I do not know how to take off... need quick help thank you