How to select a table in plsql

hello,
I have to select a complete table in a plsql block . But I am facing a problem of into clause with select statement in plsql. What should i do?
If anybody knows how to do this then please help me out.
Thanks,

This one also you can try.
DECLARE
TYPE l_mobile_no IS TABLE OF main_mast.mobile_no%TYPE;
TYPE l_cust_name IS TABLE OF main_mast.cust_name%TYPE;
TYPE l_email IS TABLE OF main_mast.email%TYPE;
tab_mobile_no l_mobile_no();
tab_cust_name l_cust_name();
tab_email l_email();
BEGIN
SELECT mobile_no,cust_name,email
BULK COLLECT INTO tab_mobile_no,tab_cust_name,tab_email
FROM  main_mast
where rownum<10;
FOR z in tab_mobile_no.first..tab_mobile_no.last
loop
dbms_output.put_line('Mobile_no'||' '||tab_mobile_no(z)||'NAME'||' '||tab_mobile_name(z)||' '||'EMAIL'||' '||tab_email(z));
end loop;
END;You can write into a file using of utl_file if the table contains more number of records.
Regards,
Achyut K
Edited by: Achyut K on Aug 5, 2010 2:09 AM

Similar Messages

  • How to select a table based on a button event

    Can we make control in row selection?
    For eg, i have added a button in my column. So it will be displayed in all rows.Clicking on the button the entire row should be selected.How to do it.
    Thanks in advance

    Hi Kishore,
    Add the press event handler for your button as below,
    new sap.ui.commons.Button({press:function(oEvent){
      oTable.setSelectedIndex(oEvent.getSource().getParent().getIndex());
    Refer to this snippet http://jsbin.com/kikubupa/1/edit
    regards
    sakthi

  • How to select a new table in logical database after creating the Infoset

    I have created a abap query report ,i have used logical data base ADA in the infoset in SQ02.In the logical database i had selected only two tables then ANALV and ANLB.Now my client wants one more field to be added and thats is from table ANEK.Now i need to select this table in logical database ADA.
    Please assist on how to select another table available in the Logicaldata base now which i didnt select when i created the query

    Markus,
    I have now selected the additional field Posting date in Document ANEK -BUDAT .Earlier the report had the fields from ANLCV - Current acquisition value ,ordinary dep posted selected for  the output.
    When i run the query after adding this new field ANEK-BUDAT the below warning  is generated  by system :
    The query specifications cannot be used to generate a list,
    i.e. the query will probably not return the list you desire.
    If you still want to execute the query, please use the
    "Generate" function
    -> 'Generate'
    Fields from parallel tables within a line*
    Line: 01
    Field: Posting Date in the Document
    (ANEK-BUDAT, table ANEK)
    Field: Ordinary depreciation posted
    (ANLCV-NAFA GEB, table ANLCV)
    Fields from parallel tables within a line*
    Line: 01
    Field: Posting Date in the Document
    (ANEK-BUDAT, table ANEK)
    Field: Current asset acquisition value
    (ANLCV-LFD KANSW, table ANLCV)
    2 warnings for query QUERY ***
    Please advice .How get this new field added.

  • SELECT POOLED TABLE IN SUBQUERY

    Hi all,
    how to select pooled table in subquery?
    e.g. Pooled table: A017
    SELECT * FROM A017
    INTO CORRESPONDING FIELDS OF TABLE itab
    WHERE exists ( SELECT * FROM EINA WHERE MATNR = A017~MATNR ).
    it gives a syntax error and runtime error when I use A017-MATNR.

    Hi,
    If u want to use exists then u can try this out
    DATA: WA_SFLIGHT TYPE SFLIGHT.
    SELECT * FROM SFLIGHT AS F INTO WA_SFLIGHT
        WHERE SEATSOCC < F~SEATSMAX
          AND EXISTS ( SELECT * FROM SPFLI
                        WHERE CARRID = F~CARRID
                           AND CONNID = F~CONNID
                           AND CITYFROM = 'FRANKFURT'
                           AND CITYTO = 'NEW YORK' )
          AND FLDATE BETWEEN '19990101' AND '19990331'.
      WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID,
               WA_SFLIGHT-FLDATE.
    ENDSELECT.
    Or u can check this sample code too
    DATA: WA TYPE SFLIGHT.
    SELECT * FROM SFLIGHT
        INTO WA
        WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).
      WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE.
    ENDSELECT.
    Hope this helps.
    Thanks & Regards,
    Judith.

  • How do I CREATE IF NOT EXISTS Temp table in PLSQL?

    hello, how do I CREATE IF NOT EXISTS Temp table in PLSQL? The following table is to be created in FIRST call inside a recursive function (which you'll see in QUESTION 2).
    QUESTION 1:
    CREATE GLOBAL TEMPORARY TABLE TmpHierarchyMap
                                  Id numeric(19,0) NOT NULL,
                                  ParentId numeric(19,0) NOT NULL,
                                  ChildId numeric(19,0) NOT NULL,
    ... more ...
                             ) on commit delete rows');
    QUESTION 2: How to return a temp table from a function?
    For example, this is how I'm doing it at the moment, using Nested Table.
    EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapObjType AS OBJECT
                   Id numeric(19,0) ,
                   ParentId numeric(19,0),
                   ChildId numeric(19,0),
    ... more ...
         EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE TmpHierarchyMapTableType AS TABLE OF TmpHierarchyMapObjType;';
    CREATE OR REPLACE FUNCTION fnGetParentsTable
    ObjectId number,
    ObjectClassifier varchar2
    RETURN TmpHierarchyMapTableType
    IS
    TmpHierarchyMap TmpHierarchyMapTableType := TmpHierarchyMapTableType();
    ThisTempId varchar2(32);
    CURSOR spGetParents_cursor IS
    SELECT
    Id,
    ParentId,
    ChildId,
    FROM TMP_HIERARCHYMAP
    WHERE TempId = ThisTempId;
    BEGIN
    SELECT sys_guid() INTO ThisTempId FROM dual;
    spRecursiveGetParents(ObjectId, ObjectClassifier, ThisTempId);
    FOR oMap in spGetParents_cursor LOOP
    TmpHierarchyMap.Extend();
    TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id
    , oMap.ParentId
    , oMap.ChildId
    END LOOP;
    DELETE FROM TMP_HIERARCHYMAP WHERE TempId = ThisTempId;
    RETURN TmpHierarchyMap;
    END fnGetParentsTable;
    QUESTION 3: what does the word GLOBAL means? I read that temp table is visible only to a particular database connection/session and will be dropped automatically on termination of the session. i can only find this information in some forum discussion but failed to locate this in Oracle doc, can someone point me in right direction please?
    Many thanks!
    REF:
    http://stackoverflow.com/questions/221822/sybase-developer-asks-how-to-create-a-temporary-table-in-oracle
    http://www.oracle-base.com/articles/8i/TemporaryTables.php

    devvvy wrote:
    so if I CREATE GLOBAL TEMPORARY TABLE twice on second pass of my recursive function what then...?You don't create it inside your function.
    You create the GTT once on your database outside of the function and then just leave it there and use it.
    Tables should not be dynamically created and dropped.
    Only other database engines such as SQL Server use the concept of creating temporary tables during the execution of code. Oracle uses a "create once, use whenever" methodology.

  • How to select the data from a Maintainance View into an internal table

    Hi All,
    Can anybody tell me how to select the data from a Maintainance View into an internal table.
    Thanks,
    srinivas.

    HI,
    You can not retrieve data from A mentenance view.
    For detail check this link,
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
    Regards,
    Anirban

  • How to select all the colomns_names from a table, with their datatypes ..

    hi :)
    i would like to know, how to select in SQL all the columns names from a table with their datatypes so that i get something like this :
    Table 1 : table_name
    the column ID has the Datatype NUMBER
    the column name has the Datatype Varchar2
    Table 2 : table_name
    the column check has the Datatype NUMBER
    the column air has the Datatype Varchar2
    and that has to be for all the tables that i own ! ..
    P. S : i m trying to do this with java, so it s would be enough if you just tell me how to select all the tables_names with all their colums_names and with all their datatypes ! ..
    thank you :)
    i ve heard it can be done with USER_TABLES .. but i have no idea how :( ..
    Edited by: user8865125 on 17.05.2011 12:22

    Hi,
    The data dictionary view USER_TAB_COLUMNS has one row for every column in every table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE have all the information you need.
    Another data dictionary view, USER_TABLES, may be useful, too. It has one row pre table.

  • How to SELECT ALL records of a TABLE VIEW in the BSP page

    Hi All,
    In the BSP portal, I am displaying some data(multple records) in the form of a table using the BSP TAG <htmlb:tableView>. I wrote the logic in the 'VIEW' of the BSP application which will be triggered by the controller. I have used the attribute selectionMode = "MULTISELECT" to have a Check Box to select a row.
    My requirement is to have a button/checkbox on the first column of the header of the table view. By clicking on this, it should select/desect all the records of the table. Could someone please help me how to do this? What attribute I should use in the tableview to get the button in the header row of the table and how to select all the records of the table.?
    Please provide your valuable inputs.
    Thanks & Regards,
    Paddu.

    Select all / Deselect all functionality when onRowSelection is there

  • How to select both af:table at a time.

    Hi, I am using jdeveloper Studio Edition Version 11.1.1.3.0
    I ahve a functionality like, on my jspx page i have two af:table. & one af:commandButton.after selecting both table button, will get enable.
    I mean after selecting the first row from the table first & selecting the second row from the table second then & then button should get enable.
    How i can do this?
    <af:panelGroupLayout id="pgl1" layout="horizontal">
    <af:table value="#{managedBean1.perInfoAll}" var="row"
    rowBandingInterval="0" id="t1" rowSelection="single">
    <af:column id="c1" headerText="Name">
    <af:outputText value="#{row.name}" id="ot1"/>
    </af:column>
    <af:column id="c2" headerText="Phone">
    <af:outputText value="#{row.phone}" id="ot2"/>
    </af:column>
    <af:column id="c3"/>
    </af:table>
    <af:table value="#{managedBean1.perInfoAll2}" var="row1"
    rowBandingInterval="0" id="table1" rowSelection="single">
    <af:column id="column1" headerText="Name">
    <af:outputText value="#{row1.name}" id="outputText1"/>
    </af:column>
    <af:column id="column2" headerText="Phone">
    <af:outputText value="#{row1.phone}" id="outputText2"/>
    </af:column>
    <af:column id="c4"/>
    </af:table>
    </af:panelGroupLayout>

    Hi,
    use a managed bean that exposes true/false based on the table selection. You create a JSF component binding for both tables to the managed bean. Then from the disabled property of the button, you reference the method, which in turn checks the tables for the selecteRowKeys. If the selected row keys is empty on one of the tables then obviously the condition under which the buttons are enabled are not met and you return true. You also need to change the table selection listener because these need to PPR the button as otherwise you wont be able to change the button from diadbled to enabled
    Frank

  • How to select multiple records from a TREE in the table

    HI,
    I have a tree structure which is in the table.When I open the node of the tree,all the subnodes are coming as one-one records in the table.I want to slect multiple record from this table.I applied onLeadSelect for this table,I can select only 1 record from the table.
    Can any one plz suggest me how to select multiple records from the table so that I can get all the data of those selected record.
    Regards
    -Sandip

    Rashmi/Kukku,
    First of all, Thanks for your help!
    Is there any other way in which we can access tables other than using BAPIs or RFCs?
    In my case, there is a table structure which has to be updated with values after validating a key. i don't think there is any RFC available now. do i need to create bapi/rfc for that?
    Krishna Murthy

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • How to select data from a table by passing document number from another tab

    How to select data from a table by passing document number from another table.
    for eg:-
    I want to display name, adres, region from ADRC table
    by using field delivery document number
    Kind Regards,
    Shanbagavalli.S

    Hi Shanbagavalli,
    There are multiple solutions to this questions a few i will try to answer and then you can take the best required for your requirements.
    **Consider that you have a Internal table having document number from other table..
    SELECT NAME ADRES REGION FROM ADRC
           INTO IT_ADRC
           FOR ALL ENTRIES IN IT_DOC
           WHERE DOCUMENT_NO = IT_DOC-DOCUMENT_NO.
    **Consider that you have 1 document number then
    SELECT NAME ADRES REGION FROM ADRC
         INTO IT_ADRC
         WHERE DOCUMENT_NO = W_DOCUMENT_NO.
    Hope this solves your problem.
    Regards,
    Kunjal

  • How to populate a table based on a row selection from another table.

    Hi, i just started to use ADF BC and Faces. Could some one help me or point me a solution on the following scenario .
    By using a search component , a table is being displayed as a search result. If i select any row in the resulted table , i need to populate an another table at the bottom of the same page from another view. These two tables are related by primary key . May i know how to populate a table based on a row selection from another table. Thanks
    ganesh

    I understand your requirement and the tutorial doesn't talk about Association between the views so that you can create a Master-Detail or in DB parlance, a Parent-Child relationship.
    I will assume that we are dealing with two entities here: Department and Employees where a particular Department has many Employees and hence a Parent-Child relationship.
    Firstly, you need to create an Association between the two Entities - Department and Employees. You can do that by right clicking on the model's entity and then associating the two entities with the appropriate key say, DepartmentId.
    Once you have done that, you need to link the two entities in the View section with this Association that you created. Then go to AppModule and make sure that in the Available View Objects: 'EmployeesView' appears under 'DepartmentView' as "EmployeesView via <link you created>". Shuttle the 'DepartmentView' to the right, Data Model and then shuttle
    "EmployeesView via <link you created>" to the right, Data Model under 'DepartmentView'.
    This will then be reflected in your Data Controls. After that, you simply would have to drag this View into your page as a Master-Detail form...and then when you run this page, any row selected in the Master table, would display the data in the Detail table.
    Also, refer to this link: [Master-Detail|http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html]
    Hope this helps.

  • How to avoid a table to be selected by a user with 'select any table' grant

    Hello,
    I want a table to be non selectable for a particular user even if that user has a 'select any table' grant.
    either the query can return no rows or an error message, it doesn't matter.
    how can I achieve this with a standard database configuration? I mean I am not allowed to use any tool of Oracle like vault etc..
    thanks in advance...

    Fine-grained access control (aka VPD, more or less) is part of Enterprise Edition. It is not a separate tool. See Oracle Database Editions
    You can read about it here Using Oracle Virtual Private Database to&amp;nbsp;Control&amp;nbsp;Data Access
    The main thing to understand is the predicte-generating function, and all the opportunities there. This example is from a presentation I once gave to a local Oracle users group.
    The policy (not shown) specifies FGAC_PKG.FGAC_PREDICATE_FNC as the predicate-generating function. If the user has role FGAC_DEMO_ALL_COMPANIES_ROLE then his view is not restricted; if his username does not appear in the COMPANY_AUTHORIZATION table he will get an error when querying the protected table; otherwise he will be restricted to see only the companies he is authorized for. So this has some elements that may be useful to you.
    CREATE OR REPLACE PACKAGE BODY FGAC_DEMO_SCHEMA.FGAC_PKG AS
    FUNCTION  FORCE_FGAC_ERROR_FNC (in_object VARCHAR2) RETURN NUMBER IS
        e_not_authorized exception;
        PRAGMA exception_init(e_not_authorized, -20667);
    BEGIN
        RAISE e_not_authorized;
        RETURN (-1);  -- will NEVER get here (have already raised an error)
    EXCEPTION
       WHEN e_not_authorized  then
         RAISE_APPLICATION_ERROR (sqlcode,
                                  sqlerrm||'Access to '|| in_object ||
                                  ' requires access to at least one company, but none have been authorized.' );
    END FORCE_FGAC_ERROR_FNC;
    FUNCTION FGAC_PREDICATE_FNC (in_schema VARCHAR2, in_object VARCHAR2)
       RETURN VARCHAR2
    IS
       out_predicate   VARCHAR2 (400);
       c_filter_predicate constant varchar2(400) :=
          'COMPANY_ID IN (SELECT COMPANY_ID FROM COMPANY_AUTHORIZATION '||
          'WHERE USER_NAME = USER)';
       c_bypass_filtering_role VARCHAR2(30) := 'FGAC_DEMO_ALL_COMPANIES_ROLE';
       v_authorization_count NUMBER;
       c_error_predicate constant varchar2(400) :=
          'FGAC_DEMO_SCHEMA.FGAC_PKG.FORCE_FGAC_ERROR_FNC('''||
               in_schema||'.'||in_object||''') = 0';
    BEGIN
      IF DBMS_SESSION.is_role_enabled (c_bypass_filtering_role) THEN
          out_predicate :=  NULL;
      ELSE
         SELECT COUNT(*) INTO v_authorization_count
            FROM COMPANY_AUTHORIZATION
            WHERE USER_NAME = USER;
         IF  v_authorization_count = 0 then
           out_predicate :=  c_error_predicate;
         ELSE
          out_predicate :=  c_filter_predicate;
        END IF;
      END IF;
      RETURN out_predicate;
    END FGAC_PREDICATE_FNC;
    END FGAC_PKG;

  • How To select maximum Value in a specifieid field in internal table.

    How To select maximum Value in a specifieid field in internal table?

    Step : 1
    Sort itab by <Field1> descending.
    Just sort the internal table by the field.
    STEP: 2
    Then read the table at index 1.
    Read table itab index 1.               
    ITAB-FIELD = MAX .                  " Max field will come in the first row of the internal table.
    Regards,
    Gurpreet

Maybe you are looking for

  • Cannot open .pdfs in Firefox

    My wife's machine is running Windows 8.1, Firefox 34.0.5 and Adobe Acrobat X Standard. Cannot open .pdfs in the browser. Clicking a link to a .pdf will open a new tab that immediately closes, leaving me right back where I was, as if I had never click

  • Captivate 7 won't launch (Windows 7)

    Having installed Captivate 7 (64-bit) on Windows 7, I've found the program won't actually open. Launching it asks for the Adobe ID, while the program flashes up for a second in the background. Having entered the ID, nothing happens. Trying to launch

  • Pictures of strange women in start up screen

    why skype puts pictures of young females and facebook advertisement on stratup screen? i dont use facebook, and pictures of you women in my startup screen are highly offensive!!!!!!!!!!! how to remove this idiotic feature???? Attachments: skypepimp.p

  • Nokia 5230 Camera Pictures _ Date

    Like in sony ericsson phones, can we bring date display at the bottom of pictures taken in 5230 camera? Solved! Go to Solution.

  • No luck installing Presenter- been more than 8 hours!

    I installed Adobe Acrobat 9 Pro Extended and it has Adobe Presenter included in it. But when I open PowerPoint files there's no presenter tab. I thought I need have to install Presenter separately. So, from the installation disk I clicked on "Install