Skip to Content
author's profile photo Former Member
Former Member

data existence check for database table

Hi guys,

anybody suggest me a better & effective way of checking a database table whether data exist in it or not?

ur help appericiated...

raja

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 15, 2005 at 07:18 AM

    Or Another way:

    tables <DBTAB>.

    select single * from <DBTAB>.

    check sy-subrc = 0.

    ....

    Svetlin

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Raja

      But what do you really want to do? Do you want to check if there is a certain record or if there is at least one record?

      Anyway SELECT SINGLE works wituout condition, it should return the first record.

      But I think is better:

      Select * up to 1 rows from <table>.

      endselect .

      Than:

      Select single * from <table>.

      Max

      Message was edited by: max bianchi

  • author's profile photo Former Member
    Former Member
    Posted on Oct 15, 2005 at 06:55 AM

    There are vairious ways

    Most effective one is

    Select * up to 1 rows from <DBTAB>.

    endselect .

    If sy-subrc ne 0.

    endif .

    ( Sy-subrc will not be zero if data does not exist )

    Or

    Select count( * ) from <DBTAB>.

    If sy-subrc ne 0.

    endif.

    ( This will be slower than the first one in case table has some data ).

    Cheers.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 15, 2005 at 07:23 AM

    Hi

    I think the best way is to do a selection withouh use of haderline.

    PARAMETERS: P_BUKRS LIKE T001-BUKRS.

    AT SELECTION-SCREEN.

    SELECT SINGLE BUKRS FROM T001 INTO P_BUKRS

    WHERE BUKRS = P_BUKRS.

    IF SY-SUBRC <> 0.

    MESSAGE E.....

    ENDIF.

    MAX

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.