View creation Procedure

Hi,
I hav created a procedure to create a daily view with 62 tables somthing like this
Create or replace Procedure View_Cre as
ex_command LONG:= null;
ex1_command LONG:= null;
ex2_command LONG:= null;
ex3_command LONG:= null;
begin
ex1_command :='CREATE VIEW VIEW_NAME AS '||chr(10)||'Select * from TAB_'||to_char(sysdate,'DD_MON_YY');
---dbms_output.put_line(ex1_command);
for idx in 1..61 loop
ex_command := ''||chr(10)||' union all'||chr(10)||' Select * from TAB_'||to_char(sysdate-idx,'DD_MON_YY');
--execute immediate ex_command;
--- dbms_output.put_line(ex_command);
ex2_command:=ex1_command||ex_command;
ex1_command:=' ';
ex3_command:= trim(ex2_command);
--dbms_output.put_line(ex2_command);
execute immediate ex3_command;
end loop;
end View_Cre;
However its not "*" there in select statement it contains large string like 30000 chars.
dbms_output gives me correct output but exec immediate gives invalide sql statement,
the output from dbms_output.put_line(ex2_command) creates view without errors when pasted on sql prompt.
Please help.
Thanks in advance.

May be like this ..
declare
  ex_command  LONG := null;
  ex1_command LONG := null;
  ex2_command LONG := null;
  ex3_command LONG := null;
begin
  ex1_command := 'CREATE FORCE VIEW VIEW_NAME AS ' || chr(10) ||
                 'Select * from TAB_' || to_char(sysdate, 'DD_MON_YY');
  ---dbms_output.put_line(ex1_command);
  for idx in 1 .. 61 loop
    ex_command := '' || chr(10) || ' union all' || chr(10) ||
                  ' Select * from TAB_' ||
                  to_char(sysdate - idx, 'DD_MON_YY');
    --execute immediate ex_command;
    --- dbms_output.put_line(ex_command);
    ex2_command := ex1_command || ex_command;
    ex1_command := ' ';
    ex3_command := ex3_command || trim(ex2_command);
    --dbms_output.put_line(ex2_command);
  --dbms_output.put_line(ex3_command);
  --dbms_output.put_line(ex3_command);
  end loop;
  --dbms_output.put_line(ex3_command);
  execute immediate ex3_command;
end;Although, I must say that it is not a good design. You may want to look at your requirement again and see whether it is really required to create a view with dynamic SQL.
Also, you may want to look at the short comings of using LONG in PL/SQL and supported data type in EXECUTE IMMEDIATE with length restriction.

Similar Messages

  • Reg View creation in Generic

    Hi SDN,
    Im trying to create Generic Data source of View Method. I wanted to create View on BSID ( Closed Customer Invoices) and BSAD ( Open Customer invoices) Tables, But while creating its giving error as "THERE IS NO RELATION BETWEEN THE TABLES"  I want to know how to create Relation Between the tables. Both BSID & BSAD are standard tables, so we cant make any changes.
    Please let me know the procedure to bulid Rlation between the tables.
    Regards
    Sujan

    Hi Siva,
        You have to give relation between these two tables in tab "Table/Join Conditions".
    Creating Views:
    http://help.sap.com/saphelp_webas620/helpdata/en/cf/21ecf9446011d189700000e8322d00/frameset.htm
    View creation fr generic extraction
    Hope it Helps

  • View creation very slow - not materialized view

    I have a view creation script which is running in a fraction of a second in the dev environment but takes over an hour to run in the test environment.
    The test environment is off-site, so I have no direct access to it. It does have a lot more data in than dev, but this is not a materialised view so as far as I understood it the amount of data in the system shouldn't affect the time to create the view.
    I haven't been able to find any information on what can make this happen. In the development environment I can be querying the view (or can lock it directly), and am still able to run the CREATE OR REPLACE statement without any performance impact. The view does contain function calls and is created with the FORCE keyword, but I can't find any evidence that this should affect the speed of creation.
    I am running Oracle 10g (10.2.0.4.0) on Solaris in both dev and test environments.
    Any ideas on what could be causing this are very welcome.
    CREATE OR REPLACE FORCE VIEW DB_OWNER.PER$AGE
    SYSTEM,
    LOCATION,
    EVENT_START,
    SURNAME,
    DOB_STRING,
    DESCRIPTION,
    GENDER,
    OLD_ID,
    URN,
    COMBINED_SCORE,
    LOAD_DATETIME,
    AGE,
    EVENTDATE_FROM,
    EVENTDATE_TO,
    DETAILS,
    AOB
    AS
    SELECT /*+ leading(ad) */
    p.system,
    p.location,
    p.event_start,
    p.surname,
    CAST (
    NVL (
    NVL2 (
    p.dob,
    TO_CHAR (p.dob, 'dd/mm/yyyy'),
    TO_CHAR (
    p.apparent_age
    + ROUND ( (SYSDATE - p.created_datetime_from) / 365, 0))),
    0) AS VARCHAR2 (10))
    AS dob_string,
    p.description,
    p.gender,
    p.old_id,
    p.urn,
    NVL2 (
    p.dob,
    db_owner.app_age_score (p.dob, ssearch.get_target_age),
    db_owner.age_score (p.apparent_age,
    p.created_datetime_from,
    ssearch.get_target_age))
    AS combined_score,
    p.load_datetime,
    psd.age,
    psd.eventdate_from,
    psd.eventdate_to,
    e.details,
    NVL (e.aob, 'N/A') aob
    FROM db_owner.person p,
    db_owner.psd psd,
    db_owner.entity e
    WHERE p.db_key = psd.db_key
    AND psd.age IS NOT NULL
    AND e.system(+) = p.system
    AND p.system IN (SELECT internal_name
    FROM ops$tomcat.feed_details
    WHERE inSearchList = 'true')
    AND e.urn(+) = p.urn;

    Hi,
    Thanks for the response.
    Trying the same thing without the FORCE keyword made no difference, the view still takes a long time to compile and there are no compilation errors.
    On the development system, I have run a long-running query on the view and checked V$Access. This returns a record for the view, but I can still successfully run the CREATE OR REPLACE statement on the view in another session. This appears to show that a record in V$Access doesn't mean that the view can't be recompiled.
    On the test system there are no other sessions connected and no records for the view in V$Access.
    Does anyone have any other ideas?

  • Set operator NE in Database View creation in  join condition

    Hi Experts,
         I have a requirement to set NE(not equal) operator in join condition of Database View creation. Could you please help me how to set in operator.
    Join condition :
    Ex : BSAK-AUGBL NE BSAK-BELNR.
    You know that by default operator is '='. i want to set NE in place of '='.
    Thanks,

    Hi Chinna,
    Check whether if there is any possibility or not to include more key fields like bukrs, lifnr, gjahr etc in the where condition, so that you query may result faster. Then, there won't be any necessary to create the view.
    Hope this helps.
    Please reward if useful.
    Thanks,
    Srinivasa

  • Automatic storage location view creation in maintenace order (IW31)

    Hello,
    Seems like I need some help.
    Have configured automatic storage location view creation for GR and reservation. Configured movement types are 101, 201, 261. While creating reservations (201, 261 mvmnt. types) with mb21 the sloc view is automatically created in material master, and everything seems fine.
    But in iw31 when I specify material number and sloc in a Components tab, I get an error message CO312: "The storage location data is not created". Automatic reservation is not created, and maintenance order can not be saved. Movement type 261 is used for automatic reservations for the maintenance order.
    If I configure message CO312 as a (W)arning  message, then it allows me to save the order and reservation, but sloc view in material master still is not created. Think that's not good and may lead to MRP issues.
    How can I configure automatic sloc view creation in iw31? Is that possible?
    Edited by: Konstantin Dudura on Nov 17, 2009 8:11 PM

    Hi,
    The customization required for Automatic Storage location creation at reservation are:
    Goto : SPRO -> MM -> inventory Management and physical inventory -> Goods issue/ Transfer posting -> Create storage location automatically
    first of all go to Plant and tick the automatic Storage location creation for the Plant. After that goto Movement type and tick the automatic Storage location for movement type 261.
    Regards

  • Personalized view creation in OA Framwork

    HI ,
    I am developing a search Trasaction in OAF using Query Region (AtuoCustomization Mode ). I developed the simple search and advanced search with dyamanic where caluse (I am setting the where clause and not using the where caluse genrate by Search Framwork ) . now i have to develope the personalized View page . i am using same method used in simple search and advance search for genrating where caluse dayanamiclly . but problem is that in personiazied view i am not able to invoke that method as i am not getting the how to handle the apply and apply & view result button in view panal . if anyone work on personalized View creation or know anything about creation of personalized view , please share your knowladge . its urgent , please help me
    regards,
    Vishal

    Looks like you are running a page which is part of a multipage transaction. Check the page function and make sure that page is not expecting any parameter, all the corresponding class files are present in the myclasses folder.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • View creation fr generic extraction

    Hai Experts,
    when we are create view from two different table ,wht is the crieteria that should  satisfy  between tables..... and at the time of datasource creation which type we need to select (master/trans)..as i found both master and transaction field in one table
    Can any one send the step by step process to create view..
    I have one more scenario ie .,i need to create a datasource from tables which belong to diff applications and their primary key is different ,can any one tell me how to create a datasource using function module,step by step process..
    thnks in advance,
    Regards,
    Suri

    hi,
    try these links for view creation...
    http://help.sap.com/saphelp_nw04/helpdata/en/f5/35c83ecedc636be10000000a114084/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9b/43473ccf20514ee10000000a114084/content.htm
    http://help.sap.com/saphelp_webas620/helpdata/en/cf/21ecf9446011d189700000e8322d00/frameset.htm
    http://www.sapdb.org/7.4/htmhelp/ee/1c5be2eba711d4aa2800a0c9430730/content.htm
    hope it helps...

  • How to restore views and procedures after drop user command?

    How to restore views and procedures after drop user command?
    We have 817 EE on NT and one developer created a lot of procedures, functions and vews. DB was not backuped and archived and export has not been done - our fault and we understand it. Sorry for this.
    Ok, now the story: another developer dropped this db user and we lost everything: procedures, functions and vews. The new user with trhe same name was created and new schema was imported in this user, but all old objects are lost. We don't have export and backup and archive log files.
    Question: may we can restore this lost stuff from some other sources. We are looking for lost codes, not data. May be we can use redo logs or shared pool or any other things. Any idea will be appreciated.
    Thanks.
    Victor
    [email protected]

    The switch has occurred after user was dropped, the data has been overwritten and there is be no way to use redo log files.
    I would like to explore another opportunity. Is possible to use Shared Pool or any Data Dictionary internal information to restore texts of the lost SQL and PL/SQL scripts executed in this DB before user was dropped? Not too many scripts are executed in this DB and the lost ones may still be in stack. I remember that Shared Pool (cash) should keep last executed scripts in order to improve performance. They probably are kept in some special format. Can we restore these scripts? Of course they also might be pushed out by Import that had been done after user was dropped.
    Thanks for your help,
    Victor

  • Tree View Creation error

    Hi,
    I have to create  tree view. I followed the stpes mentioned at the following link.
    Tree View
    I have created a Z-structure and created a table view in the component BT111H_OPPT component.
    While trying to modify the .htm page for the tree view, with the code mentioned at above link, I am getting following error.
    "node_tab is unknown. Not declared by a data statement."
    (see the line number 4 -  nodeTable = "<%= mytreenode->node_tab %>")
    I am using the following code.
    <chtmlb:tableExtension tableId = "Table"
                           layout  = "FIXED" >
      <chtmlb:configTree id                        = "configTree"
                         nodeTable                 = "<%= mytreenode->node_tab %>"
                         nodeTextColumn            = "NODE_TYPE"
                         onCollapseNode            = "nodeCollapse"
                         onExpandNode              = "nodeExpand"
                         onRowSelection            = "select"
                         onNodeClick               = "nodeClick"
                         ajaxDeltaHandling         = "FALSE"
                         headerText                = "Demo Tree"
                         allRowsEditable           = "TRUE"
                         selectionMode             = "SINGLESELECT"
                         table                     = "//mytreenode/Table"
                         tableLayout               = "AUTO"
                         visibleRowCount           = "12"
                         usage                     = "EDITLIST"
                         fillUpEmptyRows           = "FALSE"
                         personalizable            = "TRUE"
                         scrollable                = "TRUE"
                         noFrame                   = "X"
                         downloadToExcel           = "FALSE"
                         onClose                   = "closeTree"
                         onIncreaseSize            = "increaseTree"
                         nodeTextColumnDescription = "NODE" />
    </chtmlb:tableExtension>
    Please let me know where and how should I decalre it.
    Regards,
    Ansal

    Thanks Arun.. for the quick response...
    After view creation, I was directly following your second section of the thread....
    My issue is resolved....
    Hope to get further help for this object development.
    My requirement is add a new assignment block in opportunity screen which will show all the quotation,with their details, created for this opportunity and on click of each quotation id, all the items mapped to that particular quotation should be visible in same view.
    Thanks & regards,
    Ansal

  • Documentation on table, view and procedures of the user portal

    Where can I find documentation on table, view and procedures of the portal user?
    Thanks.

    PL/SQL API doc here :
    http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1014/summary.html
    VIEWS doc here :
    http://download-uk.oracle.com/docs/cd/B14099_19/portal.1014/b14135/pdg_cm_api.htm#CHDIFAGE

  • MAT View Creation Performance Issue

    Hello Experts,
    Below query is executing approximately in 1-3 sec.
    select
    COMMITMENT_ID,
    FUNDING_RULE_ID,
    reporting_year||'-'||reporting_period as RepPeriod,
    GET_START_DAY_OF_PERIOD (FUNDING_RULE_ID, reporting_year, reporting_period) START_DAY_OF_PERIODt,
    GET_END_DAY_OF_PERIOD(FUNDING_RULE_ID, reporting_year, reporting_period) END_DAY_OF_PERIOD
    from
      (select
      COMMITMENT_ID,
      FR_ID as FUNDING_RULE_ID,
      COMT_START_DATE,
      --COMT_TERMINATION_DATE,
      GETREPYEARFROMDATE(COMT_START_DATE,FR_ID) as reporting_year,
      GETREPORTINGPERIOD(to_char(COMT_START_DATE, 'mm') ,FR_ID) as  reporting_period
      from
        select
        COMMITMENT_ID,
        COMT_START_DATE,
        --COMT_TERMINATION_DATE,
        COALESCE(CB_FUNDING_RULE_ID,NC_FUNDING_RULE_ID) FR_ID
        from
        (COMMITMENT_TABLE left outer join (CHILD_BENEFICIARY_TABLE left outer join FUNDING_RULE_TABLE a on
        a.FUNDING_RULE_ID = CB_FUNDING_RULE_ID )
        on COMT_BENEFICIARY_REF = CB_BENEFICIARY_REF
        left outer join (NON_CHILD_BENEFICIARY_TABLE left outer join FUNDING_RULE_TABLE b on
        b.FUNDING_RULE_ID = NC_FUNDING_RULE_ID)
        on
         COMT_BENEFICIARY_REF = NC_BENEFICIARY_REF)
    The query is returning 4.5 lacks of rows.
    I want to create a MAT view by using above query and refresh this on daily basis.
    But the MAT view creation is taking more time near about 401sec (6.68min).
    Why the MAT view is taking more time?
    MAT_VIEW
    CREATE MATERIALIZED VIEW "REP_PERIOD_START_END_DATE"
    AS select
    COMMITMENT_ID,
    FUNDING_RULE_ID,
    reporting_year||'-'||reporting_period as RepPeriod,
    GET_START_DAY_OF_PERIOD (FUNDING_RULE_ID, reporting_year, reporting_period) START_DAY_OF_PERIODt,
    GET_END_DAY_OF_PERIOD(FUNDING_RULE_ID, reporting_year, reporting_period) END_DAY_OF_PERIOD
    from
      (select
      COMMITMENT_ID,
      FR_ID as FUNDING_RULE_ID,
      COMT_START_DATE,
      --COMT_TERMINATION_DATE,
      GETREPYEARFROMDATE(COMT_START_DATE,FR_ID) as reporting_year,
      GETREPORTINGPERIOD(to_char(COMT_START_DATE, 'mm') ,FR_ID) as  reporting_period
      from
        select
        COMMITMENT_ID,
        COMT_START_DATE,
        --COMT_TERMINATION_DATE,
        COALESCE(CB_FUNDING_RULE_ID,NC_FUNDING_RULE_ID) FR_ID
        from
        (COMMITMENT_TABLE left outer join (CHILD_BENEFICIARY_TABLE left outer join FUNDING_RULE_TABLE a on
        a.FUNDING_RULE_ID = CB_FUNDING_RULE_ID )
        on COMT_BENEFICIARY_REF = CB_BENEFICIARY_REF
        left outer join (NON_CHILD_BENEFICIARY_TABLE left outer join FUNDING_RULE_TABLE b on
        b.FUNDING_RULE_ID = NC_FUNDING_RULE_ID)
        on
         COMT_BENEFICIARY_REF = NC_BENEFICIARY_REF)
    Is there any way to make the MAT view creation within 3 minutes?

    CREATE MATERIALIZED VIEW "REP_PERIOD_START_END_DATE"
    AS
    with tab as
    select /*+ materialize */ commitment_id,
                           comt_start_date,
                           --COMT_TERMINATION_DATE,
                           coalesce (cb_funding_rule_id, nc_funding_rule_id)
                              fr_id
                      from (      commitment_table
                               left outer join
                                  (   child_beneficiary_table
                                   left outer join
                                      funding_rule_table a
                                   on a.funding_rule_id = cb_funding_rule_id)
                               on comt_beneficiary_ref = cb_beneficiary_ref
                            left outer join
                               (   non_child_beneficiary_table
                                left outer join
                                   funding_rule_table b
                                on b.funding_rule_id = nc_funding_rule_id)
                            on comt_beneficiary_ref = nc_beneficiary_ref)
    select commitment_id,
           funding_rule_id,
           reporting_year || '-' || reporting_period as repperiod,
           get_start_day_of_period (funding_rule_id,
                                    reporting_year,
                                    reporting_period)
              start_day_of_periodt,
           get_end_day_of_period (funding_rule_id,
                                  reporting_year,
                                  reporting_period)
              end_day_of_period
      from (select commitment_id,
                   fr_id as funding_rule_id,
                   comt_start_date,
                   --COMT_TERMINATION_DATE,
                   getrepyearfromdate (comt_start_date, fr_id) as reporting_year,
                   getreportingperiod (to_char (comt_start_date, 'mm'), fr_id)
                      as reporting_period
              from tab);

  • My friend has an apple iphone 4s, He could not make the ID on icloud, becase at the end of ID creation procedure, the message displayed, " the free icloud ID is not eligible for this device"  what is the solution, thanx

    My friend has an apple iphone 4s, He could not make the ID on icloud, becase at the end of ID creation procedure, the message displayed, " the free icloud ID is not eligible for this device"  what is the solution, thanx

    Your friend will have to create his iCloud account on a different iOS device.  His device has already created the maximum number of iCloud accounts and cannot create another one.

  • Output Parameters in Calc View or Procedure

    Hello,
    Is there any easier way to add output parameters into Calc Views or Procedures rather than doing it manually.
    Its taking me a real long time as I've around 70 to 100 parameters from each View or Proc. And I've quite a good number of models where the parameters are not common.
    Thanks,
    Varun

    Hi Varun,
    .procedure will create the procedure under content only.
    As per SAP we should go forward with .hdbprocedure but currently it seems like it has a bug because it creates under catalog as of now.
    Have a look on the below discussion for your reference.
    Problem in creating Repository procedure
    Regards,
    Krishna Tangudu

  • Why do I get a "ORA-01031: insufficient privileges" in my view creation?

    Why do I get a "ORA-01031: insufficient privileges" in my view creation for the table which exists in the same schema?
    Oracle version is 10g R2.
    connect cim/lion;
    create table cim.table1 (a number, b varchar2(10));
    create view cim.view1 as select * from cim.table1;
    create view cim.view1 as select * from cim.table1
    ERROR at line 1:
    ORA-01031: insufficient privileges

    Thanks it works now after giving CREATE VIEW permission to user CIM.
    This script was working fine in Oracle 10g R1.
    Looks like i need to execute the following GRANT permission explicitly
    grant create view to cim;

  • DBA views into procedure

    Hi,
    I have create a user with dba grant.
    I can select data from dba views, but when I select from dba views into procedure, I have an error message PLS-00201 sys.dba_tables must be declare.
    What is this ?
    Thank in advance for your help
    Nicolas.

    I found the answer. I need to give priviliges explicitly not through the role.
    Topic close.

Maybe you are looking for

  • How do I get my iPod nano to allow me to disconnect?

    I have a barely used iPod nano 2 2GB, which I use with Windows Xp and iTunes 7.1. It started fine but a few days on it refuses to allow me to unplug the USB cable from it, regardless of whether it's plugged into the Laptop or not. It plays the songs

  • Preview and greek letters

    I often get pdf's containing som greek letter-symbols (like sigma, tau, gamma etc). But in some pdfs, the symbols have vanished. They show fine in Acrobat, but not in Safari, Preview or Quick Look. I have a hunch that a common trait of the faulty pdf

  • WholeSales Scenario in IS Retail

    Hi, I am working on the Whole Sale scenario in IS Retail in which my client is selling the goods from the Store 'A',but the stock is physically maintained in Distribution Center 'B' as the store A is very small. That means it is only the virtual stoc

  • Outlook hangs when replying to a message from a specific email address.

    My users are a mix of Outlook 2007 and 2010 and we have an onsite Exchange 2010 SP3 environment. They can receive email and send new messages to the vendor's email address, but when anyone reply's to a message from that vendor, Outlook times-out. The

  • File path in title bar for CF files only?

    G'day When I have a CFM or CFC file open in the edit window, its full path - relative to the project - is displayed in the title bar of CFB.  With any other sort of file, just the file name is displayed. Now... I seem to recall switching on some "sho