Pass variable in the SELECT... WHERE... (< VAR >) have problems.

Hi all

I'm using Oracle 11 g R2 and Linux.

I'm working on a code in which I need to dynamically pass values to 'IN' clause in a select statement.

A short demonstration of my question is as below: -.

Set serveroutput on

/

declare

NUM varchar2 (100): = 1, 2';

number of v_inst_id;


Start


dbms_output.put_line (' value of num before :-'||) (NB);

Select INST_ID select

in v_inst_id

GV $ session

where username = 'SYS '.

and to_char (inst_id) in (num) - 1, 2

order of INST_ID select;


exception

while others then

dbms_output.put_line (SQLERRM);


end;

/

anonymous block filled

Before value of num:-1, 2

ORA-01403: no data found

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

Select INST_ID select

-by v_inst_id

GV $ session

where username = 'SYS '.

and to_char (inst_id) in (1,2)

order of INST_ID select;

INST_ID SELECT

----------

1

1

1

2

2

2


Please let me know why my request does not work in plsql but works perfectly in sql.


Thanks in advance.

VJ4 wrote:

Hello

Thanks for your reply.

Can you please give a brief explanation on the example you showed?

with this request

SELECT to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) p_id

OF THE DOUBLE

WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

CONNECTION BY INSTR (num, ',', 1, LEVEL - 1) > 0

I shared your (digital) channel of n number of rows in the table

SQL > set serveroutput on;

SQL >

SQL >-created the 11.06.2014 by RAMIN. H

SQL > declare

2 num varchar2 (100): = '1.2'.

3. start

4 r in (SELECT to_number (REGEXP_SUBSTR (num, ' [^,] +', 1, ROWNUM)) p_id)

5 DOUBLE

6. WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

7 CONNECT BY INSTR (num, ',', 1, LEVEL - 1) > 0) loop

8 dbms_output.put_line (r.p_id);

9 end of the loop;

10 end;

11.

1

2

PL/SQL procedure successfully completed

SQL >

SQL >-created the 11.06.2014 by RAMIN. H

SQL > declare

2 num varchar2 (100): = "1,2,3,4,5,6";

3. start

4 r in (SELECT to_number (REGEXP_SUBSTR (num, ' [^,] +', 1, ROWNUM)) p_id)

5 DOUBLE

6. WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

7 CONNECT BY INSTR (num, ',', 1, LEVEL - 1) > 0) loop

8 dbms_output.put_line (r.p_id);

9 end of the loop;

10 end;

11.

1

2

3

4

5

6

PL/SQL procedure successfully completed

SQL >

SQL >

SQL > SELECT to_number (REGEXP_SUBSTR ('& num', ' [^,] +', 1, ROWNUM)) p_id

2 FROM TWO

3. WHERE to_number (REGEXP_SUBSTR ('& num', ' [^,] +', 1, ROWNUM)) IS NOT NULL

4 CONNECT BY INSTR ("& num', ',', 1, LEVEL - 1") > 0

5.

P_ID

----------

1

2

3

4

5

6

SQL >

----

Ramin Hashimzade

Tags: Database

Similar Questions

  • passing variables between the pop-up windows

    I'm moving one popup to the other variables. It works fien if I spend bvariable of main application as soon as I'm moving from variable popup to popup window it does not work here is what I am trying ro:

    That works fine

    hand. MXML

    private function launchMoreInfo (): void {}
    var win: view = PopUpManager.createPopUp (this, opinion, true) as point of view;
    //

    victory. AccountNum = list1.selectedItem.accountNum;
    Win.User = user;

    }

    But if I try to pass variables to the pop-up window, created from popup component, is not ' work

    View.MXML

    private function dsclientevents (): void {}
    var win2:view = PopUpManager.createPopUp (Thi, dsclienteventlog, true) like point of view;
    //

    win2. AccountNum = 'test ';

    }

    AccountNum is declared in dsclienteventlog.mxml

    Is it possible to pass variables between the pop-up windows?

    I would much apreciate your help

    Thank you

    Hi friend!

    I have faced this kind of problem and solved using 'Public static var '.

    Just, you declare a public static variable in your class Popup. Then you can directly set the value to this variable as,

    ClassName.StaticVariableName = value;

    In your case,.

    say PopUp2.mxml or PopUp2.as

    =======

    In the PopUp1 script:

    OnItemSelectionChange (event): void

    {

    PopUp2.m_iSelectedID = DatagridID.selectedItem.AccountID; It will change the value of this variable, even if the popup2 is open.

    your stuff here...

    }

    Try this, I hope this will help you.

    Thank you

    Merlina.

  • Set the Variable in the select statement

    Hello

    Can we define a variable in the select statement.

    Example:

    Select firstname, lastname
    employees;

    in this simple select statement we can define x as number?
    select fname,lname
    from employees
    where rownum <= 30;
    
  • Trying to reinstall my Windows XP home edition and my keyboard does not work when I reached the part where I have to type my name and organization

    Original title: reinstalling Windows

    I am trying to reinstall my Windows XP home edition and when I reached the part where I have to watch myself and my organization my keyboard does not work and I can't type my name or to the next step.

    Hello

    1. did you have backed up your data before attempting to reinstall Windows?
    2. do you have other devices connected to your computer outside of the mouse and keyboard?

    If so, I suggest that you remove any external devices, then try reinstalling Windows.

  • Not able to find the path where I have to put the file on the server .plx

    I have to make a few changes to the PLL (library) file and compile it to its .plx file and move the .plx on the server.

    I'm not able to find the path where I have to put the file on the server .plx.

    I put it in/iasapp01/app_name/library, but it does not in effect.

    Please help if someone knows about it, about how to solve this problem

    Thank you
    GAG

    So yes, we have replaced the old file by the new modifed one, but somehow, the changes that we made in the pll being file do not appear

    So either your changes do not work, or you have replaced the wrong file and there is another instance of the plx elsewhere. What happens if you delete your plx. IF its does not exist, the form should throw an error, otherwise, there is another instance of the file.

  • My iPhone can connect to the computer via Wifi instead of cable? Because I figured that my head of the telephone cable i have problem if the computer cannot detect my folder after plugging in the cable.

    My iPhone can connect to the computer via Wifi instead of cable? Because I figured that my head of the telephone cable i have problem if the computer cannot detect my folder after plugging in the cable.

    Sync your iPhone, iPad or iPod touch with iTunes using a WiFi - Apple...

  • Using arrary associative as parameter and passing then to the place where the clause of the select statement

    Hello

    I have this scenario where I have to pass multiple values to a parameter of a procedure of monkey and then collect in another variable (the lines can be multiple).

    The parameter must be used in the where clause of the statement select here I create a sample table for the problem.

    Create table test_tab (number of trans_id, cmts varchar2 (50));

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");

    insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");

    This is so all cmts have same trans_id but different name

    This query gives the result as -

    Select the cmts, count (1)

    of test_tab

    where cmts ("wnlb-cmts-11-04','wnlb-cmts-11-01", "wnlb-CMTS-11-02'")

    and trans_id = 568890112115

    Cmts group;

    COUNTY OF CMTS

    WNLB-CMTS-11-04 2

    3 WNLB-CMTS-11-01

    Now, I want to use this query in a PLSQL block like where I can spend the CMTS collection and trans_id as a scalar variable and once again an OUTPUT parameter that holds the result of the query.

    I use OUT parameter because it will be called to the JAVA program.

    Here, I write a PACKAGE for it but it gives me compilation error!

    create or replace package CMTS_SUCCESS_FAILED_API

    is

    type t_item_name is table of index varchar2 (50) by pls_integer;

    TYPE t_cmts_count () IS RENDERING

    CMTS VARCHAR2 (30),

    number of NUMBER

    );

    type t_reseg_dtl is table of index t_cmts_count by pls_integer;

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);

    end CMTS_SUCCESS_FAILED_API;

    /

    Now that I have created a different PACKAGE BODY, but none don't work!

    1.

    create or replace package CMTS_SUCCESS_FAILED_API

    is

    type t_item_name is table of index varchar2 (50) by pls_integer;

    TYPE t_cmts_count () IS RENDERING

    CMTS VARCHAR2 (30),

    number of NUMBER

    );

    type t_reseg_dtl is table of index t_cmts_count by pls_integer;

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);

    end;

    /

    create or replace package CMTS_SUCCESS_FAILED_API body

    is

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)

    is

    Start

    I'm in p_item_name.first... p_item_name. Last

    loop

    Select the cmts, count (1)

    bulk collect into p_reseg_dtl (i)

    of test_tab

    where cmts = p_item_name (i)

    and trans_id = p_trans_id

    Cmts group;

    end loop;

    for r in p_reseg_dtl.first... p_reseg_dtl. Last

    loop

    dbms_output.put_line (p_reseg_dtl (r). TRANSACTION_ID | » '|| p_reseg_dtl (r). JOB_STATUS | » '|| p_reseg_dtl (r). CMTS);

    end loop;

    end CMTS_SUCCESS_FAILED_RESEG_ORDR;

    end CMTS_SUCCESS_FAILED_API;

    While I run this procedure it is said TOO_MANY LINES.

    2.

    create or replace package CMTS_SUCCESS_FAILED_API body

    is

    procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)

    is

    cursor c_dtl is

    Select the cmts, count (1)

    of test_tab

    where cmts = p_item_name < < error

    and trans_id = p_trans_id

    Cmts group;

    Start

    Open c_dtl;

    collect the fetch c_dtl in bulk in p_reseg_dtl;

    close c_dtl;

    -for i in p_item_name.first... p_item_name. Last

    -loop

    -end loop;

    end;

    end;

    THIS error GIVES BODY as EXPRESSION IS OF TYPE INCORRECT for where clause where I mark it as "BOLD".

    I think Miss me a small detail to add here, but I can't do even now it seems for me that I'm working on it since the morning and SQL are a little complex in real time who also write.


    I use-

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    Please suggest me!

    Until then I'm also working on this issue hope will find a solution.

    In the database (we show it with a standalone function, you should put it in a package):

    create or replace function CMTS_SUCCESS_FAILED_RESEG_ORDR (
      p_item_name IN SYS.DBMS_DEBUG_VC2COLL,
      p_trans_id IN number
    )
    return sys_refcursor is
      l_refcur sys_refcursor;
    begin
      open l_refcur for
        SELECT cmts , COUNT(*)
          FROM test_tab
        WHERE cmts member of p_item_name
           AND trans_id = p_trans_id
        GROUP BY cmts;
      return l_refcur;
    end CMTS_SUCCESS_FAILED_RESEG_ORDR;
    /
    

    In Java:

    import java.math.BigDecimal;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import oracle.jdbc.OracleCallableStatement;
    import oracle.jdbc.OracleTypes;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.sql.ARRAY;
    import oracle.sql.ArrayDescriptor;
    
    public class SQLCollection {
    
        public static void main(String[] args) throws SQLException {
    
            System.out.println("Class SQLCollection started.");
    
            OracleDataSource ods = null;
            Connection conn = null;
            CallableStatement cs = null;
            ResultSet rset = null;
    
            try {
                ods = new OracleDataSource();
                String url = "jdbc:oracle:thin:@//127.0.0.1:1522/orcl.localdomain";
                ods.setURL(url);
                ods.setUser("stew");
                ods.setPassword("stew");
                conn = ods.getConnection();
                conn.setAutoCommit(false);
    
                ArrayDescriptor oracleVarchar2Collection =
                    ArrayDescriptor.createDescriptor("SYS.DBMS_DEBUG_VC2COLL", conn);
                String[] inset = new String[2];
                inset[0] = "wnlb-cmts-11-04";
                inset[1] = "wnlb-cmts-11-01";
                ARRAY ora_inset = new ARRAY(oracleVarchar2Collection, conn, inset);
    
                cs = conn.prepareCall("begin ? := CMTS_SUCCESS_FAILED_RESEG_ORDR(?, ?); end;");
                cs.registerOutParameter(1, OracleTypes.CURSOR);
                cs.setArray(2, ora_inset);
                cs.setBigDecimal(3, new BigDecimal("568890112115"));
                cs.execute();
    
                // Dump the cursor
                rset = ((OracleCallableStatement)cs).getCursor(1);
                while (rset.next())
                    System.out.println(rset.getString(1) + ": " + rset.getInt(2));
    
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (rset != null) {
                    rset.close();
                }
                if (cs != null) {
                    cs.close();
                }
                if (conn != null) {
                    conn.close();
                }
                System.out.println("Class SQLCollection ended.");
            }
        }
    }
    
  • How to pass Variables from the Source (SQL) to tab target (JavaBin Shell) in ODI knowledge Modules

    Hi all

    My name is Alessandro and I am new to the community.

    I have a problem with the KM stage custom when I try to pass the variable from the source to the target.

    The ODI version tha I use is the 11.1.1.5.0.

    I created a stage KM following the instructions of the metalink document (Doc ID 728636.1).

    But when I insert the value of the variable in a test table, the value in a table is the name of the variable.

    Where I'm wrong?

    I am doing thi.

    (1) create a step in my goal of shell sql source and javabin KM. In the source tab I get the value of a query, and the name "LAST_UPDATE" column.

    In the target tab, I attribute to the variabile jv_last_update the value of the variable #LAST_UPDATE, with the same name in the selection column.

    source_tab.jpgtarget_tab.jpg

    (2) I created a second stage where I insert into a table of the value of the variable jv_last_update (to debug the value of the variable):

    insert_step.jpg

    (3) when I try to see what I have in the table, the value of any line is the name of the variable "#LAST_UPDATE"; ".

    result_table.jpg

    Thanks in advance


    Alessandro

    Hi Alessandro,.

    Interesting... I have not read the Oracle document you sent yet, but one thing I can guarantee you, is that it doesn't. If Oracle says that it should work, maybe it's a bug, or maybe he has changed on new versions of ODI. I am also on ODI 11.1.1.5 and I tried many different ways to pass SQL results to variables of java with all sorts of different labels, but none of them worked for me as well. But I managed to use it in a different way, so please see below if it matches your needs:

    We are just one step. The second is just to show that it worked:

    In the first step, on the source tab, select Oracle and point to the logical schema that you want to run the query:

    On the target, note the following Java BeanShell code with the SQL that you want to run:

    Now your variable must have the correct value of your SQL. To test it, I just write a comment 'Raise' to Jython in the second step:

    The result is 'X' as expected:

    It will be useful.

    Thank you!

  • How to pass variables bind to select query

    Hello
    I use jdeveloper 11.1.1.6.0 version.
    My use case is - I want to change the settings of the select clause dynamically
    For example
    My view of object query is as follows:
        SELECT FN_GET_ALFA_MESSAGE_DETAIL_SEQ(1,2) FROM DUAL
       
    where FN_GET_ALFA_MESSAGE_DETAIL_SEQ is the name of function.
    I want to pass parameters at runtime instead of 1 and 2 as a and b.
    So, how can I pass dynamic parameters (bind variables) in the display object during execution of the select clause.

    Published by: 925410 on January 7, 2013 18:25

    Hello

    You may have two bind variables (note that bind variables are always preceded by a colon in the query) as below:

    SELECT FN_GET_ALFA_MESSAGE_DETAIL_SEQ(:bind_var1,:bind_var2) FROM DUAL
    

    Then, follow the following steps:
    1. create two variables of the same names liaison in the variables section of Bind in the query tab of the VO
    2 2 disposer have a method in the class Impl of Module of the Application and within this method, pass the values of these bind variables as below:

                Impl vo = null;
                vo = get1();
                vo.setNamedWhereClauseParam("bind_var1", );
                vo.setNamedWhereClauseParam("bind_var2", );
                vo.executeQuery();
    

    3 expose this method of the the module interface of the client Application, then the method will be visible in the section data when updating controls.
    4 use the method to run the original Version of data controls you want :)

    Kind regards
    Seddik

  • How to pass variables to the basket to your fund information?

    Here's what I have to do.

    I have a site that sells the same products to several groups of people.

    When a customer enters our site that they need to choose what 'group', they belong to.

    Based on this selection of some of the images, text and links on the pages are customizable (I can do this without problems using a combination of passing parameters through the URL, and writing based on cookies).

    My problem is when I get the extraction are the cookies that I wrote do not give because the url changes to the worldsecuresystems.com.

    I tried everything I can think of to try to get the information stored in the basket page to transfer to the payment page.

    I basically need to spend the 2 pieces of data based on {{globals.cookie.creditunion}} and {{globals.cookie.group}} in the cart at checkout it is added to the CMS or order somewhere.

    I hope that makes sense.

    James

    Hi James,

    Just like Mihai said, pass variables by using the url in the payment button.

    Use the liquid version to create a payment button, here is an example:

    Checkout

    Afterwards, you should be able to go to globals.get.creditunion or globals.get.group

    Good luck

    Stoiky

  • using variable in the select statement (php)

    I have trouble using a variable in a select statement.

    The following query to manually (using a static date) works very well:

    $query_Recordset1 = "SELECT * from academyClasses WHERE the classDate > ' 2006-06-01' ';"

    However, if I use the following:

    $dateVar = date('Y-m-d');

    @mysql_select_db ($database_mw, $mw);
    $query_Recordset1 = "SELECT * from academyClasses WHERE the classDate > $dateVar";

    All records are returned, which means that the $dateVar variable is not recognized. I compared the values of $dateVar <? PHP echo $datetime;? > against the real value of my date field <? PHP echo $row_Recordset1 ["classDate"];? > in my results to the table and it seems that the values are indeed accurate regarding a date 2006-06-04 for example.

    My date field 'classDate' is of type 'date' in the mysql database. I use Dreamweaver MX 2004 with Mac OSX 10.3.9.

    I'm sure it's just a syntax problem, at least, I hope it is.

    Any help is greatly appreciated.



    It worked:

    $query_Recordset1 = "SELECT * from academyClasses WHERE the classDate > = CURRENT_DATE;

    Thank you
    MW

  • passing parameters to the select query in DB link to call him...

    I have a DB link that executes the select query based on user specified parameter.

    Now, I created an invoke activity and specified input [which must be passed to the query] and output parameters [it is the result of the query]. That invoke link activity DB calls in which a parameter was created to be used in the select query. So my question is, DB link partner take the input parameter of call activity automatically or do we need to specify a mapping for this?

    When you create a partnerlink db the setting that you create for your chosen matches the entry and when you create the variable entry in the invoke for this partnerlink is created with the type of the parameter.

    Create an assignment before your invoke and assign a value to the input variable that you created in the invoke. This value will be passed and used as a parameter in the selection.

    Heidi.

  • Why Abobe always opens at the beginning of a document, to the place where you have reached?

    I see a big problem with the last updated Adobe, my daughter has dyslexia and reading all his school books on his computer via Abobe. In the previous version, it could Save and next time , she opened the book, its opening on the page it takes a read. This feature disappeared with the last update, is it a error? If this is not the case, What considerations is initially this change?


    I spoke with le education leaders in the municipality we live in, and they see as a big problem for both teacher and students that documents always Open on the first page instead of
    where you have reached.

    Is it possible this feature will be restored during the next Update?

    Hi Lisa,

    Go to Edition-> Preferences-> GENERAL-> check "restore the last display settings when reopening documents."

    Kind regards

    Rahul

  • Address IPCONFIG auto cannot locate my Ip address. Other computers on the WIFI at home have problems of "IP address conflict address" How can I fix

    Auto IPCONFIG can find 169. addresses. My IP BigPond do not answer to 169. I force the IP to get internet now. I'm trying to return to power enable all desktop computers 3 and 5 laptops (all windows) to use WIFI that we used to be able to 2 months ago. BigPond advise me to get in touch with Microsoft on 132058 and I can only do this Mon - Fri 9.00 - 5.00 which is extremely difficult so that an employee who works 12 hours. After hours of contact would be much more preferable. How can I have my computer 'automatically' identify my IP without forcing the numbers. When I force the IP on the other computers on the home WIFI network they can not access the internet due to a "conflict with an IP address. They should automatically be able to identify and define the same IP address as the primary computer without problem. How can I fix?

    It seems much more likely that the fault is in your TG782T on Windows.

    Either way, a 'normal' router will work with many more than 4 Ethernet ports (though most only have a maximum of 4 physical Ethernet Sockets) and more than 5 wireless connections.  It is therefore likely that your ISP has "customized" your device in a way that limits the number of connections - and it is probably this "customization" that gives you your current problems.  It will be a little difficult to do this via an Internet forum (rather than sitting in front of your computer), but it should be possible.

    Please specify the following sentence: "disconnect this computer and try a new computer is always the same problem as the gateway must always have this setting, this computer in IP."  What is "this setting of intellectual property?

    In the area of local connections > Internet protocols (TCP/IP), how is the 'work' computer configured?  Normally, it would set on "Obtain an IP address automatically."  What was the setting of 'alternative' that your ISP you are trying?

    The first thing to do is to get information on your work computer.  Follow these steps:

    1. click on start, and then type the three letters cmd in the run box, and then click OK.
    2. Enter the following command and press ENTER:
    ipconfig/all > "% UserProfile%\Desktop\ip.txt" {Enter}
    3. open the IP.txt file to your desktop
    4. copy and paste the text into your response.

    One of the lines in IP.txt will be something like the following:

    ... Default gateway. : 192.168.1.254

    This number is the IP address of your router.  Open a web browser (Firefox or Internet Explorer) and enter the IP address of your default gateway in the address box.

    At this point, it is possible that it will ask you a user name and password.  If you did not one, use admin as username and leave the password empty box.  If this does not work, there is a way around this, but it involves several phone calls from your ISP.

    Unfortunately, the only manual for the TG782 I could find is terribly incomplete. http://www.thomsonbroadbandpartner.com/GetFile.php?id=6978

    After login, you should see a page with a menu on the left (see p. 26 of the pdf above thomsonbroadbandpartner).  Click on the entry for "Home Network."  Unfortunately, the manual does not show the screen that appears when you enter this part of the configuration utility.  What you are looking for are the settings for the DHCP server on the router, which assigns IP addresses to computers connected to the router (no matter if they are connected by wire or wireless).

    Because the manual for your TG782T is not describe it, take a look at this, which is a part of the Linksys WRT54G Router configuration utility:http://cid-18b259158254905b.office.live.com/self.aspx/.Public/router%20setup.jpg

    Under the Network Configuration, the local IP address is set to 192.168.1.1.  On your router, the default value for this entry is 192.168.1.254.  Just under which are entered for "DHCP Server" "" starting IP address"and"Maximum number of DHCP users."  Here are the settings that you want to search.  The two critical parameters, as regards your current problem is are (1) the server DHCP must be "enabled" and "(2) the number of DHCP users Maximum" must be equal to or greater than the total number of computers that you want to connect (wired and wireless).

    Sorry I can't give you more specific instructions.  Usually, the user guide for the router will display all the available screens in the router configuration utility... but not this one.

  • passing variable table_name in SELECT... IN... FROM in pl/sql

    DECLARE
    cnt1 number;
    cnt2 number;
    tab_name  varchar2(34);
    bkp_tab_name varchar2(34) ;
    CURSOR c_cur IS select table_name from dba_tables where username='XXX';
    c1   c_cur%ROWTYPE;
    BEGIN
    tab_name='XXX.'||c1.table_name||'';
    bkp_tab_name='XXX.'||substr(c1.table_name,1,26)||'_BKP' ;
    select count(*) into cnt1 from tab_name;      ------------------------>how to pass "tab_name"  variable in this loop ??
    select count(*) into cnt2 from bkp_tab_name;  ------------------------>how to pass "bkp_tab_name"  variable in this loop ??
    dbms_output.put_line('original tab count: '||cnt1);
    dbms_output.put_line('backup tab count: '||cnt2);
    END LOOP;
    END;
    /
    in over pl/sql block how can I pass the variable table_name and bkp_tab_name Select... IN... CLAUSE?

    It is a very poor design.

    It would be something like this...

    DECLARE
    cnt1 number;
    cnt2 number;
    sql1 varchar2(4000) ;
    sql2 varchar2(4000);
    tab_name  varchar2(34);
    bkp_tab_name varchar2(34) ;
    CURSOR c_cur IS select table_name from dba_tables where username='XXX';
    c1   c_cur%ROWTYPE;
    BEGIN
    tab_name='XXX.'||c1.table_name||'';
    bkp_tab_name='XXX.'||substr(c1.table_name,1,26)||'_BKP' ;
    --select count(*) into cnt1 from tab_name;      ------------------------>how to pass "tab_name"  variable in this loop ??
    --select count(*) into cnt2 from bkp_tab_name;  ------------------------>how to pass "bkp_tab_name"  variable in this loop ??
    sql1 := 'select count(*) from '||tab_name;
    sql2 := 'select count(*) from '||bkp_tab_name;
    execute immediate sql1 into cnt1;
    execute immediate sql2 into cnt2;
    dbms_output.put_line('original tab count: '||cnt1);
    dbms_output.put_line('backup tab count: '||cnt2);
    END LOOP;
    END;
    / 
    

    but maybe you had better explain what you are trying to reach that make dynamic SQL is not a good idea, and it is rare that you should have the dynamic table names that are not known at design time.

Maybe you are looking for