Decode the statement using the nvl function

I inherited the code uses a decode and nvl. I'm not sure the purpose of him and wants confirmation that it is logical and an error. The situation can be re-created by implementing the following.

CREATE TABLE XX_TEST
(IDENTIFICATION NUMBER,
DOMAIN VARCHAR2 (255)
)

INSERT INTO XX_TEST (ID, FIELD) VALUES (1, 'Yes')
INSERT INTO XX_TEST (ID, FIELD) VALUES (2, 'No')
INSERT INTO XX_TEST (ID, FIELD) VALUES (3, NULL)

Commit

SELECT ID,
FIELD,
DECODE (on the GROUND, the 'yes', ' Yes result this ", NVL (FIELD, 'No'),"no results don't do this","catch all result do this")
OF XX_TEST

I'm not sure of the NVL (FIELD, 'No') I think that the creator may have thought this would draw the NULL values, but it is not.
Null is not converted into no. and plunges into the place the Tote. Can anyone help with an explanation of how oracle is interpretting the select statement. Any ideas on why NVL would be used like that? Seems a mistake?

decode compares them the first FIELD against NVL (FIELD, 'No').
If the FIELD is null estimated them VSN none which is not null, then...
just to make an entry for the null value and one for the 'no' with the same result.
However, I prefer case statement in this case.

SELECT ID,
FIELD,
case
when FIELD ='Yes' then 'Yes Result do this'
when FIELD is null or FIELD = 'No' THen 'No result do this'
else 'catch all result do this'
end
FROM XX_TEST

As more readable.
concerning

Tags: Database

Similar Questions

  • How to use the NVL function in decoding?

    Hi all

    How to use the NVL function in decoding?

    SELECT Decode (Sign (sum (nvl (7), 0)-nvl (sum (5), 0)), - 1, 0, (sum (nvl (7), 0)-nvl (sum (5), 0)) QTY)

    of the double

    Thank you

    You should not do that...

    Greatest (NVL (Sum (Quantity), 0)-NVL (SUM (quantity_received), 0), 0) AS qty_arrival

    will do the same

    HTH

  • How to use the NVL function to a parameter with comma delimited values

    Gurus,

    It is confusing to me.  I am trying to use the NVL function, but the setting that I'm passing in my cursor contains multiple values with commas.  The NVL function is confused when analyzing the values.

    'Where' cursor clause...

    and nvl (sn.c_attribute1,'x@#$%') in nvl (p_desig,'x@#$%'( )

    translated parameter values...

    and nvl (sn.c_attribute1,'x@#$%') in nvl ('SPRT''GOOD' 'BAD' 'x@#$%') -NVL does not parse the value correctly

    Any idea on how to get NVL recognize 'x@#$%' , if p_desig is null?

    Thank you

    Scott

    HI, Scott.

    Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

    My best guess, based on what you posted bone is present, that your problem is discussed in the following:

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

    http://www.Oracle-base.com/articles/Misc/DynamicInLists.php

  • Do I need to use the NVL function for this request?

    I seem to have some problems using the NVL function on a date. I'm trying to create a query pulls back just a date a file was sent between the sysdate and the date_sent more a minute. Here is the code I use...

    Oracle: 10.2 G
    SELECT date_sent as date_sent
    INTO    iDateSent
    FROM    tableX
    WHERE  file_id= 9999
    AND    date_sent BETWEEN sysdate AND date_sent + 1/1440; 
    Currently Output (null):
    DATE_SENT
    Desired output when date_sent is null:
    DATE_SENT
    0:0:000 0:00:00
    Note:
    date_sent column is in a normal date - same format as sysdate format.

    The problem I encounter is when date_sent is null, the stored procedure, I built crashes because date_sent returns a null and a null value cannot be stored in the variable 'iDateSent '. I was thinking about using the NVL function here to resolve, however, I'm not entirely sure who will work with the above query. Any thoughts?

    Published by: user652714 on July 9, 2010 12:58

    Published by: user652714 on July 9, 2010 13:11

    Hello

    you said: "desired output when date_sent is null: date_sent: 0".
    It is not possible to have a date of 'zero '.

    "and a null value cannot be stored in the variable 'iDateSent'. '.

    I do not think: If this variable is declared normally (without any not null not constrained to this topic) so that it can contain a null value. (it's 99% of the time in PL/SQL).

    I think it's that your SQL retrieves no rows, to manage what you should put an exception handler:

    begin
    SELECT date_sent as date_sent
    INTO    iDateSent
    FROM    tableX
    WHERE  file_id= 9999
    AND    date_sent BETWEEN sysdate AND date_sent + 1/1440;
    exception when NO_DATA_FOUND then
     iDateSent:=null;
    end;
    

    So what you can do if you don't want the date empty a nvl:

    return(nvl(iDateSent,sysdate));  -- or another date ...
    

    Published by: user11268895 on July 9, 2010 22:09

  • Decode the help function

    Hello

    I'm new to the development of Oracle.

    MY requirement:

    I need to fill a column "ISMSG" by YES / NO based on the following condition

    When the code = the of ' or 'O'... the 'ISMSG' column should display any other YES no.

    That is, output should be like

    CODE ISMSG

    A NO
    S YES
    S YES
    O YES

    My code for the Decode function:

    CASE
    WHEN s = c.code ' THEN decode (c.code, the of ',' YES, 'NO')
    WHEN c.code = 'o' THEN decode (c.code, 'O', 'YES', 'NO')
    END ISMSG

    My code is correct? If Yes is the best way to do it?
    If this is not the case, correct the code.

    Is there an effective way to do it?

    Thanks in advance.

    Hello

    You can use CASES or DECODE for this; There is no need to use both.
    With the help of CASE:

    SELECT  c.code
    ,     CASE
             WHEN  c.code  IN  ('S', '0')  THEN  'YES'
                                               ELSE  'NO'
         END     AS ismsg
    FROM    table_x   c;
    

    Using DECODE:

    SELECT  c.code
    ,     DECODE ( c.code
                , 'S'      , 'YES'
                , '0'      , 'YES'
                              'NO'
                )          AS ismsg
    FROM    table_x   c;
    

    I suggest that you forget to DECODE and use always the CASE, at least while you are beginner.

    CASE may do everything they can to DECODE. There is a little bit simple, situations where DECODE is a little shorter than the CASE and therefore a bit clearer, but only a little and, as I said, these are just simple situations, and CASE is clear enough in them.
    DECODE is never much shorter or clearer than the CASE. The reverse is not true: there are many situations where the CASE is much, much shorter and lighter than DECODE.

  • Decode the simple function

    Gurus,

    Please help me with a decoding function.

    doknlbc can be null or different bnuinfc in some occasions.

    Select dokkeyi, (doknlbc, null, 'no emp_id', bnuinfc) decoding as dok emp_id, bnu
    where doknlbc = bnunamc and dokkeyi in (6545,6525);


    Result
    EMP_ID DOKKEYI
    6545 70348

    Result, I want to!
    EMP_ID DOKKEYI
    6545 70348
    6525 no emp_id

    Thanks for the help!

    Try this:

    select dokkeyi, decode(doknlbc,null,'no emp_id',bnuinfc) as emp_id
    from dok, bnu
    where
         ( doknlbc = bnunamc  or
           doknlbc is null
         )
         and dokkeyi in (6545,6525);
    
  • Not able to run the NVL function in the data model

    I tried to use NVL today in the data model, but I got the error message.
    Here's the code: -.
    SELECT ROUND (WHEN BOX: MO_TARGET_DISP_RATE > = 100)
    THEN 100
    (TO ANOTHER NVL (: MO_TARGET_DISP_RATE, 1) END, 2) AS "TARGET_PC_MO".

    Y at - it another option to replace NVL here... that runs in the NOSE? Thanks in advance.

    Just a suggestion, try a view then refer to the display in the data model

    (SELECT (ROUND (CASE WHEN to_number(:MO_TARGET_DISP_RATE) > = 100)))
    THEN 100
    Of OTHER NVL (to_number(:MO_TARGET_DISP_RATE), 1) END 2)), double) My_field

    The error was not a tank for the error number was or media...! If so above should be ok...

  • Decode the query help

    Hello
    I'm new to the development of Oracle.
    Oracle 10 g 2

    My original query:

    SELECT APP, count (*)
    TRANSACTION
    WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
    and the APP ("SAPPI", "SAPPI", "SAPR3") and INTERVENE ('9320 ', '9332','1208 ')
    GROUP BY APP TYPE
    order of the APP

    the result of this query:
    SAPPI 100
    SAPPI 600
    SAPR3 440

    My requirement
    And I want to have something like output

    LDCS 100
    TSW 600
    PDC 440

    IE.the APPP and STEP combinations. Must return the specified values
    SAPPI & 9320-> LOC (here SAPPI IE APP is the same for both... but it's a coincidence IE APP can be sliced also)
    SAPPI & 9332-> tsw
    SAPR3 & 1208-> pdc

    Options, I tried:
    Query provided by one of the Forum members...
    SELECT THE CHECK BOX
    WHEN APP = "SAPP1" THEN DECODE (step, '9320', 'LSW', '9332', "TSW")
    WHEN APP = "SAPR3" step = '1208' AND 'PDC '.
    END app
    COUNT (*)
    TRANSACTION
    WHERE TYPE in ('ShipmentConfirmPR', 'ShipmentConfirm', 'ShipConfirm')
    AND THE APP ("SAPPI", "SAPPI", "SAPR3")
    AND STEP IN ('9320', '9332', ' 1208')
    GROUP BY APP, STEP
    ORDER OF THE APP.

    EXECUTION PLAN

    | ID | Operation | Name |
    ------------------------------------------------------------------------
    | 0 | SELECT STATEMENT |
    | 1. GROUP SORT BY |
    | 2. INLIST ITERATOR.
    | 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
    | 4. INDEX RANGE SCAN | TRANSACTION_IDX |


    The output of the query (as above) must partially match the following query (a particular combination of CLO)

    SELECT count (1)
    TIBCO. TRANSACTION_HISTORY
    WHERE TYPE = 'ShipmentConfirm '.
    and APP in ("SAPPI") and INTERVENE ('9332')


    My Questions:

    1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?

    2. is the right to approach? Would the use of the concat operator in the function decode work better for my needs?
    Something like

    Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where < COND >

    If Yes can you please provide the query?

    3. ANY other approach / request for my requirement.

    Thanks in advance.

    Hello

    user13517642 wrote:
    ... EXECUTION PLAN

    | ID | Operation | Name |
    ------------------------------------------------------------------------
    | 0 | SELECT STATEMENT |
    | 1. GROUP SORT BY |
    | 2. INLIST ITERATOR.
    | 3. TABLE ACCESS BY INDEX ROWID | TRANSACTION |
    | 4. INDEX RANGE SCAN | TRANSACTION_IDX |

    The output of the query (as above) must partially match the following query (a particular combination of CLO)

    SELECT count (1)
    TIBCO. TRANSACTION_HISTORY
    WHERE TYPE = 'ShipmentConfirm '.
    and APP in ("SAPPI") and INTERVENE ('9332')

    My Questions:

    1.*There are indexes on all 3 APP passes it's IE, STEP and TYPE *. I don't want a FULL table Scan (as one would use the index). Can change us the query / use of indices, etc. to make it faster?

    A full table scan might be the fastest way to get results. Do you have any reason to think that it would be faster to go through the index? How selective are the clues? In other words, what is the percentage of rows in the table correspond to each of the values in the WHERE clause?

    2. is the right to approach?

    It depends on what you're trying to do, which is not at all clear to me.

    Would the use of the concat operator in the function decode work better for my needs?
    Something like

    Select decode (APP |) STEP, 'SAPP9332', 'X') of TRANSACTION_HISTORY where

    If you use this approach, look out for the problem Ab asse crevit . For example, if you have these 4 rows and 2 columns:

    str1     str2
    ----     ----
    (NULL)     FOO
    F     OO
    FO     O
    FOO     (NULL)
    

    There are 4 values of distict of str1 (counting NULL) and 4 separate values of str2, str1 but | str2 is the same for each of them. In the above example, it there is no way to know, just by looking at the concatenated string, including str1 and str2 ends begins. Maybe it's not the case for your specific data (for example, if the application is still exactly 5 characters long). otherwise, you may need to add some kind of delimiter, like this

    app || '+' || step
    

    where you know that '+' never occurs in one of these columns.

    3. ANY other approach / request for my requirement.

    CASES, as I mentioned in your previous message:
    Decode the help function
    and as you have used above.

    In this thread, you said "I have to use the decode function. Why? It is a competition of school Etudieeo DECODE is explicitly required? Why you don't want in the best way, what that turns out to be?

    Your WHERE clause:

    AND APP IN ('SAPPI', 'SAPPI', 'SAPR3')
    AND STEP IN ('9320', '9332', '1208')
    

    admits 6 possible combinations of APA and step:

    app     step
    -----     ----
    SAPP1     9320
    SAPP1     9332
    SAPP1     1208
    SAPP3     9320
    SAPP3     9332
    SAPP3     1208
    

    but you are looking for only 3 of these combinations in DECODE it or the expression BOX. (Have 2 copies of 'SAPP1' e list won't do any good, but it does hurt real, either.)
    By the way, is "SAPPI" app with the letter 'I' at the end, or "SAPP1", with the number '1' at the end?

    Published by: Frank Kulash, March 24, 2011 19:44

  • Bug with the aggregate function and no group

    When I run the following query:
    with the_table as
    (
      select 1 as id, 100 as cost from dual
      union all select 2 as id, 200 as cost from dual
      union all select 3 as id, 300 as cost from dual
      union all select 4 as id, 400 as cost from dual
      union all select 5 as id, 500 as cost from dual
    )
    select id, cost
    from
    (
      select id, cost
      from the_table
      --
      union all
      --
      select 0 as id, sum(cost) as cost
      from the_table
      where 0 = 1
      -- group by 1
    )
    order by id;
    I get this result:
    ID    COST
    --  ------
     0  <null>     
     1     100
     2     200
     3     300
     4     400
     5     500
    However, when I "uncomment" the line "Group 1", the query works as expected (without the id = rank 0).

    This occurs even when "the_table" is an array.

    Someone else comes through this (and if so, how long is a problem)?

    The database is 11.2.0.2.0 64-bit.

    EDIT: It also happens without a Union - the following returns a single line (with null 0 and cost of id) without the Group By and no line with her:
    select id, cost
    from
    (
      select 0 as id, sum(cost) as cost
      from 
      (
        select 1 as id, 100 as cost from dual
        union all select 2 as id, 200 as cost from dual
        union all select 3 as id, 300 as cost from dual
        union all select 4 as id, 400 as cost from dual
        union all select 5 as id, 500 as cost from dual
      )
      where 0 = 1
      -- group by 1
    )
    order by id
    Edited by: Donbot February 15, 2012 10:29

    Donbot wrote:
    Someone else comes through this (and if so, how long is a problem)?

    The database is 11.2.0.2.0 64-bit.

    This is a documented behavior.

    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions003.htm#SQLRF20035

    "
    All except COUNT (*) GROUPING and GROUPING_ID aggregate functions ignore NULL values. You can use the NVL function in the argument of an aggregation function to substitute a value for a null value. COUNTY and REGR_COUNT never return null, but return a number or zero. For all remaining functions of aggregation, * if the DataSet contains no line, * or if it contains only the rows with NULL values as arguments to the aggregate function, * then the function returns null.*
    "

  • NVL function in Oracle 11 G

    Hi all

    During my interview, I had two questions that made me perplexed in the interview.

    (1) in Oracle 11 G, there is a similar to the nvl function. What is it? I knew that we can use decode function nvl but in 11G, any function has been introduced?

    (2) other that function, what are the other ways to pass the entries of a procedure?

    Someone knew the answers to these or questions asked by the interviewer are wrong? Please give your suggestions...

    Hello

    user2639048 wrote:

    Hi all

    During my interview, I had two questions that made me perplexed in the interview.

    (1) in Oracle 11 G, there is a similar to the nvl function. What is it? I knew that we can use decode function nvl but in 11G, any function has been introduced?

    COALESCE may think of you (or the one who asked you this), but she is older than version 11.

    See COALESCE

    If you had no idea what was the service, a good answer would be: "I don't know what is the function, but I know that there is a"what's new"manual Oralce 11 (and all recent versions) and, better yet, a"What's new"chapter at the beginning of the manual of the SQL language that describes all the new features."  "Know exactly what are the new features in Oracle 11 aren't really important if we are now both Oracle 11 and older versions, anyway."

    (2) other that function, what are the other ways to pass the entries of a procedure?

    Someone knew the answers to these or questions asked by the interviewer are wrong? Please give your suggestions...

    Sorry, I can't understand what you're asking.

    Isn't a function.

    IN arguments are usually the best way to move the entries of a procedure.  If, in an interview, someone asked on other ways, make it clear that you know before you give any other answer.

    I suggest that you describe what you want a little more in detail.

    In addition, create a separate thread for each separate issue.  (I do not know what 2) above is, but it doesn't seem to have anything to do with 1).  (Asked in the same interview is not significant.)

  • NVL function

    How to apply the nvl function to the case to avoid null values in the result (I want to replace nulls by zero in the result)

    SUM (CASE
    WHEN S.RESULT IN ('Y', 'O', 'I', 'F')
    THEN
    1
    END
    ) STAT.

    case statements can have ELSE clauses...

    just put a 0 otherwise in there.

  • How to use the Substring function with Case statement.

    Hi all

    I have a requirement where I have to use the substring function on the ground for the report criteria.
    FOR EXAMPLE
    I branch domain name where I have all the information of the branch names, now some of the branch names are too large with an extension after the name.
    now I want substing it, but the length of characters varies for each branch.
    so is it possible where we use a box where we can define if the character of name plug exceed a value then he substing with this length.

    Try something like this:

    LENGTH WHEN CARTER (tablename. Branch_Name) > n THEN SUBSTRING (...) Of ANOTHER tablename. Branch_Name END

    where n is the number of characters that you want to start the break.

  • How to use the Pivot function for range group in oracle SQL

    Hello

    Hello!!!

    I need to display the data in the format below. There are 2 columns 1 is State and another is rate.

    State < 100 100-199, 200-299 300-399 400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 Total
    AK 1 2 0 4 1 4 4 35 35 4 1 25
    AL 0 0 2 27 10 17 35 2 2 35 0 103
    AR 0 0 1 0 0 2 2 13 13 2 0 6
    AZ 0 1 2 14 2 14 13 3 3 13 0 57
    CA     0     0     1     6     2     7     3     4     4     3     0     34

    Developed the sub query but unable to use the beach on the pivot function. Please help on this.

    (select (SELECT short_description
    OF CODE_VALUES
    WHERE CODE_TYPE_CODE = ad. STATE_TYPE_IND_CODE
    AND VALUE = ad. STATE_CODE
    ) STATE,
    Nr.rate
    N-NEUTRAL
    c contacts,
    announcement of addresses,
    xref_contacts_addresses xca,
    neutral_rates nr
    where n.contact_id = c.contact_id
    and n.address_id = ad.address_id
    and xca.address_id = ad.address_id
    and xca.contact_id = c.contact_id
    and nr.contact_id = n.contact_id
    and nr.rate_frequency = 'HOUR')

    Like this

    with t
    as
    (
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 67 value from dual union all
    select 'AL' state, 23 value from dual union all
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 78 value from dual union all
    select 'AL' state, 34 value from dual union all
    select 'AL' state, 4 value from dual union all
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 15 value from dual union all
    select 'AZ' state, 6 value from dual union all
    select 'AZ' state, 123 value from dual union all
    select 'AZ' state, 123 value from dual union all
    select 'MA' state, 23 value from dual union all
    select 'MA' state, 120 value from dual union all
    select 'MA' state, 456 value from dual union all
    select 'MA' state, 11 value from dual union all
    select 'MA' state, 24 value from dual union all
    select 'MA' state, 34 value from dual union all
    select 'MA' state, 87 value from dual union all
    select 'MA' state, 23 value from dual union all
    select 'MA' state, 234 value from dual union all
    select 'MA' state, 789 value from dual union all
    select 'MH' state, 54321 value from dual
    )
    -- End of test data
    select state,
           nvl(count(decode(value, 0, 0)), 0) "<100",
           nvl(count(decode(value, 1, 1)), 0) "100-199",
           nvl(count(decode(value, 2, 2)), 0) "200-299",
           nvl(count(decode(value, 3, 3)), 0) "300-399",
           nvl(count(decode(value, 4, 4)), 0) "400-499",
           nvl(count(decode(value, 5, 5)), 0) "500-599",
           nvl(count(decode(value, 6, 6)), 0) "600-699",
           nvl(count(decode(value, 7, 7)), 0) "700-799",
           nvl(count(decode(value, 8, 8)), 0) "800-899",
           nvl(count(decode(value, 9, 9)), 0) "900-999",
           nvl(count(decode(value, 10, 10)), 0) ">=1000"
      from (
              select state, case when value < 100 then 0
                                 when value between 100 and 199 then 1
                                 when value between 200 and 299 then 2
                                 when value between 300 and 399 then 3
                                 when value between 400 and 499 then 4
                                 when value between 500 and 599 then 5
                                 when value between 600 and 699 then 6
                                 when value between 700 and 799 then 7
                                 when value between 800 and 899 then 8
                                 when value between 900 and 999 then 9
                                 when value >= 1000 then 10
                            end value
                from t
           )
     group
        by state
    
  • SetCtrlVal used during the Thread function works causes memory leaks

    I am writing a program that works if... Or not work if... - see the next lines... :-)...

    The program includes a section, mostly GUI - and User Interaction.

    The other part is a DLL. In the DLL we readings on an external consultant controller RS232. Sometimes the controller card needs (called how much) time and this time must pass then the result can be read card controller... and so on...

    Blocking is not GUI-user-program for the expectation of the return value of the DLL functions (which need a few seconds to be finished) I start a thread in the DLL with

    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, THREAD_FunctionX, & tmpTFP, NULL);

    with "tmpTFP" as an instance of type "TYPE_THREAD_FUNCTION_PARAMETERS":

    typedef struct
    {
    //
    int IntVal1;                // 1. Integer-Wert
    int IntVal2;                // 2. Integer-Wert
    int IntVal3;                // 3. Integer-Wert
    int IntVal4;                // 4. Integer-Wert
    int IntVal5;                // 5. Integer-Wert
    //
    int IntBuffer1 [32];            // 1. Integer-buffer (aktuell genugt einer)
    //
    Double DblVal1;                // 1. Double-value
    Double DblVal2;                // 2. Double-value
    Double DblVal3;                // 3. Double-value
    Double DblVal4;                // 4. Double-value
    Double DblVal5;                // 5. Double-value
    //
    char CharVal1;                // 1. (Single)- Tank-Wert
    char CharVal2;                // 2. (Single)- Tank-Wert
    char CharVal3;                // 3. (Single)- Tank-Wert
    char CharVal4;                // 4. (Single)- Tank-Wert
    char CharVal5;                // 5. (Single)- Tank-Wert
    //
    char CharBuffer1 [1024];        // 1. Char buffer (akutell einer genugt)
    //
    } TYPE_THREAD_FUNCTION_PARAMETERS;

    In the GUI-user program - I get fast by default-return value of the thread start function.

    Then I asked the DLL (some global state variables are used for this) when it is finished.

    According to the map-controller (RS232) contacted the waiting time depends on the 'mood' of the controller card.

    In the DLL-mark of the GUI-user-program routine now everything works fine - without using "SetCtrlVal!"

    In my GUI, there is a text box of the info/comment for messages. If I do a few outputs user using 'SetCtrlVal' I always errors, caused by the false "TYPE_THREAD_FUNCTION_PARAMETERS"-values in the service of thread. "» If I set a breakpoint at the beginning thread-function I see mostly erroneous values in my transfer structure variables. If I put a breakpoint in the thread-function-calling 'CmtScheduleThreadPoolFunction (...)"and at the beginning of the thread values are (mostly) correct!

    I tried several and different things - but:

    If I ONLY (!)  Commenting on the (!) of a line with "SetCtrlVal", the program works, all States are asked out of the DLL.

    If I replace the "SetCtrlVal" with a written record-file function clean everything works fine and after completing the program I can look at the log file and see all the user information. BUT with 'SetCtrlVal' instead or set or (...) it does not work.

    My description is maybe not entirely clear, but believe me: only ONE line the «SetCtrlVal "line - should be commented out to let the program run properly!»

    Because if the line "SetCtrlVal"is program-user-GUI, after the call to the thread in the DLL, the DLL-memory seems to be corrupted by the call "SetCtrlVal" in the user-GUI program.»

    Best regards

    F.

    There may be a problem in your structure that your variable is set.

    You said that, after the address of the variable in the thread function the appellant one ends. Now, as you can read help each value passed in parameter threadFunctionData of the layed function must point to an area of memory that persist when the fuction is running: If your variable is defined at the level of the functions it is not valid when the thread runs since the appellant finished and released its local memory.

    Your approach with a global variable is a valid alternative, but if it is the solution, you will find data passed to the thread function must be valid for all his life.

  • How can I use the BCGTransform function to treat the 16-bit Image?

    Hi ~

    I use LabWindowsCVI8.5 and NI Vision to make the treatment of the Image. When I read the "IMAQ Vision for LabWindowsCVI Reference Manual", I found that the imaqBCGTransform function only supports 8-bit Image, while I do the BCG to turn on 16-bit image. Are there solutions to use the BCGTransform function to deal with the 16-bit Image? Or any other feature that could make the correction Gamma, contrast and brightness on the 16-bit Image?

    Thank you very much!

    because imaqBCGTransform is implemented as a lookup table, we can understand why it is limited to 8-bit images.

    Now let's take a look at the definition of each of this mandate (from the NI Vision Concepts documentation):

    -brightness: a constant added to the components red, green, and blue pixel of color over color, decoding of the process;

    -contrast: a constant multiplication factor applied to the components of the luma and chroma of a pixel of color in color to decoding process.

    -gamma correction: expand high gray-level information in an image while removing information of low level of gray.  (the chapter on lookup tables gives some examples of corrections gamma)

    now that you understand that this transformation is a simple mathematical function, simply calculate the correction for each pixel on your 16-bit images.

    I know not the exact formula used by the imaqBCGTransform function, but you should be able to approach by performing some tests on images 8 bits with the original function... or you can make your own formula... or find one on the net... or you can ask someone at home OR you give the formula...

Maybe you are looking for