1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Explain below Query

Discussion in 'SQL PL/SQL' started by mist, Dec 23, 2013.

  1. mist

    mist Active Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    160
    Hi all,

    can any one please explain the below code

    At declaration section
    --------------------
    QT varchar2(10) :=''''; -->see here

    at if condition
    --------------
    if : :CONTROL_BLOCK.ITEM_NAME is not null then
    finalstr := finalstr || 'AND ITEM_NAME =' || QT||:CONTROL_BLOCK.ITEM_NAME||QT;
    end if;

    Thank You
     
  2. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Hi Mist,

    QT varchar2(10) :='''';

    this will return ' (Single Quote).

    :CONTROL_BLOCK.ITEM_NAME will come between Single Quotes.

    Like below.

    ':CONTROL_BLOCK.ITEM_NAME'
     
    mist likes this.
  3. mist

    mist Active Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    160
    Hi Jagadekara Reddy,

    Could you please explain with example please.

    Thank You
     
  4. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Example:

    declare
    QT varchar2(10) :='''';
    v_CONTROL_BLOCK_ITEM_NAME varchar2(100):='Example';
    finalstr varchar2(100);

    begin
    --------------
    if v_CONTROL_BLOCK_ITEM_NAME is not null then
    finalstr := finalstr || 'AND ITEM_NAME =' || QT||v_CONTROL_BLOCK_ITEM_NAME||QT;

    end if;
    dbms_output.put_line(finalstr);

    end;

    The result is shown below:


     
    mist likes this.
  5. mist

    mist Active Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    160
    Great!! Explanation Jagadekara Reddy..:)