Write a Get_bit function

Hello

I have a get_bit function in the Postgres database.  In Oracle, there is no built-in function to manage the get_bit.    I need to write my custom Oracle PLSQL function to mimic the behavior of this get_bit function.  Can we have suggestions on how to do it?   Thank you!

Get_bit definition is as follows:

Function

Return type

Description

Example of

Result

GET_BIT (String, offset)

int

Excerpt from bit string

GET_BIT (E 'Th\\000omas': bytea, 45)

1

GET_BIT (String, offset)(returns int)
Excerpt from bit string
GET_BIT (E 'Th\\000omas': bytea, 45) = > 1

Note that the bits in a byte are numbered with the least significant bit being the bit to zero. In the example above, the 'a' is the

byte that is referenced and it contains x '61' = > 0110 0001 and the third bit from left to right (bit 5 from scratch at right) is returned.

I don't know if you need a VARCHAR2 string as input or directly a byte sequence so here's an example that accepts an input VARCHAR2 and an argument optional charset to convert the string in bytes (default is the database character set).

SQL> create or replace function get_bit (
  2    p_str     in varchar2
  3  , p_bit_num in integer
  4  , p_cs      in varchar2 default null
  5  )
  6  return integer deterministic
  7  is
  8    input        raw(32767) := utl_i18n.string_to_raw(p_str, p_cs);
  9    target_byte  raw(1);
 10    output       integer;
 11  begin
 12    target_byte := utl_raw.substr(input, trunc(p_bit_num/8)+1, 1);
 13    output := bitand(utl_raw.cast_to_binary_integer(target_byte) / power(2, mod(p_bit_num, 8)), 1);
 14    return output;
 15  end;
 16  /

Function created

SQL>
SQL> select get_bit('Th'||chr(0)||'omas', 45)
  2  from dual;

GET_BIT('TH'||CHR(0)||'OMAS',4
------------------------------
                             1

Tags: Database

Similar Questions

  • How to write a decryption function?

    Hi! everyone ,


    I see one encryption function in my database.


    Select f_pwd_encrypt ('password') of double


    -> 12412913141313139139130121


    My question is


    How to write a decryption function?


    As:


    Select f_pwd_decrypt ('12412913141313139139130121') of double


    ->password

    CREATE OR REPLACE FUNCTION EPADM."F_PWD_ENCRYPT" ( vpwd in varchar2)
    return varchar2
    is
        vother_p   varchar2(9);
        vtr_pwd  varchar2(2048);
        i       number;
        j         number;
        vsubstr varchar2(9);
        vtemp1 varchar2(08);
        vvalue number := 0;
        vdb_pwd varchar2(100);
    
    
        function str_2_bit(vstring in varchar2)
        return varchar2
        is
           i number;
           vtemp number;
           v1 varchar(2048);
    
    
         function single_byte(vin in number)
           return varchar2
           is
             i number;
             vresult varchar2(08);
             vtemp number := vin;
           begin
             for i in 1..8 loop
               vresult := to_char(mod(vtemp,2))||vresult;
               vtemp := trunc(vtemp/2);
             end loop;
             return(vresult);
           end;
      --
        begin
          for i in 1..lengthb(vstring) loop
            select to_number(substrb(dump( vstring ,10,i,1),instr(dump( vstring ,10,i,1),' ',-1)+1))
              into vtemp
            from dual;
            v1 := v1 || single_byte(vtemp);
          end loop;
    
    
          return(v1);
        end;
    
    
    begin
      vtr_pwd := str_2_bit(vpwd);
      vtr_pwd := substrb(vtr_pwd,4)||substrb(vtr_pwd,1,3);
      vvalue := 0;
      vdb_pwd := null;
    
    
       for i in  1..(lengthb(vtr_pwd)/4)  loop
         vtemp1 := substrb(vtr_pwd,(i-1)*4+1,4);
         for j in 1..4 loop
           vvalue :=  vvalue + to_number(substrb(vtemp1,j,1)) * power(2,j-1);
           dbms_output.put_line(j||' '||vvalue);
         end loop;
              vdb_pwd := to_char(vvalue) ||vdb_pwd;
              vvalue := 0;
       end loop;
      return(vdb_pwd);
    
    
    END;
    /
    

    OK, after reviewing the, I don't think you'll be able to write a function of decryption for him.

    The first thing he does is take the ascii value of each character in the password and converts them into a binary string.  The code it uses is far too complex and can be simplified, but which is not a problem here.

    I've recreated the first step of SQL like this...

    SQL > ed

    A written file afiedt.buf

    1 with chr_val like)

    2. Select level l

    3, dump('password',10,level,1) in the dmp

    4, to_number (substrb (dump('password',10,level,1), instr (dump('password',10,level,1),' ', 1) + 1)) as chr_val

    5, ascii (substr('password',level,1)) as chr_val - equivalent of extraction of useless dump

    6 double

    7. connect by level<=>

    8        )

    9, r (l, b, ch, chr_val, result, vtemp) as

    10 (select l, 0 b, chr (chr_val), chr_val)

    11, cast (null as varchar2 (8)) as a result

    12, chr_val as vtemp

    13 of chr_val

    14 union of all the

    15 select l, b + 1, b, ch, chr_val

    16, to_char (mod(vtemp,2)) | result as a result

    17, trunc(vtemp/2) as vtemp

    18 r

    where the 19 b + 1<=>

    (20) depth search first by l, defined b seq

    21, as)

    22 select l, ch, chr_val, str_to_bit result

    23 r

    where the 24 b = 8

    25 arrested by l, seq

    26            )

    27 select listagg (ch) within the Group (order) as password

    28, listagg (chr_val, ',') within the Group (order) byte_vals

    29, listagg (str_to_bit) within the Group (order) bit_vals

    30 sec.

    SQL > /.

    PASSWORD BYTE_VALS BIT_VALS

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

    password 0111000001100001011100110111001101110111011011110111001001100100 112,97,115,115,119,111,114,100

    Then he takes this string binary ("bit_vals" in my example) and does the following:

    1. take the first 3 bits of left and to transpose on the right end of the string.

    2 chops the resultant bit string upward into sections of 4 bits (which is known as a 'nibble' inside)

    3. for each bit in the nibble, he treats the bits in binary reverse to normal and gives them a value of 1,2,4 or 8 from left to right for each bit set to 1

    4. for each nibble it adds the value of 1,2,4,8 bits to give a value from 0 to 15

    To show that the use SQL...

    SQL > byte (select ' 0111000001100001011100110111001101110111011011110111001001100100' as pieces of double)

    2, swap3bit as (-take the binary string and put the first bits (high) 3 as a (low) bit of the right hand side)

    3. Select bytes.bits

    4, substr (bit 4) | substr (bits, 1, 3) as init_substr

    5 bytes

    6                   )

    7, split4 as (-chop the string of bits nibbles (half bytes - 4 bits))

    8. Select level l

    9, substr (init_substr, ((level-1) * 4) + 1, 4) as a nibble

    swap3bit 10

    11. connect by level<=>

    12                 )

    13, bitpowers (select l

    14, snack

    15, to_number (substr(nibble,1,1)) * power (2, 1-1) as bitval1

    16, to_number (substr(nibble,2,1)) * power (2, 2-1) as bitval2

    17, to_number (substr(nibble,3,1)) * power (2, 3-1) as bitval3

    18, to_number (substr(nibble,4,1)) * power (2, 4-1) as bitval4

    19, to_number (substr(nibble,1,1)) * power (2, 1-1) +.

    20 to_number (substr (nibble, 2, 1)) * power (2, 2-1) +.

    21 to_number (substr (nibble, 3, 1)) * power (2, 3-1) +.

    22 to_number (substr (nibble, 4, 1)) * power (2, 4-1) as total_val

    23 of split4

    24                   )

    25 select * from bitpowers

    26.

    L NIBB BITVAL1 BITVAL2 BITVAL3 BITVAL4 TOTAL_VAL

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

    1 1000          1          0          0          0          1

    2 0011          0          0          4          8         12

    3 0000          0          0          0          0          0

    4 1011          1          0          4          8         13

    5 1001          1          0          0          8          9

    6 1011          1          0          4          8         13

    7 1001          1          0          0          8          9

    8 1011          1          0          4          8         13

    9 1011          1          0          4          8         13

    10 1011          1          0          4          8         13

    11 0111          0          2          4          8         14

    12 1011          1          0          4          8         13

    13 1001          1          0          0          8          9

    14 0011          0          0          4          8         12

    15 0010          0          0          4          0          4

    16 0011          0          0          4          8         12

    16 selected lines.

    These final values are then re-combination as strings in reverse order so that you get then:

    '12' |' 4'||' 12' |' 9'||' 13'... and so on.

    In SQL...

    SQL > byte (select ' 0111000001100001011100110111001101110111011011110111001001100100' as pieces of double)

    2, swap3bit as (-take the binary string and put the first bits (high) 3 as a (low) bit of the right hand side)

    3. Select bytes.bits

    4, substr (bit 4) | substr (bits, 1, 3) as init_substr

    5 bytes

    6                   )

    7, split4 as (-chop the string of bits nibbles (half bytes - 4 bits))

    8. Select level l

    9, substr (init_substr, ((level-1) * 4) + 1, 4) as a nibble

    swap3bit 10

    11. connect by level<=>

    12                 )

    13, bitpowers (select l

    14, snack

    15, to_number (substr(nibble,1,1)) * power (2, 1-1) as bitval1

    16, to_number (substr(nibble,2,1)) * power (2, 2-1) as bitval2

    17, to_number (substr(nibble,3,1)) * power (2, 3-1) as bitval3

    18, to_number (substr(nibble,4,1)) * power (2, 4-1) as bitval4

    19, to_number (substr(nibble,1,1)) * power (2, 1-1) +.

    20 to_number (substr (nibble, 2, 1)) * power (2, 2-1) +.

    21 to_number (substr (nibble, 3, 1)) * power (2, 3-1) +.

    22 to_number (substr (nibble, 4, 1)) * power (2, 4-1) as total_val

    23 of split4

    24                   )

    25 select listagg (to_char (total_val)) the Group (order of the desc) as pwd

    26 of bitpowers

    27.

    PWD

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

    12412913141313139139130121

    Now, the problem of decryption is that these numbers are concatenated without padding for a fixed number of digits by value, so you don't know if it was

    '12' |' 4'||' 12' |' 9'||' 13'... and so forth as we did it, or whether he was

    '1'||' 2'||' 4'||' 12' |' 9'||' 1'||' 3'... and so on, or any other combination of values from 0 to 15

    There is essentially no information to allow you to divide the string upwards in the correct components to allow the whole process be reversed.

    So, you are out of luck... no chance of decrypting it.

  • write an analytical function custom to get the current time

    Hi all
    I want to write a custom analytical function to get to the current week.
    for example if it is today, January 13, 2012 then during week 2 the analytical function must return true.

    I have an existing analytical function for the passage of time, written by someone else as below.

    Decode (connect_by_root (LASTDATE) - trunc (sysdate),-1, 1, 0)

    here last date it receives from the other query. This function returns me if the current date is passed or not.

    So can someone please tell me how to write a custom function to get the current week.


    Thank you
    Prateek

    Published by: 804658 on January 13, 2012 02:10

    I have an existing analytical function for the passage of time, written by someone else as below.
    Decode (connect_by_root (LASTDATE) - trunc (sysdate),-1, 1, 0)

    Is not an analytic function.

    I guess (because we don't know) that you need a function analytical, because you have a start date, but no end date and so an analysis as an ADVANCE or a DELAY can help you get the end_date.

    If so, then maybe this shows you in the right direction.
    I limited to 5 weeks to keep the short output.
    I chose a start date of January 3, 2012.

    SQL> WITH my_cal AS
      2  (select ROWNUM week_no
      3   ,      TO_DATE('03-JAN-2012','DD-MON-YYYY') + (ROWNUM-1)*7 start_date
      4   FROM   DUAL
      5   CONNECT BY  ROWNUM <= 52)
      6  SELECT *
      7  FROM   my_cal
      8  WHERE  week_no <= 5;
    
       WEEK_NO START_DAT
    ---------- ---------
             1 03-JAN-12
             2 10-JAN-12
             3 17-JAN-12
             4 24-JAN-12
             5 31-JAN-12
    
    SQL>  WITH my_cal AS
      2   (select ROWNUM week_no
      3    ,      TO_DATE('03-JAN-2012','DD-MON-YYYY') + (ROWNUM-1)*7 start_date
      4    FROM   DUAL
      5    CONNECT BY  ROWNUM <= 52)
      6  SELECT week_no
      7  ,      start_date
      8  ,      LEAD(start_date) OVER (ORDER BY start_date) - 1 end_date
      9  FROM   my_cal
     10  WHERE week_no <= 5;
    
       WEEK_NO START_DAT END_DATE
    ---------- --------- ---------
             1 03-JAN-12 09-JAN-12
             2 10-JAN-12 16-JAN-12
             3 17-JAN-12 23-JAN-12
             4 24-JAN-12 30-JAN-12
             5 31-JAN-12
    
    SQL> WITH my_cal AS
      2  (select ROWNUM week_no
      3   ,      TO_DATE('03-JAN-2012','DD-MON-YYYY') + (ROWNUM-1)*7 start_date
      4   FROM   DUAL
      5   CONNECT BY  ROWNUM <= 52)
      6  SELECT *
      7  FROM (
      8   SELECT week_no
      9   ,      start_date
     10   ,      LEAD(start_date) OVER (ORDER BY start_date) - 1 end_date
     11   FROM   my_cal)
     12  WHERE  TRUNC(SYSDATE) BETWEEN start_date AND end_date;
    
       WEEK_NO START_DAT END_DATE
    ---------- --------- ---------
             2 10-JAN-12 16-JAN-12
    
    SQL> 
    
  • How to write a generic function.

    Hello

    Can someone tell me the concept, I have to get hip to in order to write a generic function that will work on any object?

    Here is the project: I'll be show 24 graphs, (imported as Bitmaps and BitmapData jpg), and I would like to create a function where onRollover graph would be tween on twice its size, then come back to the original dimensions when the mouse is released. Pretty simple.

    I'm OK with everything about the import of jpg files and to implement the action of Tweener. And I think it's good to be a better way to write different functions of RollOver and RollOut for each graph, but I must have been absent that day.

    When I use 'this' in the function, it behaves like 'this' is planned: any change! But it's not what I'm shooting.

    I expect to write the function ONCE and apply it to all the graphics after that I have addChild-ed them, but I can't figure out how to set the variable (in the function) which refers to some object (Bitmap graphics) is set up to the course.

    I declare a public variable or something? And match to what is reversed? No need a step by step tutorial, just of me not to point in the right direction. I'll ask Shupe and Rosser. :)

    Oh, uh, Flash CS3, AS3... (I prefer to use the Flash environment because I'm still not enough good for simply create the .as files.)

    Thank you!

    Each of your JPGs load as a MovieClip/Sprite. Say mc1, mc2...
    Then set properties for all the clips as below

    MC1.buttonMode = true;
    MC1.mouseChildren = false;
    MC1.addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);
    MC1.addEvenListener (MouseEvent.MOUSE_OUT, onMouseOut);

    function onMouseOver(evnt:MuseEvent)
    {
    new Tween (evnt.target, "x", Regular.easeInOut, evnt.target.x, evnt.target.x * 2, 5, true);

    new Tween (evnt.target, "y", Regular.easeInOut, evnt.target.y, evnt.target.y * 2, 5, true);
    }

    This is what helped?
    Tell me if you need something more...

  • Cannot write the recursive function in PL/SQL

    I'm down to the following without interest in PL/SQL script:

    Set serveroutput on;

    Set feedback off;

    DECLARE

    recursion_counter NUMBER: = 0;

    function countNum (OUT int counter) return a Boolean value is

    Start

    dbms_output.put_line (Counter);

    If counter > 10 then

    Returns true;

    on the other

    counter: = counter + 1;

    countNum (counter);

    end if;

    end countNum;

    BEGIN

    dbms_output.put_line (case when countNum (recursion_counter) then end if 'false' to 'true');

    END;

    I get the following error:

    PLS-00221: 'COUNTNUM' is not a procedure or is not defined

    and I would really like to know why. The error refers to this line:

    countNum (counter);

    DECLARE

    recursion_counter NUMBER: = 0;

    function countNum (int counter) return a Boolean value is

    Start

    dbms_output.put_line (Counter);

    If counter > 10 then

    Returns true;

    on the other

    Return countNum (counter + 1);

    end if;

    end countNum;

    BEGIN

    dbms_output.put_line (case when countNum (recursion_counter) then end if 'false' to 'true');

    END;

    /

    0

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    true

    SQL >

    SY.

  • Need help to write a Boolean function

    Hello

    I would appreciate you help for writing a Boolean function!


    Below are the possible expressions:

    ${brand.name}

    ${model.name}

    ${franchise.name}

    ${supercategory.name}

    ${category.name}


    VALIDATE any combination of the expressions above (upper and lower case) in a string.


    For example:

    «It's the best brand of ${brand.name} template category, ${model.name} franchise ${franchise.name} supercategory $ {supercategory.name} and ${category.name} category.»


    If one of the above expressions is incorrect in the string, the function returns error.

    I'd appreciate your kind help!


    Thanks in advance!

    Mustak

    Maybe (watching scary)

    with

    data in the form of

    (select txt "this is the best brand of ${brand.name} of model category ${model.name} franchise ${franchise.name} supercategory $ {supercategory.name} and ${category.name} category".)

    of the double

    Union of all the

    Select txt ' is the best brand of ${Brand.name} of model category ${Modl.name} franchise ${Franchise.name} supercategory $ {Supercategoory.name} and ${Category.name} category.

    of the double

    )

    Select sys_connect_by_path (case when instr (lower (txt),' ${' | level case when 1 then 'brand'}))

    When 2 then 'model '.

    When 3 then 'franchise '.

    When 4 then 'supercategory.

    else 'category.

    end: '. (name}') > 0

    then '1'

    else ' 0'

    end,' ') boolean,.

    txt

    from the data

    where connect_by_isleaf = 1

    connect by level<=>

    and prior txt = txt

    and prior sys_guid() is not null

    BOOLEAN TXT
    1 0 1 0 1 It's the best brand of ${Brand.name} template category, ${Modl.name} franchise ${Franchise.name} supercategory $ {Supercategoory.name} and ${Category.name} category.
    1 1 1 1 1 It's the best brand of ${brand.name} template category, ${model.name} franchise ${franchise.name} supercategory $ {supercategory.name} and ${category.name} category.

    Concerning

    Etbin

  • How can I write this small function to create the number of strips, please?

    Guys,

    How can I have a create table according to the argument passed. I'm doing this right?

    function createArray(n:int):Array

    {

    for (var i: int = 0; i < n; i ++)

    {

    nArr var = new Array();

    }

    return nArr [i];

    }

    Thank you very much.

    var aArraySet:Array = createArraySets (5); create 5 paintings

    Table 1-> aArraySet [0]

    Table 2-> aArraySet [1]

    Table 3-> aArraySet [2]

    Table 4-> aArraySet [3]

    Table 5-> aArraySet [4]

    function createArraySets(n:uint):Array

    {

    var aArraySet:Array = new Array();

    for (var i: uint = 0; i

    {

    aArraySet.push (new Array();

    }

    Return aArraySet;

    }

  • Use to write key VI with a table of cluster

    Hello

    I wanted to use an array of clusters to define certain configuration settings for an application. Unfortunately, 'Write key VI' does not support the type of cluster. Has anyone modified this function ('write key VI') in support of cluster and cluster table? Otherwise, no idea to keep it as simple as possible?

    My clusters include boolean, path, U32 and string.

    Thank you

    Olivier

    FYI, I have eventually save the cluster as a binary ("Write to binary function') file and a VI to read/write it. Is the easiest way for me as the other functions seem to have a limit on the complexity of the clusters they can handle.

    Thnaks for your suggestions,

    Olivier

  • filtering of the data sent to write to the file of measure

    Hi everyone, I was wondering how to implement a "filter" that prevents the data to write in the function "write into file measuments.  Say if the incoming data is a 0 (DBL), hwo to prevent it from being written?

    Use a box structure.  Put your writing to the file of the measure within a case structure, probably in the REAL case.

  • 2 parallel while loops with functional overall to share data

    Hello

    I'm having a problem with the sharing of functional with globals data between two parallel while loops:

    1. One of the loop (bottom) generates a random number periodically and write the total functional sample.
    2. Another loop (above) has a structure of event and when it expires, he would read the functional global and intrigue, a chart data point.

    The problem is sometimes the functional overall seems to be 'locked' and the output becomes zero constant. It also seems that whenever I first open the VI, it works fine. But for the second time running, he begins to have the problem.

    You must initialize your VI stop FGV FRONT of your lower loop begins.  Even if you use a global variable that is functional, you have a race condition.  FGV is read in the lower loop until it had a chance to be initialized with a value of false in the upper loop.  Functional global variables do not forget their data between executions of the VI.  So it is always set on stop the last time that you ran the VI.  This works your VI the first time it's because VI does not have in memory, so when it loads, it loads with the default value False in the shift register.

  • Help function LabelField

    Hello

    I use many LabelField controls in the project do not wish to repeat the same code & would like help in creating a reusable function.

    Example:

    Import net.rim.blackberry.api.phone.Phone;

    LabelField lfOwner = new LabelField ("owner:" + OwnerInfo.getOwnerName (), DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };

    LabelField lfOwnerInfo = new LabelField ("owner:" + OwnerInfo.getOwnerInformation (), DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };

    As you can see, the two are LabelFields with graphics by placing of the same color. It makes no repeat the code point and would be better to be able to pass information to a function to set the color for label... Creating a class using a variable public to access the info above which is converted into a string before being passed to the LabelField control. Each LabelField will be in the same format:

    LabelName (sText + ":" + sText2, DrawStyle.LEFT);

    or

    MyLabelName ("owner", PhonesOwner(), DrawStyle.LEFT);

    producing a

    Owner: [name of the owner of some here]

    Following label:

    The owner Info: [info from the owner here]

    and so on

    That's what I wrote, but doesn't seem to work:

    ' Public Sub SetGreenLabel (field field, String sLabelText, String sFunctionName)
    {
    field = new LabelField (sLabelText + ":" + sFunctionName, DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };
    };

    May extend to pass the ForeColor as parameter

    ' Public Sub SetLabelColour (String sLabelText, String sFunctionName, PlayStations color field, field)
    {
    field = new LabelField (sLabelText + ":" + sFunctionName, DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (cColour);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };
    };

    Perhaps an overload of the function as follows:

    SetLabelColour (String sText, String sText2)

    SetLabelColour (String sText2, String sText, color cForeColour)

    SetLabelColour (String sText2, String sText, cBackColour color, color cForeColour)

    My public variable

    MyClass mc = new MyClass();

    Label

    LabelField lf1;

    MC. SetLabelColour (lf1, 'Owner', PhonesOwner());

    Any ideas on how to write the correct functions?

    Thanks in advance

    Sure. Here is a more elaborate version of the idea of the subclass that has multiple constructors, commented to indicate what is happening. I have also set the colours.

    public class ColorLabelField extend LabelField {    /** Foreground color */    private int fg;
    
        /** Background color */    private int bg;
    
        /**     * Construct a ColorLabelField with empty text, default     * colors of dark green foreround and white background,     * and default style as determined by LabelField.     */    public ColorLabelField() {        this("", Color.DARKGREEN, Color.WHITE);    }
    
        /**     * Construct a ColorLabelField with indicated initial text,     * foreground and background colors, and default style.     * @param text the initial text     * @param fg the foreground color for the text     * @param bg the background color for the text     */    public ColorLabelField(String text, int fg, int bg) {        super(text);        this.fg = fg;        this.bg = bg;    }
    
        /**     * Construct a ColorLabelField with indicated initial text,     * foreground and background colors, and style.     * @param text the initial text     * @param fg the foreground color for the text     * @param bg the background color for the text     * @param style the style for the field     */    public ColorLabelField(String text, int fg, int bg, long style) {        super(text, style);        this.fg = fg;        this.bg = bg;    }
    
        /* No Javadoc comment. Just because. :) */    public void paint(Graphics g) {
            g.setColor(fg);
            g.setBackgroundColor(bg);
            super.paint(g);
        }
    }
    

    If you wish, you can add accessor functions to set the foreground and background colors after the ColorLabelField was built. As written, once you create them, the colors are immutable. (As far as the style of any field bits are immutable). If you add these accessor functions, you should consider if disabled then automatically the field when colors are changed or if it must remain until the client code to invalidate after everything he's done.

  • function table

    Hi experts


    I want to know how to create a table function that returns the Recordset (empno, ename, sal + comm) of the emp table

    I know that this can be done with simple SQL, but I want to learn to write the table function.

    And how to call this function from another sql table.

    Please help me...

    The sample data is data.

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR

    7369 SMITH COMMITTED 7902 17 DECEMBER 80 800 100 20

    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30

    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30

    Table function returns a collection of lines (a nested table or varray). You can choose from this collection, as if it were a database table by calling the function table inside of the TABLE clause in a SELECT statement. However, the use of the results of the function table based on table producing the entire collection (and remember, the collection is stored in memory) and then sending it only to the SQL statement. Table function in pipeline using PIPE ROW to route the data to the SQL statement as part of collection is produced. This SQL statement way working on this element table in function transformation pipeline while working to produce the next item in the collection. This improves performance and reduces the memory usage which can be even more important when the function produces collections of great footpring. RTFM in pipeline and functions using parallel Tableanyway.

    SY.

  • Help with a case function

    Hello

    I want to create a function box where column2 is based on the value of Column1.

    For example, the table below

    On the underside, I would ask something like

    Select status, description, l3_days, (case when status = 'Open' and DEV_DAYS = null THEN L3_DAYS = 'LOGIN_DATE-SYSDATE' WHAT status = 'open' and DEV_DAYS! = NULL THEN DEV_DAYS = L3_DAYS ELSE LOGIN_DATE-L3_DAYS-SYSDATE, DEV_DAYS END)

    support.jpg

    Not sure so clearly. Basically, I want to L3_DAYS and DEV_DAYS to be updated automatically based on the login_date. I plan to add a DEV_START_DATE column, which would facilitate the calculation of DEV_DAYS

    In any case I want to know how to write a case function, where denotes Column1 Column2?

    Thank you

    There are two CASE statements like this

    select status
         , description
         , case when status = 'Open' and dev_days is null then LOGIN_DATE-SYSDATE
                else l3_days
           end l3_days
         , case when status = 'Open' and dev_days is not null then LOGIN_DATE-L3_DAYS-SYSDATE
                else dev_days
           end dev_days
    

    If this isn't what you are looking for you need to explain your best condition. Provide a CREATE TABLE script and INSERT a TABLE for examples of data and provide a few example expected output.

    Also please read Re: 2. How can I ask a question on the forums?

  • Reusable functions?

    Is it possible for me to write some JavaScript functions to which all my rules and transformations can visit his profile?  Currently, I am cutting and pasting in each script.  I hope that there is a better way.

    -Eric


    Hi Eric,.

    The "functions/methods" dialog 'Custom libraries' list to create publicly exposed methods/functions, which can be selected in the dialog box "Scripts of custom transformations". Of course these function names must match the names of real functions in the code. They will be detached from your tasks. Other functions (not exposed in this example) in the code will be common code, used on many places is called/appellant/from other functions.

    I attached the below code and screenshot

    It is a very simple example of library with functions:

    That's how you use it in the script transformation dialog box

    Here is the code

    // this is publicly exposed
    function doSomeImportantThing() {
    // your logic goes here
    tables = model.getTableSet().toArray();
    for (var t = 0; t
    

    I guess that's what you're looking for

  • PL/SQL functions as LOV to use in another display object

    Hello

    We had a custom search to extract data from a display object and the data displayed as a Table of ADF. Now, there are few requests for searches on this report. Go see criteria and Panel request if we allow saved search. But the fields used in the research are going through a lot of logic and thus the PL/SQL functions are implemented. We used to call these functions and lists separated by commas and then divided the list into individual elements and put in the component "select options".

    The value (String) returned by the pl/sql function is something like - APAC, EMEA, NORTH AMERICA, FDA

    I am creating a LOV based on SQL-query "Select getRegions() from dual;

    Now, I want the list separated by commas to divide so that I could use this LOV in an another view and try the display criteria and saved searches.

    I tried to assign as LOV just to check and the criteria drop-down view for region displays same value as single element - "APAC, EMEA, NORTH AMERICA, LAD."

    I want it to be 4 separate - elements

    APAC

    EMEA

    NORTH AMERICA

    DVL

    Is there anyway to achieve this?

    Or better is at - it another way to do this (maybe I'm wrong)

    Thank you.

    JDev: 11.1.2.4

    Instead of a programmatic VO of PL/SQL, I found sometimes easier to write PL/SQL functions that return a table - need to CREATE a TYPE for the data items to be returned and a TYPE of TABLE IMBRIQUE tabular form of the first kind.  The function returns the type of table, and can even be a PIPElined table function.  Then I create a VO with the following text:

    SELECT * from TABLE (my_function_returning_table)

    The function can even take parameters, which you fill with variable BIND your VO.

Maybe you are looking for

  • Right click on the wrong spelling will not display suggestions more

    When I misspelling a word FF highlights but on click right it won't appear suggestions of words like before. I don't remember exactly when it started, but it's been a few months and everything I tried didn't work. I tried to download a dictionary as

  • Failed to format create recovery media

    I am trying to create a recovery media for new R30 - 1GZ and opted for USB Flash memory. Inserted a 16 GB Sandisk Cruzer module and said OK for reformatting. Message appears: "Unable to format the drive Windows" (or words to that effect). The module

  • Clear pages from iPhone

    Hello world I recently sold my old iPhone and upgraded to a new. When I open Safari, I notice that I can still see the pages that I had opened my last session on my old phone. I can slide and remove them well when I close Safari and reopen them to ap

  • DB25 Connector RS232

    Hello I hope that there could be someone who might have experience with this and can offer some advice. I have a very old piece of equipment (Schaffner NSG 1003) here which I am hoping to write some LabVIEW drivers for. I have the old manual of the p

  • G560 keyboard does not work after restoring

    Hello! I just did a restore using the recovery disks sent to me by the customer hotline of lenovo. the whole process went through and now it says: "LENOVO PRELOAD IS COMPLETE! Press any Key to Shutdown! » the keyboard and the touchpad does not, so I