How to compare the type of data returned block Varchar2 PL/SQL

Hello

I'm new to the PL/SQL PROGRAMMIN, only to learn the basics of using if else block.
Here I have a query, please help

We compare a varchar2 data type using cant =. (For example, if the return value is equal to the name then alors that otherwise do something else)

declare

V_Key VARCHAR2 (15);
V_Value VARCHAR2 (15);
BEGIN

SELECT try.key FROM V_Key TO TRY WHERE value = "Value1";

IF(V_Value='Key1') THEN
dbms_output.put_line (' value is ');

on the other
dbms_output.put_line ('the value is two');

END IF;
END;


It's my program example, the returned value is here two (the execution of another condition) even if Key1 is returned.

Please advise, thank you in advnace.

Dear user!

That's only a guess, but I think that it is a problem of casessensitivity. If your query returns 'key1' or 'KEY1' and not 'Key1 '? Due to the fact that Oracle is casesensitive these three values are not equal. To solve your problem, you can use the LOWER-SQL function like this:

DECLARE
  V_Key VARCHAR2(15);
  V_Value VARCHAR2(15);
BEGIN
  SELECT try.key INTO V_Key
  FROM   TRY
  WHERE  value = 'Value1';

  IF(LOWER(V_Key)='key1') THEN
    DBMS_OUTPUT.PUT_LINE('the value is One');
  ELSE
    DBMS_OUTPUT.PUT_LINE('the value is Two');
  END IF;
END ;
/

I hope this will help you along.

Yours sincerely

Florian W.

Published by: Florian W. the 21.09.2010 08:15

Tags: Database

Similar Questions

  • oracle.jbo.domain.Number, round() method to change the type of data returned?

    Hi all

    When I tried to round the value to oracle.jbo.domain.Number, it returns data of type oracle.sql.Number. Please see the following code snippet:

    Number unitPrice = new Number (9.95);

    Number of numOfRet = new Number (5);

    Total = (unitPrice.multiply (numOfRet)) .multiply (1.05) .round (2);

    The third line can not compile because the round() method returns a data type of oracle.sql.Number, which generates the compile error. If I put a guy up there, it works. When I checked the javadoc, the method has a number of return type. But it says in the details of the description of the method, it returns a Java int. Can I ask is there something wrong here? You can find the javadoc here: number (Oracle ADF business components API Reference 10.1.2 areas)

    Thank you

    Sheet

    Order to understand, the problem is that the round() method returns a number, but a NUMBER data type.

    NUMBER public tour (int decimal_place)

    Therefore, cast to the number.

    Timo

  • Oracle Nashorn - how to change the type of data/size of the column?

    Hello!

    Can someone give an example of how to do to change a column datatype/size with Oracle Nashorn?

    The way I did (with Mozilla Rhino) does more work:

    type = model.getDesign () .getLogicalDataTypeSet () .getLogTypeByName ("VARCHAR");

    column.setLogicalDataType ();

    Thank you!

    Emiliano.

    I think you need to call setLogicalDatatype (with a small t) rather than setLogicalDataType.

    David

  • How to read the table of string returned by the DLL

    I developed DLLS in labview that takes 2 input parameters as a string and returns an array of strings in return. How can I read back this array returned strings in labview? I tried to return a string and I can't able to read. But how to read a table?

    Is the signature of the function – void GetLoginInfo (char [] DBPath, char [UserName], LStrHandleArray * table)

    Shrinivas

    I found the solution. When you configure the node to call a library function, the argument (in which we expect an array of string) type should be chosen as "Adapt to the Type" and data format to be "pointers to the sleeves.

  • determine the type of data

    Hi all

    I've got procedure of inserting data in table1 value1 column.
    My need is to determine the type of data entered by the user.
    If the data type is not number user should error.
    How can I make it?

    The easier and more reliable way would be to declare the formal parameter as a number, such as:

    SQL> create procedure p (p_num in number) as
      2  begin
      3     null;
      4  end;
      5  /
    
    Procedure created.
    
    SQL> exec p('a');
    BEGIN p('a'); END;
    
    *
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at line 1
    

    If you cannot do this, or want to be more "user friendly", so the only alternative is to test and trigger an error like:

    SQL> create procedure p (p_str in varchar2) is
      2     l_num number;
      3  begin
      4     l_num := to_number(p_str);
      5  exception
      6     when value_error then
      7        raise_application_error(-20001, 'I know I said it was a string, but I really want a number');
      8  end;
      9  /
    
    Procedure created.
    
    SQL> exec p('a');
    BEGIN p('a'); END;
    *
    ERROR at line 1:
    ORA-20001: I know I said it was a string, but I really want a number
    ORA-06512: at "OPS$ORACLE.P", line 7
    ORA-06512: at line 1
    

    John

  • How display you the type of file in PS Elements 10?

    How display you the type of file in PS 10 items in the organizer for each photo?

    I know that you can right click and watch meta data.

    In PSE 7 it was displayed under each photo.

    Two things:

    1. set the display option to display file names:

    2. make sure your tiles are large enough to display the data:

    Ken

  • Problem with the type of data in a view

    Hi all

    I have modified a view. For this reason my view passed to varchar2 column data type number automatically. But it should be only a number.

    Updated the view that changes the data type of column varchar2

    VIEW to CREATE or REPLACE v1
    AS
    SELECT Decode (Sign (mta.base_transaction_value), 0, Decode (Sign (mta.transaction_value), Decode (Sign (mta.primary_quantity),-1, NULL, 0))
    MTA.base_transaction_value),
    -1, NULL,
    Decode (Sign (mta.primary_quantity),-1, NULL, NULL
    MTA.base_transaction_value),
    (0)
    1, MTA.base_transaction_value,
    Col1 is NULL)
    Mtl_transaction_accounts MTA

    Old view that keeps this column under the number:

    VIEW to CREATE or REPLACE v1
    AS
    SELECT Decode (Decode (Sign (mta.base_transaction_value), 0, Decode (Sign (mta.transaction_value), 0, Decode (Sign (mta.primary_quantity), 1,0,))))
    0,0,
    (NULL),
    1.0,
    (NULL),
    1, MTA.base_transaction_value,
    Col1 NULL))
    Mtl_transaction_accounts MTA

    -> Create a note that the type of data of base_transaction_value, transaction_value, primary_quantity columns is number

    No help for making the data type of column 'col1' number using my first query?

    Thank you
    Srini

    The data type of an expression of DECODE() is determined by that of his first return value. Oracle has decided that a NULL value is a VARCHAR2 data type (because there must be something ).

    The changes to your code are extremely intertwined and twisted out and frankly too hard to work through. However, I think at some point the changes that you have implemented it had that effect.

    SQL> create or replace view v1
      2  as
      3  select decode(to_number(to_char(sysdate, 'dd')), 1, 0, 99) as col1
      4  from dual
      5  /
    
    View created.
    
    SQL> desc v1
     Name                                                  Null?    Type
     ----------------------------------------------------- -------- ----------------
     COL1                                                           NUMBER
    
    SQL> create or replace view v1
      2  as
      3  select decode(to_number(to_char(sysdate, 'dd')), 1, null, 99) as col1
      4  from dual
      5  /
    
    View created.
    
    SQL> desc v1
     Name                                                  Null?    Type
     ----------------------------------------------------- -------- ----------------
     COL1                                                           VARCHAR2(2)
    
    SQL>
    

    Cheers, APC

    blog: http://radiofreetooting.blogspot.com

  • How to compare the 2 versions of the same document in Pages?

    How to compare the 2 versions of the same document on Pages?

    There is no OS X Visual tool which can open two Pages document and show the differences between them - other than the human eye.

    What information are you interested in identify as different between the two documents? What specific version of Pages?

  • In the attached VI why looping force the type of data while the other does not?

    In the attached VI why looping force the type of data while the other does not?

    I'm guessing that you have created the Enum on the front panel.  If you right click and create an indicator, it corresponds to the type and be an enum.  LabVIEW represents enums as U16, but because the types are not the same (for example, your enum has 3 values, but a U16's 65 536 values), LabVIEW automatically converts value (or converts) the smallest representation (enum) in the largest value (U16).

  • How to compare the content of two Wordpad / documents notebook without reading them line by line?

    How to compare the content of two Wordpad / documents notebook without reading them line by line?

    Hello

    Without this feature is included in the operating system.

    However, you can use your favorite search engine to look for software that needs to perform these tasks.

    WARNING of THIRD PARTY SOFTWARE: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Hope this information helps.

  • How to check the type of memory installed (ECC or not)?

    all!

    I have some servers Dell PowerEdge R420 and I want to upgrade memory, install more...

    How to check the type of memory installed (ECC or not)?

    Dmidecode output here:

    Drive.google.com/.../View

    Hello.

    Unfortunately, we are not able to open the link you have provided. You can display information about your memory on the web iDRAC under hardware and memory interface. You see the type of error correction (ECC or Non ECC) within the information memory page. You can also view the same information on OpenManage Server Administrator and even make use of the memory part number to find out more information.

  • How to change the type of user account in the registry editor

    Hello.

    Can someone tell me how to change the type of user account in the registry editor

    Thanks in advance... :-)

    Kind regards
    Rambeau

    Hello.

    Can someone tell me how to change the type of user account in the registry editor

    Thanks in advance... :-)

    Kind regards
    Rambeau

    You can not. You need to do this via the control panel / accounts of users or via the command prompt. In both cases, you need to be logged in as an administrator account.

  • [JS] How to change the type of stroke?

    app.selection[0].strokeWeight = 3;     // app.selection[0] = [object TextFrame]
    app.selection[0].strokeCornerAdjustment = StrokeCornerAdjustment.DASHES;
    

    Hello.

    I tried this code, but error.

    error message: property is not applicable to the current state.

    How to change the type of dotted line?

    You must use the strokeType method, try this

    App.Selection [0] .strokeWeight = 3;

    App.Selection [0]. StrokeType = "dashes (3 and 2).

  • HOW TO COMPARE THE REGULAR TEACHER VS VERSIONS?

    HOW TO COMPARE THE REGULAR TEACHER VS VERSIONS?

    Thank you

    An educational version of Photoshop Elements are totally same (feature wise) than the regular commercial versions. So, it is unnecessary to compare.

  • How do I reselect the type to change.  I have a text template that I want to, but when I try to select it with the text tool always creates a new text layer.  How to change the type of the layer in my registered design?

    How do I reselect the type to change.  I have a text template that I want to, but when I try to select it with the text tool always creates a new text layer.  How to change the type of the layer in my registered design?

    OK, Bob. This give a try.

    First, open a new file and make sure the background is white, not on Transparent that I suspect you have currently defined.

    Then, type your copy. Your layers panel will then look like the top of this picture...:

    and when you drag the text on the image layer, it will look like the lower part of the sample above.

    You can then position the text layer with the tool move

Maybe you are looking for