How to create a view dynamicly in plsql?

I need to write a pl/sql package to create a view dynamic
,but i can't use 'create or replace view xxxx as select *
from db where ...',I know the dbms_sql package can parse the
'select' sentence,but i don't know how to create a view,only can
drop a view,who can help me?
thanks!
null

Try 'EXECUTE IMMEDIATE 'CREATE AS SELECT....' in your PL/SQL
xhpxorcl (guest) wrote:
: I need to write a pl/sql package to create a view dynamic
: ,but i can't use 'create or replace view xxxx as select *
: from db where ...',I know the dbms_sql package can parse the
: 'select' sentence,but i don't know how to create a view,only
can
: drop a view,who can help me?
: thanks!
null

Similar Messages

  • Create a view dynamically

    I would like to create a view dynamically based on “Employee” table
    A view in each database should contain every column in “Employee” table except column called “year”. “Employee” table exists in every database but has different columns except “year” column ,so
    the employee view should contain different columns based on which database you create a view
    How can I create a view dynamically for each database? I am using SQL server 2008 R2

    Try this... (Note the @Debug parameter is there to allow you to preview the code before you create the view... 1 to view the dynamically generated code, 0 tt simply execute it.)
    DECLARE
    @DeBug BIT = 1,
    @ColumnString VARCHAR(MAX),
    @sql VARCHAR(MAX)
    SELECT
    @ColumnString = COALESCE(@ColumnString + ',' + CHAR(10) + CHAR(9), '') + c.COLUMN_NAME
    FROM
    INFORMATION_SCHEMA.COLUMNS c
    JOIN INFORMATION_SCHEMA.TABLES t ON c.TABLE_NAME = t.TABLE_NAME AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    WHERE 1 = 1
    AND t.TABLE_TYPE = 'BASE TABLE'
    AND c.TABLE_NAME = 'Employee'
    AND c.COLUMN_NAME <> 'Year'
    ORDER BY
    c.ORDINAL_POSITION
    SET @sql = '
    CREATE VIEW dbo.v_Employee
    AS
    SELECT
    ' + @ColumnString + '
    FROM dbo.Employee'
    IF @DeBug = 1
    BEGIN
    PRINT (@sql)
    END
    ELSE
    BEGIN
    EXEC (@SQL)
    END
    HTH,
    Jason
    Jason Long

  • How to create alv table dynamically by performing action on the button.

    Hi all,
    my requirement is to create alv table dynamically.
    that is i will create two buttons
    1) show alv table
    2) close alv table
    if user selects show alv table then the alv table should be displayed.
    and if user selects clsoe alv table then the alv table should be closed.
    to create alv table dynamically  i have followed this procedure.
    under view properties i have added salv_wd_table component. then under the action of showalvbutton i went to code wizard and i have selected instantiate used component component use salv_wd_table. the following code will be generated
    with this code i am unable to display alv table dynamically correct me where i went wrong kindly send me the necessary steps how to create alv table dynamically
    data lo_cmp_usage type ref to if_wd_component_usage.
    lo_cmp_usage =   wd_this->wd_cpuse_salv_wd_table( ).
    if lo_cmp_usage->has_active_component( ) is initial.
      lo_cmp_usage->create_component( ).
      endif.
    to close table i have used the following code. with this code i am able to achieve the functionality to delete the alv table
    data lo_cmp_usage type ref to if_wd_component_usage.
    lo_cmp_usage =   wd_this->wd_cpuse_salv_wd_table( ).
    if lo_cmp_usage->has_active_component( ) is initial.
      else.
      lo_cmp_usage->Delete_component( ).
    endif.
    Thanks & Regards,
    Naveen
    Edited by: naveen.webhelp on Feb 10, 2011 5:52 AM

    Hi
    ALV table will be shown in the viewcontainerUI element.
    it is shown there empty if you dont fill the node bound to the data node of the interface controller of the comp usage
    SALV_WD_TABLE.
    and if you are not getting the table filled in the first place.
    then check have you mapped the DATA node to some node in the comp controller
    wht basically is your requirment is that you want to show ALV gird on click of one button and delete it on click of other button.
    there are many ways to do so.
    best way is control the visiblity of the viewcontainer UI element which containes the TABLE view of SALV_WD_table comp.
    create an attribute of type WDUI_VISIBILITY name say VIS.
    now go to the layout and bound hte visible property of the viewcontainer to this attribute VIS.
    then in the showalv grid button's eventhandler write
    wd_context->set_attribute(
    name = 'VIS'
    value = '02'
    and in the wddoinit and delete alv grid button's event handler write
    wd_context->set_attribute(
    name = 'VIS'
    value = '01'
    thanks
    sarbjeet singh

  • How to  create i view  in visual composer give details screenshots

    how to  create i view  in visual composer give details screenshots

    Hi,
    Go through these threads
    VisualComposer
    http://help.sap.com/bp_epv170/EP_US/HTML/Executive_Cockpit.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1752b737-0401-0010-0ba3-87c3eda8c6ce
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e019d290-0201-0010-f186-8630a949800a
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30987099-a74c-2a10-70b5-a2751ce79359
    http://help.sap.com/saphelp_nw04/helpdata/en/fd/4a7e40417c6d1de10000000a1550b0/content.htm
    Tarak
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00b9ba6d-1291-2a10-208d-bd27544e7939

  • How to creat a view in

    Hi all,
    i am new to can u tell me how to creata a view. and how we can create node.and how we can create outbound plug and inbound plug.
    thanks & regards
    naveen

    Hi Naveen,
    In the component click on view qith the right button and select "Create View" follow the steps. Its a very simple wizard.
    Let me know if you have more issues.
    Best regards,
    Caíque Escaler

  • How to create a view in R/3?

    Hello, Can anyone plz gimme step by step how to create a view in R/3....

    Hi dear,
    go to SE11, out your Z* view and click create...
    Then choose your source tables, the join condition between them and, finally, all the fields (coming from source tables) you need for your purposes...
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/cf/21ed06446011d189700000e8322d00/content.htm
    Hope it helps!
    Bye,
    ROberto

  • How to create a view with Oracle apps Org initialization ?

    Hi,
    How to create a view which needs Oracle apps org initialization to provide the correct data .
    The purpose of the view is to be accessed in Primavera DB via a DB link for reporting purpose.
    So how should the org be initialized so that the view returns the correct data when accessed from the remote data base using the DB link?
    EX: step1 run fnd_client_info.set_org_context for the org
    step2 query the veiw returns correct data in Oracle.
    How can this be achieved if the view needs to be accessed via DB link?
    sample view sql :
    select po_header_id
    from po_distributions_all pod
    where (apps.po_intg_document_funds_grp.get_active_encumbrance_func
    ('PO',
    pod.po_distribution_id
    ) <> 0
    Thanks in advance!
    Darshini

    Hi,
    This is not possible in Oracle. What u can do is create the view without the where clasue and supply the where clause at runtime.
    Hope this helps...
    Regards,
    Ganesh R

  • How to create a view on tables with different keys?

    I have to create a View on:
    Z3PVR: Transparent Table
    BSEG: Cluster Table
    CKIS: Transparent Table
    BKPF: Transparent Table
    RV61A: Structure
    T001: Transparent Table
    All the tables have different "Key Fields" and the structure has no "Key Fields". When i create the view, what do I mention in the "JOIN FIELDS" tab. and how do i create the view with the structure?
    Please advise.

    How to create a view on a Non-Transparent Tables.
    how to create view?
    HELP.. How to create a view with the tables with ALV

  • How to create a view indicating column's length?

    SQL>create table abc (a number(12));
    I want to create a view cde with a length of number(5) by "describe cde" in sql*plus.
    SQL>create view cde(a) as select a from abc;
    SQL>desc cde
    A NUMBER(12)
    how to create a view indicating column's length? the actual value in abc only <1000
    I want to create a view cde with a length of number(5) .
    SQL>desc cde
    A NUMBER(12)
    Thank You
    Ming-An Zhang

    This does not make sense. How can a view be a NUMBER(5) and the actual column a NUMBER(12)?
    What happens if there is a 10 or 12 digit number in the table? Just what is the view suppose to do? Crash and burn? Where is the logic in that?!
    If the table's column has an incorrect precision and size, THEN FIX IT!! Do not hack it with view!
    It is silly purposefully building constructs into the database that can easily result in run-time errors.

  • How to create a view object and attach with extended AM

    Hi,
    I tried to create new vo and attach this vo with the extended AM. But it is throwing error like 'PC.NAME : invalid identifier' (Actually this PC.NAME is exiting one).
    Now i want to know how to create a view object similar like seeded one but with one additional condition in the where clause.
    It is possible though extension, but i want to create two view object similar like seeded one, one with some other condition in the where clause
    and another one with some other condition.
    So for my requirement, i'll extend one VO and i'll add my condition but how to do it for second condition.
    But i want same seeded VO with two different condition.
    Any suggestions please,
    SAN

    SAN,
    There is no need to attach the newly created VO with extended AM. You need to attach the same with the standard AM.
    Regards,
    Gyan

  • How to create  some columns dynamically in the report designer depending upon the input selection

    Post Author: ekta
    CA Forum: Crystal Reports
    how  to create  some columns dynamically in the report designer depending upon the input selection 
    how  export  this dynamic  report in (pdf , xls,doc and rtf format)
    report format is as below:
    Element Codes
    1
    16
    14
    11
    19
    10
    2
    3
    Employee nos.
    Employee Name
    Normal
    RDO
    WC
    Breveavement
    LWOP
    Sick
    Carers leave
    AL
    O/T 1.5
    O/T 2.0
    Total Hours
    000004
    PHAN , Hanh Huynh
    68.40
    7.60
    76.00
    000010
    I , Jungue
    68.40
    7.60
    2.00
    5.00
    76.00
    000022
    GARFINKEL , Hersch
    66.30
    7.60
    2.10
    76.00
    In the above report first column and the last columns are fixed and the other columns are dynamic depending upon the input selection:
    if input selection is Normal and RDO then only 2 columns w'd be created and the other 2 fixed columns.
    Can anybody help me how do I design such report....
    Thanks

    Hi Developer life,
    According to your description that you want to dynamically increase and decrease the numbers of the columns in the table, right?
    As Jason A Long mentioned that we can use the matrix to do this and put the year field in the column group, amount fields(Numric  values) in the details,  add  an filter to filter the data base on this column group, but if
    the data in the DB not suitable to add to the matrix directly, you can use the unpivot function to turn the column name of year to a single row and then you can add it in the column group.
    If there are too many columns in the column group, it will fit the page size automatically and display the extra columns in the next page.
    Similar threads with details steps for your reference:
    https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings 
    If your still have any problem, please try to provide us more details information, such as the data structure in the DB and the table structure you are currently designing.
    Any question, please feel free to let me know.
    Best Regards
    Vicky Liu

  • How to create a folder dynamically in KM repository

    Hi All,
    Could you please let me know how to create the folder dynamically in KM...
    Thanks in Advance,

    >
    Romano Bodini wrote:
    > Hi,
    >
    > Search the forum. And the SDN. Then ask.
    >
    > [Creating folders in KM dynamically|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1761]
    >
    > Romano
    Actually, "look at the API documentation" should be in that list.

  • How to create XMLTYPE View from the XMLType table

    Hi:
    I have a large XML file and inserted to the XMLTYPE table
    For the XQUERY purpose I would like to create XMLView of the table.
    The examples I got from Oracle to create XML view are for small files.
    Can some one help me how to create XMLType VIEW for large XML Files ( 20,000 lines )?
    Ali_2

    Have a look at the examples given on XMLType Views (based on relational tables) or standard views (based on XMLType storage) in the FAQ url located on the main page of this forum site regarding XMLDB.

  • How to create GOS view attachment list in ECC6

    Hi,
    I created Z transaction. I have to create View attachment List to this transaction. How to create GOS view attachment list in ECC6. can anybody send sample code on this.
    Thanks in advance.
    Zakir.

    Hi all,
    I've following problem with class CL_GOS_ATTACHMENTS.
    Transaction IE01/02/03 (create/change/display equipment) starts and instantiate GOS manager, and related BAdI are called.
    Then, when I choose one of available service, CL_GOS_ATTACHMENTS is instantiated, and inside that class a new GOS manager is instantiated, inspite of already existing instance.
    As a result, related BAdI are called twice, but unfortunately second time some SY variables are not correctly filled, particularly SY-TCODE and SY-MODNO are both empty.
    I've develop a workaround so that when sy-tcode is filled I save it somwhere, and when it's empty I filled it from saved value, does anyone know any other solution??
    Many thanks
    Regards
    m@x

  • How to create Maintaince View and Help View

    Hi,
    Can u pls tell me the step by step procedure for how to
    create Maintaince View and Help View.
    And what's the use of these view's.
    Regards,
    Kumar

    FOR MAINTANENCE VIEW
    Create a table or a view in transaction SE11.
    A function group in SE80 transaction
    1>go to se54 transaction.
    2>give the name of the table /view starting from z.
    3>select "Generated Objects" radio button.
    4>click on "create/change" push button.
    5>you get a pop asking you whether to create modules ,click on YES
    6>give "authorization group" as temp.
    7>give the function group name created by you.
    8>click on "find Scr numbers "push button on the application tool bar.
    9>in the pop up that you get select the 1st option and press enter
    10>click on the create push button (it is beside "Find Scr numbers" push button)
    11>selct local object and pres enter.
    12>go to SM30 transaction.
    13>give the table/view name
    14>click on "maitain" push button.

Maybe you are looking for

  • Open Page in new window from button

    I have a button that need to open up a page in new window when clicked. The page it needs to open is dynamic and stored in an item called 'P0_STUDENT_RECORD_LIST'. I added this to item pre-element text: <button onclick="javascript:PopupSTUDENT()"> Ho

  • I am having trouble in the app store after upgrading to iPhone 5 and iOS 6

    I am having trouble since upgrading from iPhone 4s to iPhone 5.  The "restore" feature never completed after activation of the new phone (it was close, only "find my iphone" app did not complete - it looked like it is forever trying to download).  Bu

  • Trojan:DOS/Alureon.E is killing me! Help Please!

    Hello, here is my info: HP Pavilion dv6985se Windows Vista 64 TrojanOS\Alureon.E is found by MSE and it can't be cleaned No changes were made before the virus/trojan appeared. I've been dealing with this for almost two weeks and can't seem to get it

  • REG : Date insertion in RFC

    HI All, I am facing problem in inserting the date into RFC from webdynpro java. Actually BAPI can accept teh date only in sql format and i have taken it as sql only and i am sending it direct as 2009-08-31 ,but its not going into backend. When i trie

  • Saving 2nd versions in Aperture 3

    Hi All; I am just getting into editing some photos and want to colour highlight a specific point on a black and white picture. (ie a Ruby stone on a buckle) That, I have figured out (Intensify Contrast Overlay - Colour Overlay) however cannot figure