Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    74

    Arrow Unanswered: How can I more faster find out whether there are any records in a table?

    HI,all
    I am coding using SPB. I want to know whether there are any records in a table. I don't want to use the statement of "select count(*) into :var from my_table" and then I judge the value of the :var. It's too slow. Is there a system variable contained the count of records of a table in DB2? or can I break the SQL statement when the sql have fetched 1 row in a table?

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: How can I more faster find out whether there are any records in a table?

    Can use FETCH TOP 1 ROW ONLY and/or OPTIMIZE FOR 1 ROW ...

    Refer to the DB2 manuals for correct syntax ...

    Cheers

    Sathyaram

    Originally posted by zhouhaiming
    HI,all
    I am coding using SPB. I want to know whether there are any records in a table. I don't want to use the statement of "select count(*) into :var from my_table" and then I judge the value of the :var. It's too slow. Is there a system variable contained the count of records of a table in DB2? or can I break the SQL statement when the sql have fetched 1 row in a table?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •