Need a Query to search a value from all tables.

Hi,
I would like to know, is there any way that we could search a string from all the tables.
For example I need to find a STRING 'hello world', on which table it presents. I want to search it from all the tables, as there might be a situtation
where we dont knwo which table the value gets stored.
REgards
Suresh

Run this code ---this is only search for required value in VARCHAR2 column.as per ur requirement u can change it to oher dataype..
Reply if its helpful to you
DECLARE
S SYS_REFCURSOR;
CURSOR c_user_col IS
SELECT TABLE_NAME,COLUMN_NAME,DATA_TYPE FROM USER_TAB_COLUMNS,TAB
WHERE TABLE_NAME=TNAME AND TABTYPE='TABLE'
ORDER BY TABLE_NAME;
TYPE TAB_LIST
IS
RECORD
TABLE_NAME VARCHAR2(1000),
COLUMN_NAME VARCHAR2(1000),
DATA_TYPE VARCHAR2(100));
TYPE T_TAB_LIST
IS
TABLE OF TAB_LIST;
L_TAB_LIST T_TAB_LIST := T_TAB_LIST();
L_STMT CLOB;
l_exists NUMBER;
BEGIN
FOR i IN c_user_col LOOP
L_TAB_LIST.EXTEND;
L_TAB_LIST(L_TAB_LIST.LAST).TABLE_NAME := I.TABLE_NAME;
L_TAB_LIST(L_TAB_LIST.LAST).COLUMN_NAME := i.COLUMN_NAME;
L_TAB_LIST(L_TAB_LIST.LAST).DATA_TYPE := i.DATA_TYPE;
END LOOP;
FOR i in 1..L_TAB_LIST.COUNT LOOP
l_exists := NULL;
IF L_TAB_LIST(I).DATA_TYPE = 'VARCHAR2' THEN
L_STMT := 'SELECT 1 FROM '||L_TAB_LIST(I).TABLE_NAME||' WHERE '||L_TAB_LIST(I).COLUMN_NAME||'=''samplesdfsdfsdf''';
OPEN S FOR L_STMT;
FETCH S INTO l_exists;
CLOSE S;
IF l_exists IS NULL THEN
NULL;
ELSE
DBMS_OUTPUT.PUT_LINE('Table name: '||L_TAB_LIST(I).TABLE_NAME||'--Column Name: '||L_TAB_LIST(I).COLUMN_NAME);
DBMS_OUTPUT.PUT_LINE(L_STMT);
END IF;
END IF;
END LOOP;
END;

Similar Messages

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • Query Expression not returing value from Systemuser table

    HI All,
    I tried to fetch user from Systemuserbase using QueryExpression using below Query but its not Retriving values
    QueryExpression query = new QueryExpression("systemuser");
    query.ColumnSet = new ColumnSet(true);
    query.Criteria.AddCondition(new ConditionExpression("domainname", ConditionOperator.Equal,
    proposal.ModifiedBy));
    var coltest = orgService.RetrieveMultiple(query);
     for (int i = 0; i < coltest.Entities.Count; i++)
     systemuserid = new Guid(coltest[i].Attributes["systemuserid"].ToString());
    proposal.ModifiedBy may change based on user the values will be ASKA\ADMIN and ASKA\USER (the user will be passed from share point)

    Hi,
    What happens if you put the proposal.ModifiedBy into a string of its own before using it in the fetch?
    I.e.
    string userName = proposal.ModifiedBy;QueryExpression query = new QueryExpression("systemuser");
    query.ColumnSet = new ColumnSet(true);
    query.Criteria.AddCondition(new ConditionExpression("domainname", ConditionOperator.Equal, userName));
    var coltest = orgService.RetrieveMultiple(query);
     for (int i = 0; i < coltest.Entities.Count; i++)
     systemuserid = new Guid(coltest[i].Attributes["systemuserid"].ToString());
    There might be som issues with how the string is formatted from wherever you're getting it. If that doesn't work you can do a string.replace and add an extra backslash if needed.
    Regards
    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

  • Is there any way to improve Query which searches XML data from a table??

    hi all,
    i have a table which have one column say 'colA' as Varchar(max) datatype which  i  save xml data and it have other cols too 
    Currently i am searching data inside this table using like operator
    eg:
    Select * from tablename where colA like ‘%<tagname>parameterstringvalue</tagname>%’
    when i check with the Execution plan i could see it Takes 82% for clusterd index scan ( primarykey col
    not ColA)
    i added new non clusterd index for the same with include col as ColA and i found nonclusterd index scan
    with same estimated I O cost and Extimated operator cost as clusterd index scan
    My Question is :-
    1. why didnt nonclusterd index seek come?
    2. In What way i can improve perfomance for such situvation? i had seen couple of post suggesting to rewrite the Query as SELECT
    * FROM myTable WHERE CONTAINS (myCol1, myCol2, "myString").
    I Try creating Full text index and found cost increased compared to the original Query ?
    3. As per my assumption the wild charecter ('%') in begining makes perfomance issue is there any option
    or an alternative for such case?

    hi...i can give a skeleton 
    --Table Structure------------
    Table1:-
    (colA - int(PK),
    ColB - Varchar(max),
    ColC-uniquieidentifier,
    ColD-datetime,
    ColE-Bit)
    It have clusterd index for ColA
    Table2:-
    (ColA-int(fk)
    colF-int(pk)
    colG-varchar(max),
    ColH-uniqueidentifier,
    colI-int,
    colJ-int
    ColK-date)
    -----------------Query Skeleton-------------------: 
    select Distinct
    s.colA,
    s.ColB,
    S.colC,
    S.colD
    from Table1 s with (nolock)
    left outer join table2 Q with (nolock) on s.colA=q.ColA
    where Q.ColA is null
    and s.colB like '%<tag>sometext</tag>%'
    and s.colD >='1/1/2010'
    and s.colD <='1/1/2014'
    i hope this will help to understand it clearly.........

  • How to select distinct values from a table when it has composite primary ke

    Hi
    I have the requirement like , I need to select distinct one column values from the table which has composite primary key. How to acheive this functioinality using view object.
    Eg : Table 1 has col1 and col2, col3
    col1 col2 col3
    1 A NA
    1 B NA
    2 A NA
    3 C NA
    2 D NA
    primary key (col1,col2)
    I have to select distinct col1.
    Thanks

    Hi
    I got the solution for above. By Creating the read only view object we can acheive this.
    thanks

  • Can retrieve value from one table, but not the other (exception thrown)

    Hi
    I hope some friendly soul can help me out here. I have a local Access database file. I am able to get a value from all tables except for one, which throws this error: "System.NullReferenceException:
    Object reference has not been specified to an object".
    The rather simple lines of code when working is this:
    Dim email As Object
    value = MyDataSet.Tables("Table")(0)(1).ToString
    Msgbox(email)
    However, when simply changing from "Table" to "AnotherTable", the exception is thrown. I
    have seriously no idea why. I've made sure the datatypes are the same and that the values are not NULL.
    What gives?

    Hello,
    Going with your last reply, you should be accessing data via the strong typed classes that get generated.
    Example using Microsoft Northwind database accessing the customers table in a MS-Access database. Note the check for Rows, we could even go farther if we are questioning issue with the data via try-catch statements writing errors to the IDE Output window.
    I would highly recommend never referencing rows without first checking if there are rows and secondly never reference columns by ordinal index, always use the column name. One example with ordinal positioning, suppose someone did SomeDataTable.Columns("SomeColName").SetOrdinal(3)
    and you expect the ordinal position to be 1 ? things will crash-n-burn. Food for thought :-)
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.CustomersTableAdapter.Fill(Me.MainDataSet.Customers)
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If MainDataSet.Customers.Rows IsNot Nothing Then
    Dim FirstCompanyName As String = MainDataSet.Customers.FirstOrDefault.CompanyName
    MessageBox.Show(FirstCompanyName)
    Else
    MessageBox.Show("No rows in customer table")
    End If
    End Sub
    End Class
    In this case we get the first record from below in Button1 Click
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Copy selected values from a table control into another table control

    hi there,
    as seen in the subject i need to copy selected values from a table control into another table control in the same screen. as i dont know much about table controls i made 2 table controls with the wizard and started to change the code... right now im totally messed up. nothing works anymore and i don't know where to start over.
    i looked up the forums and google, but there is nothing to help me with this problem (or i suck in searching the internet for solutions)
    i have 2 buttons. one to push the selected data from the top table control into the bottom tc and the other button is to push selected data from the bottom tc into the top tc. does somebody has a sample code to do this?

    you're funny
    i still don't get it... can't believe, there is no tutorial or sample code around how to copy multiple selected rows from a tc.
    here's my code, maybe you can tell me exactly were i have to change it:
    tc1 = upper table control
    tc2 = lower table control
    SCREEN 0100:
    PROCESS BEFORE OUTPUT.
      MODULE status_0100.
      MODULE get_nfo. --> gets data from the dictionary table
      MODULE tc1_change_tc_attr.
      LOOP AT   it_roles_tc1
           INTO wa_roles_tc1
           WITH CONTROL tc1
           CURSOR tc1-current_line.
      ENDLOOP.
      MODULE tc2_change_tc_attr.
      LOOP AT   it_roles_tc2
           INTO wa_roles_tc2l
           WITH CONTROL tc2
           CURSOR tc2-current_line.
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP AT it_roles_tc1.
        CHAIN.
          FIELD wa_roles_tc1-agr_name.
          FIELD wa_roles_tc1-text.
        ENDCHAIN.
        FIELD wa_roles_tc1-mark
          MODULE tc1_mark ON REQUEST.
      ENDLOOP.
      LOOP AT it_roles_tc2.
        CHAIN.
          FIELD wa_roles_tc2-agr_name.
          FIELD wa_roles_tc2-text.
        ENDCHAIN.
        FIELD wa_roles_tc2-mark
          MODULE tc2_mark ON REQUEST.
      ENDLOOP.
      MODULE ok_code.
      MODULE user_command_0100.
    INCLUDE PAI:
    MODULE tc1_mark INPUT.
      IF tc1-line_sel_mode = 2
      AND wa_roles_tc1-mark = 'X'.
        LOOP AT it_roles_tc1 INTO g_tc1_wa2
          WHERE mark = 'X'.    -
    > big problem here is, that no entry has an 'X' there
          g_tc1_wa2-mark = ''.
          MODIFY it_roles_tc1
            FROM g_tc1_wa2
            TRANSPORTING mark.
        ENDLOOP.
      ENDIF.
      MODIFY it_roles_tc1
        FROM wa_roles_tc1
        INDEX tc1-current_line
        TRANSPORTING mark.
    ENDMODULE.                    "TC1_MARK INPUT
    MODULE tc2_mark INPUT.
      IF tc2-line_sel_mode = 2
      AND wa_roles_tc2-mark = 'X'.
        LOOP AT it_roles_tc2 INTO g_tc2_wa2
          WHERE mark = 'X'.             -
    > same here, it doesn't gets any data
          g_tc2_wa2-mark = ''.
          MODIFY it_roles_tc2
            FROM g_tc2_wa2
            TRANSPORTING mark.
        ENDLOOP.
      ENDIF.
      MODIFY it_roles_tc2
        FROM wa_roles_tc2
        INDEX tc2-current_line
        TRANSPORTING mark.
    ENDMODULE. 
    thx for anybody who can help with this!

  • Search Help values to Internal table

    Dear Friends,
    Is it possible to export Search Help values to Internal table?
    On screen, when user click on Search button, the SAP standard search help will call (Customer Search). After entering values, some result get displayed and this result need to export to the internal table.
    Thanks in stack
    Nilesh

    Hi:
    try this:
    DATA : wa_shlp TYPE shlp_descr,
               it_records LIKE ddshretval OCCURS 0 WITH HEADER LINE.
    wa_shlp-SHLPNAME = 'MAT0M'.   "one of elementary search help name from mara-matnr.
    wa_shlp-SHLPTYPE = 'SH'.
    CALL FUNCTION 'F4IF_SELECT_VALUES'
         EXPORTING
           shlp                   = wa_shlp
      MAXROWS                = 0
      SORT                   = ' '
      CALL_SHLP_EXIT         = ' '
    IMPORTING
      MAXROWS_EXCEEDED       =
        TABLES
      RECORD_TAB             =
      RECDESCR_TAB           =
          return_tab            = it_records
    LOOP AT it_records.
      WRITE:/ it_records.
    ENDLOOP.
    Follows is how to get the search help name:
    CALL FUNCTION 'DD_SHLP_GET_HELPMETHOD'
      EXPORTING
        tabname                 = 'MARA'
        fieldname               = 'MATNR'
        langu                   = sy-langu
      NO_CHKTAB_MAPPING       =
      GET_ENTITYTAB           = ' '
       CHANGING
         shlp                    = wa_shlp
      callcontrol             = callcontrol
      EXCEPTIONS
        field_not_found         = 1
        no_help_for_field       = 2
        OTHERS                  = 3
    CALL FUNCTION 'F4IF_EXPAND_SEARCHHELP'
       EXPORTING
         shlp_top = wa_shlp
       IMPORTING
         shlp_tab = shlps.
    好运,
    启明星

  • How to get string value from database table using Visual Studio 2005?

    Hi,
    Im developing plugin in illustrator cs3 using visual studio 2005. I need to get the values eneterd in database. Im able to get the integer values. But while getting string values it is returning empty value.
    Im using the below code to get the values from database table
    bool Table::Get(char* FieldName,int& FieldValue)
        try
            _variant_t  vtValue;
            vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
            FieldValue=vtValue.intVal;
        CATCHERRGET
        sprintf(m_ErrStr,"Success");
        return 1;
    Im using the below code to get the values.
    AIErr getProjects()
        char buf[5000];
        int i;   
        std::string  catName;
        ::CoInitialize(NULL);
        Database db;
        Table tbl;
        errno_t err;
        err = fopen(&file,"c:\\DBResult.txt","w");
        fprintf(file, "Before Connection Established\n");
        //MessageBox(NULL,CnnStr,"Connection String",0);
        if(!db.Open(g->username,g->password,CnnStr))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        fprintf(file, "After Connection Established\n");
    if(!db.Execute("select ProjectID,ProjectName from projectsample",tbl))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        int ProjectID;
        int UserID;
        int ProjectTitle;
        char ProjectName[ProjectNameSize];
        if(!tbl.ISEOF())
            tbl.MoveFirst();
        ProjectArrCnt=0;
        for(i=0;i<128;i++)
            buf[i]='\0';
            int j=0;
        while(!tbl.ISEOF())
            if(tbl.Get("ProjectID",ProjectID))
                fprintf(file,"Project ID: %d ",ProjectID);
                ProjectInfo[ProjectArrCnt].ProjectID = ProjectID;
                sprintf(buf,"%d",ProjectID);
                //MessageBox(NULL, buf,"f ID", 0);
                j++;
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            //if(tbl.Get("ProjectTitle",ProjectName))
            if(tbl.Get("ProjectName",ProjectName))
                MessageBox(NULL,"Inside","",0);
                fprintf(file,"ProjectTitle: %s\n",ProjectName);
                //catName=CategoryName;
                ProjectInfo[ProjectArrCnt].ProjectName=ProjectName;
                //sprintf(buf,"%s",ProjectName);
                MessageBox(NULL,(LPCSTR)ProjectName,"",0);
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            ProjectArrCnt++;
            //MessageBox(NULL, "While", "WIN API Test",0);
            tbl.MoveNext();
        //MessageBox(NULL, ProjectInfo[i].ProjectName.c_str(),"f Name", 0);
        ::CoUninitialize();
        //sprintf(buf,"%s",file);
        //MessageBox(NULL,buf,"File",0);
        fprintf(file, "Connection closed\n");
        fclose(file);
        for(i=0;i<ProjectArrCnt;i++)
            sprintf(buf,"%i",ProjectInfo[i].ProjectID);
            //MessageBox(NULL,buf,"Proj ID",0);
            //MessageBox(NULL,ProjectInfo[i].ProjectName.c_str(),"Project Name",0);
        return 0;
    In the above code im geeting project D which is an integer value. But not able to get the project name.
    Please some one guide me.

    As I said in the other thread, this really isn't the place to ask questions about a database API unrelated to the Illustrator SDK. You're far more like to find people familliar with your problem on a forum that is dedicated to answering those kinds of questions instead.

  • How to retrieve 2 values from a table in a LOV

    Hi
    I'm pretty new to APEX. I try to retrieve two values from a table using a LOV. I have a table named DEBIT with then columns SITE, NAME and KEY
    I want to display NAME to the user in a list. When the user select an item from the list, I want to retrieve the data of the SITE and KEY column of this item in order to launch an SQL command based on this two values.
    How to retrieve thes two values whant the user chooses an item from the list ?
    I apologize for my english, being french.
    Regards.
    Christian

    Christian,
    From what I understood about your requirement, you want a 'select list with submit' which displays "NAME" and based on the value selected, you want to get the corresponding values for "SITE" and "KEY" from the table.
    <b>Step 1: Create a select list with submit, say P1_MYSELECT </b><br><br>
    Use something like this in the dynamic list of values for the select list: <br>
    SELECT NAME display_value, NAME return_value
    FROM DEBIT<br><br>
    <b>Step 2: Create a page process of type PL/SQL block. Also create 2 hidden items P1_KEY and P1_SITE. </b><br><br>
    In the PL/sQL, write something like:
    DECLARE
      v_key DEBIT.KEY%TYPE;
      v_site DEBIT.SITE%TYPE;
      CURSOR v_cur_myvals IS
              SELECT KEY, SITE
              FROM DEBIT
              WHERE NAME = :P1_MYSELECT;
    BEGIN
      OPEN v_cur_myvals;
      LOOP
              FETCH v_cur_myvals
              INTO  v_key,v_site;
              EXIT WHEN v_cur_myvals%NOTFOUND;
    :P1_KEY := v_key;   
    :P1_SITE := v_site; 
      END LOOP;
      CLOSE v_cur_myvals;
    END; <br><br>
    Then you can use these values for whatever purpose you need to.
    Hope this helps.

  • POPUP FM to get values from a table control?

    I know about the FM POPUP_GET_VALUES to get one or more values from a popup dialog box.  I would like to find a similar FM that allows getting values from a table control or something that allows entry of multiple lines of values.  Is there such a thing, or do I need to write my own?

    it depends on what values you want to enter, better write your own to have a control on the function.

  • How to get edited row values from ADF table?

    JDev 11.
    I have a table which is populated with data from Bean.
    I need to save changes after user make changes in any table cell. InputText is defined for table column component.
    I have defined ValueChangeListener for inputText field and AutoSubmit=true. So when user change value in inputText field, method is called:
    public void SaveMaterial(ValueChangeEvent valueChangeEvent) {
    getSelectedRow();
    SaveMaterial(material);
    This method should call getSelectedRow which take values from selected table row and save them into object:
    private Row getSelectedRow(){
    RichTable table = this.getMaterialTable();
    Iterator selection = table.getSelectedRowKeys().iterator();
    while (selection.hasNext())
    Object key = selection.next();
    table.setRowKey(key);
    Object o = table.getRowData();
    material = (MATERIAL) o;
    System.out.println("Selected Material Desc = "+material.getEnumb());
    return null;
    Problem is that getSelectedRow method doesnt get new (edited) values, old values are still used.
    I have tried to use ActiveButton with same method and it works fine in that case. New values are selected from active row and inserted into object.
    JSF:
    <af:table var="row" rowSelection="single" columnSelection="single"
    value="#{ManageWO.material}" binding="#{ManageWO.materialTable}">
    <af:column sortable="false" headerText="E-number">
    <af:inputText value="#{row.enumb}" valueChangeListener="#{ManageWO.SaveMaterial}" autoSubmit="true"/>
    </af:column>
    <af:column sortable="false" headerText="Description">
    <af:inputText value="#{row.desc}" valueChangeListener="#{ManageWO.SaveMaterial}" autoSubmit="true"/>
    </af:column>
    </af:table>
    <af:activeCommandToolbarButton text="Save" action="#{ManageWO.EditData}"/>
    What is a correct place from where save method should be called to get new (edited) values from ADF table?
    Thanks.

    Did you look into the valueChangeEvent?
    It has oldValue and newValue attributes.
    public void SaveMaterial(ValueChangeEvent valueChangeEvent) {
    Object oldVal = valueChangeEvent.getOldValue();
    Object newVal = valueChangeEvent.getNewValue();
    // check if you see what you are looking for.....
    getSelectedRow();
    SaveMaterial(material);
    }Timo

  • Values from CRCO Table.

    Hi all ,
    I need to retreive some values from CRCO table based on the balues fetched from AFRU table. I am writing a select like this
    select single KOKRS KOSTL into table itab from CRCO
              where OBJTY = 'A'
                 and OBJID  = AFRU-ARBID
                 and ENDDA >= AFRU-BUDAT
                 and BEGDA <= AFRU-BUDAT.
    As I need to retreive a single record from above select, but as a result i am getting multiple records.
    Can anybody tell me what other keys from AFRU I can specify in the select in order to fetch only a single record.
    Thanks,
    Mungala.

    Object ID you can get from ARBID from AFRU Table. Put value of ARBID in OBJID in table CRCO & get values of KOKRS & KOSTL. That value will be unique for an work center But if ARBID values are many for an AUFNR(order no.) that mean you are using different work center where in may be you are using different cost center(i think controlling area will remain same). & hence SAP creates different records.
    Regards
    Prashant Jaiswal

  • How to display the values from the table in the screen

    Hi,
    I have created a screen where i will enter the values for the field treshold amount and desc and if i press update button  .it will update the new values by overriting the existing values .
    Now i have got requirement i need to create a button show which will display the existing value from the table. always there will be only one entry...in this table
    Please can one give me idea...to do this
    or sample code...thanks in advance
    regards
    paveeeeee

    Define a function code 'SHOW' for your button. In your PAI module, when you check for various sy-ucomms, check for 'SHOW' also.
    Your code will be like this:
    Case sy-ucomm.
      when 'SHOW'.
         perform show_details.
    endcase.
    In the perform, you can fetch the data from the table and put it in global variables. In the PBO, move the data from the global variables to the screen fields so that they get displayed on the screen.
    Hope this helps. Reward points for useful answers.
    Regards
    Nithya

  • How to truncate the values from the table

    Hi All,
    I am working on an issue..where we are first deleting all the records from the table and then based on few conditions we are putting the records back in that table...when we tried to run this program along with few others those who are doing almost the same stuff we are having issues...we tried to schedule few jobs related to these programs only...but after a ceratin amount of time couple of jobs got canceled...I was talking to my basis guy and he said the problem is ratehr then truncating the records from the table we are deleting the records and it's taking lots and lots of space to execute...so we need to truncate the records from the table insted of deleting it...we are using the following the statement right now:
        DELETE FROM ZTUS_PG.
        COMMIT WORK.
    So can you please tell me how can we truncate the values from this table instead of just deleting them and what would be effect of this.
    Thanks,
    Rajeev Gupta

    I don't think basis is saying you should delete all the records from the table. They are saying remove the table and it's contents (a much faster thing to do). I'm not sure this the right thing to do, but you can have a look at:
    http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.sample.doc/doc/admin_scripts/s-truncate-db2.htm
    Something like:
    EXEC SQL.
      TRUNCATE TABLE ZTUS_PG REUSE STORAGE
    ENDEXEC.
    COMMIT WORK.                      "Empty table is committed here
    Rob
    Edited by: Rob Burbank on Dec 1, 2008 4:06 PM

Maybe you are looking for