Need to wite pl sql procedure for dynamic select statement

Need pl sql procedure for a Dynamic select statement which will drop tables older than 45 days
select 'Drop table'||' ' ||STG_TBL_NAME||'_DTL_STG;' from IG_SESSION_LOG where substr(DTTM_STAMP, 1, 9) < current_date - 45 and INTF_STATUS=0 order by DTTM_STAMP desc;

I used this to subtract any data older than 2 years, adjustments can be made so that it fits for forty five days, you can see how I changed it from the originaln dd-mon-yyyy to a "monyy", this way it doesn't become confused with the Static data in the in Oracle, and call back to the previous year when unnecessary:
TO_NUMBER(TO_CHAR(A.MV_DATE,'YYMM')) >= TO_NUMBER(TO_CHAR(SYSDATE - 365, 'YYMM'))

Similar Messages

  • Cursor - Suggestions for Dynamic select statements

    Hey,
    Am trying to define a cursor like this -
    cursor c1 is
    select table_name from dba_tables INTERSECT select table_name from dba_tables@SOME_DBLINKMy need is to pass this dblink as IN parameter to the procedure and use it in the select statement for cursor. How can I do this?
    Any suggestion is highly appreciated. Thanks!

    Well that was meant to be my point. If you had two, you wouldn't (I hope) call the second one "c2" - you would be forced to think about what it represented, and name it "c_order_history" or something. Sticking "1" on the end does not make an extensible naming convention for cursors any more than it does for variables, procedures, tables or anything else, and so the "1" in "c1" is redundant because there will never be a c2.

  • Inner Join for Dynamic Select statement

    Hi All,
      Can some one please help me in rewriting the below select statement where i have to remove the existing table1 by putting a dynamic table name which has the same table structure.
      select a~zfield1
               a~zfield2
          from ztab1 as a
           inner join ztab2 as b
               on b~ztab1-zfield3 = a~ztab2-zfield3
         where a~zfield4 = 'A'.
    I am looking something as below. But encountering an error when using the below statement
      select a~zfield1
               a~zfield2
          from (v_ztab1) as a
           inner join ztab2 as b
               on b~ztab1-zfield3 = a~ztab2-zfield3
         where a~zfield4 = 'A'.
      No Separate selects please. Please help me in rewriting the same select statement itself.
    Regards,
    PSK

    hi,
    What error you are getting ?
    Also INTO is missing from the statement.
    SELECT  pcarrid pconnid ffldate bbookid
      INTO  TABLE itab
      FROM  ( spfli AS p
                INNER JOIN sflight AS f ON pcarrid = fcarrid AND
                                           pconnid = fconnid    )
      WHERE p~cityfrom = 'FRANKFURT' AND
            p~cityto   = 'NEW YORK' .
    thanks

  • Using cron-job to call the PL/SQL procedure for every 5 min

    Hi All,
    i wrote one procedure. using cron-job to call this PL/SQL procedure for every 5 min. i don't have any idea about cron job & what is thescript file formate .where can i place that script file. what are the details we placed in that script

    Really appreciate you. I like this approach .
    please give me advice for the below thing
    job_action =>an i give my procedure name under this?
    BEGIN
    -- Job defined entirely by the CREATE JOB procedure.
    DBMS_SCHEDULER.create_job (
    job_name => 'Job_schedule_update',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN Schedule_update; END;',
    start_date => SYSTIMESTAMP,
    repeat_interval => 'FREQ=HOURLY;BYMINUTE=5',
    end_date => NULL,
    enabled => TRUE,
    comments => 'Job defined entirely by the CREATE JOB procedure.');
    END;

  • How to add Document group  in t code S_ALR_87012082 for dynamic selection.

    Hi Gurus,
    I Need to add  Document group  in t code S_ALR_87012082  for dynamic selection.
    Currently here two groups are showing , Vender and Comp Code. i need to add Document group  there. Kindly guide me in this.
    Thanks in advance.

    Hi
    Pls follow below report
    *S_ALR_87012103 - List of Vendor Line Items *
    In dynamic selections you can find Document number, there you can give the range
    Reg
    Vishnu

  • Submit syntax for dynamic selections for T-code FAGLL03

    Hi Experts,
    My z report contains following fields in selction screen.
    1 . G/ L account
    2. Comapny code
    3. posting date
    4. Profit Center
    5. layout
    In my z report i used following syntax for passing selection screen values to standard program and getting data.
    This is for T-code FAGLL03
    SUBMIT FAGL_ACCOUNT_ITEMS_GL
    WITH SD_SAKNR IN S_SAKNR
    WITH SD_BUKRS IN S_BUKRS
    WITH %%DYN001-LOW (Profit Center)
    EXPORTING LIST TO MEMORY
    AND RETURN.
    The above syntax is not working for dynamic selection field ( Profit Center), entire Profit center data is fetching from standard program. I want to fetch profit center data based on my z report selection values .
    Expect for profit center field , submit syntax is working.
    kindly provide submit syntax for my above requirement .
    Any suggestions from experts....
    Edited by: PLP REDDY on Nov 25, 2009 8:59 AM

    Indeed it won't work. Instead of passing parameters one by one use
    [SUIBMIT... WITH SELECTION-TABLE rspar|http://help.sap.com/abapdocu_70/en/ABAPSUBMIT_SELSCREEN_PARAMETERS.htm#!ABAP_ADDITION_3@3@]
    Here you add one line per parameter (field KIND = 'P' ) and multiple lines per select options (field KIND = 'S' ). For the latter you need also provide SIGN and OPTIONS, i.e SIGN = 'I' , OPTIONS = 'EQ'
    The lin I gave you will explain it more.
    Regards
    Marcin

  • FAGLL03 : Submit syntax for dynamic selections

    Hi Experts,
    My z report contains following fields in selction screen.
    1 . G/ L account
    2. Comapny code
    3. posting date
    4. document type
    5. layout
    In my z report i used following syntax for passing selection screen values to standard program and getting data.
    SUBMIT FAGL_ACCOUNT_ITEMS_GL
                      WITH SD_SAKNR   IN S_SAKNR
                      WITH SD_BUKRS   IN S_BUKRS
                      WITH X_OPSEL    EQ ' '
                      WITH X_CLSEL    EQ ' '
                      WITH X_AISEL    EQ 'X'
                      WITH SO_BUDAT   IN S_BUDAT
                      WITH PA_VARI    EQ P_VAR
                      EXPORTING LIST TO MEMORY
                     AND RETURN. 
    The above syntax is not working for dynamic selection field ( document type ), entire document types data is fetching from standard program. I want to fetch document type data based on my z report selection values for document type field.
    Expect for document type field , submit syntax is working.
    kindly provide submit syntax for my above requirement .
    Any suggestions from experts....
    thanks & regards,
    Hari priya
    Edited by: Hari  Priya on Aug 24, 2009 4:33 PM

    Hi,
    Try like this.
    call function 'RS_REFRESH_FROM_SELECTOPTIONS'
      exporting
        curr_report = 'FAGL_ACCOUNT_ITEMS_GL'
      tables
        selection_table = i_sel[].
    Fill your profit center values in i_sel
    Submit FAGL_ACCOUNT_ITEMS_GL with selection-table i_sel and return
    WITH FREE SELECTIONS TEXPR AND RETURN
    Regards,
    Shamma

  • Selection variable for dynamic selection in QE51n

    Hi All,
    I have a scenario were we have a repetitive Manufacturing and we create one insp. lot of origin 13 and keep creating insp. points for days, so my user wants the insp. points to be displayed only for the past 3 days based of the Date Insp. point identifier which is one of dynamic selection criteria under insp. points, I see with other transaction I can do selection variable on dates for dynamic selection fields but I cannot do that in QE51n, I can do the same in QE51 but not in QE51n, can some tell me if there is a OSS or other way to get this working.
    I appreciate your help.
    Thanks,

    Hi Srikant,
    I think you can meet the requirement in QE51N also.
    In the screen for QE51N :Result Recording Work list", Follow this Path,,,,,,,,,
    Edit--->Dynamic Selection.
    The system will pop-up new small window for "Dynamic selection for insp. lot and operation" here I there is one folder is available named "Inspection point " which is having the selection criteria "Inspection point",  double click on it and enter the desired values.
    Regards,
    Shyamal

  • Automize SQL TRACE for a selected session

    Hi,
    Should I automize the process of SQL Tracing for a particular session of our choice?
    Let’s say when there are several sessions, and we want to select the particular session for SQL TRACING, then the SQL tracing for that session enable via running a routine.
    I used AFTER LOGON trigger for enabling SQL trace, but using this approach enable SQL TRACING all the sessions.
    My Logon Trigger for enabling SQL Tracing:
    create or replace trigger LOGON_SQL_TRACE
    after logon on database
    begin
    execute immediate
    'alter session set sql_trace=true';
    end;
    I want to use a perfect routine that first get the sid, serial# or username etc. from V$session, V$process or else, and then enable the SQL TRACING for the selected session.
    Like SYS.DBMS.SYSTEM.SET_SQL_TRACE_IN_SESSION package is available for doing that or may be some others as well.
    But how should we use these packages or other SQL tracing commands in a routine, which we can use for, enable SQL Tracing implicitly.
    Any ideas will be great.
    Bill

    SYS.DBMS.SYSTEM.SET_SQL_TRACE_IN_SESSION is just fine.
    You can get the SID and SERIAL# from v$session; you just have to know the username, osmachine, the OS process, ...
    Fred

  • Use of a stored procedure in a select statement submitted to cx_oracle

    Hi,
    I am developping under python and I'm using the cx_oracle interface.
    I've written a stored procedure that I've tested directly under sqlplus session : it's ok. I've also tested this stored procedure from python by using callproc routine : its also ok.
    Now I need to use this procedure within a select statement that I submit to the execute statement of cx_oracle as :
    s = "select a.airport_name,gmlpos.ExpLatLong(a.point_name) from airport"
    self.db = oracledb('ops/opeope00@ACE2008B')
    dbmsg = self.db.execute(s)
    IF (dbmsg == "") :
    An error occurs :
    Message = request = select a.AIRPORT_NAME, gmlpos.ExpLatLong(a.point_name) from airport, errmsg = ORA-00904: "GMLPOS"."EXPLATLONG": invalid identifier
    Noting that the execution of any other select (without stored procedure) order from python works fine.
    Is anybody has a solution or workaround ?
    thanks a lot for your help

    The result gives what is expected :
    AIRP
    GMLPOS.EXPLATLONG(A.POINT_NAME)
    LFLL
    -45.71666666666667 -5.08333333333333
    As I said the stored procedure works fine.
    Thanks for your expertise
    PS : why change the login password until nobody says which machine or database is concerned ?

  • Autonumbers through dynamic SELECT statement

    Trying to get an autonumber from an order table. The order_id I need from the table is only uniquely identified by the customer_id and the date/time. I've been advised that you cannot get an autonumber back from access without going via a select statement.
    I've tried to do a dynamic select statement by getting the date (short i.e.DD/MM/YY) from the server using a JSP custom tag and then putting this value into a hidden form field on the previous web page.
    However, when I load the next page the data gets input into the order table okay but the web page displayed is blank i.e. it doesn't display the order_id or the form to input credit card details. There are no error messages
    Code below, any ideas?
    <%@ page language="java" contentType="text/html"
    import="ShoppingBasket,Product,java.util.*"
    errorPage="errorpage.jsp"%>
    <jsp:useBean id="basket" class="ShoppingBasket" scope="session"/>
    <html>
    <head>
    <title>Your Order Has Been Received</title>
    </head>
    <body>
    <%
    String customer_id = request.getParameter("customer_id");
    String total_value = request.getParameter("total_value");
    String order_date = request.getParameter("order_date");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:odbc:Novbase","","");
    java.sql.Statement Stmt = connection.createStatement();
    String query = ("INSERT INTO Orders (customer_id, total_value) VALUES ("+customer_id+", "+total_value+")");
    Stmt.executeUpdate(query);
    java.sql.Statement Stmt2 = connection.createStatement();
    java.sql.ResultSet RS = Stmt2.executeQuery("SELECT order_id FROM Orders WHERE customer_id = "+customer_id+" AND time_date LIKE '"+order_date+"%'" );
    while(RS.next())
    String order_id = RS.getString("order_id");
    %>
    your order id is <%=order_id %>. Please input your credit card details in the form below:
    <form name="form1" method="post" action="shop-postorder4.jsp">
    <table width="90%" border="0" cellspacing="1" cellpadding="5">
    <tr>
    <td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Credit
    Card Type</font></td>
    <td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <select name="card_type">
    <option value="AMERICAN EXPRESS">American Express</option>
    <option value="MASTER CARD">Master Card</option>
    <option value="SWITCH">Switch</option>
    <option value="VISA">Visa</option>
    </select>
    *</font></td>
    </tr>
    <tr>
    <td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Credit
    Card No.</font></td>
    <td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="card_number" size=18 maxlength="18">
    *</font></td>
    </tr>
    <tr>
    <td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Issue
    No. <font size="1"><br>
    (Switch card holders<br>
    only)</font></font></td>
    <td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="issue_no" size="2" maxlength="2">
    </font></td>
    </tr>
    <tr>
    <td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Valid
    From</font></td>
    <td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="valid_from" size="4" maxlength="4">
    e.g. 0502</font></td>
    </tr>
    <tr>
    <td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Validy
    To</font></td>
    <td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="valid_to" size="4" maxlength="4">
    * e.g. 0105</font></td>
    </tr>
    </table>
    <input type="submit" name="Submit" value="Submit">
    <input type="hidden" name="order_id" value="<%=order_id %>">
    </form>
    <a href=" <%= response.encodeURL(shop-products.jsp") %">">
    <img src="images\toshop.gif" border="0" alt="Return to the Shop"></a>
    <%
    RS.close();
    Stmt.close();
    Stmt2.close();
    connection.close();
    %>
    </body>
    </html>
    </a>

    String query = ("INSERT INTO Orders (customer_id, total_value) VALUES ("+customer_id+", "+total_value+")");
    the data gets input into the order table okay
    java.sql.ResultSet RS = Stmt2.executeQuery("SELECT order_id FROM Orders WHERE customer_id = "+customer_id+" AND time_date LIKE '"+order_date+"%'" );It is a field name as <B>time_date </B>in Orders table? And should you insert some value ?
    It seems your select return nothing.
    When your RS.next() is false, so you get blank. Add some HTNL code or just <HR> after while {} block so your would see it.

  • Dynamic SELECT statement causing CX_SY_DYNAMIC_OSQL_SEMANTICS error.

    Hello Gurus,
    We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
              SELECT (lt_select_flds)
                FROM (lf_tab_name)
                INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
                FOR ALL ENTRIES IN <lt_source_data>
                WHERE (lf_where).
    In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
    WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
    This code was working fine till yesterday when we encountered serious performance problems and the Basis team had to do some changes at the DB level [Oracle]. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS.
    Is setting changes at the Oracle level cause issues with how the data is being read at the DB. If yes, can you suggest what can we do to this code to get is working correctly [in case Basis can't revert back their changes]?
    Would appreciate any help we can get here.

    You don't understand - this error comes up when we run specific BEx queries.  It was working yesterday, but today it is not.  Our support package did not change from yesterday.  We did not apply any OSSnotes.
    We are however doing pre-prepare on our Prod system.
    The temporary table is used to store SIDs for use in the join.  the table exists in the dictionary, but not at an Oracle level.

  • CX_SY_DYNAMIC_OSQL_SEMANTICS error with dynamic SELECT statement

    Hello Gurus,
    We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
              SELECT (lt_select_flds)
                FROM (lf_tab_name)
                INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
                FOR ALL ENTRIES IN <lt_source_data>
                WHERE (lf_where).
    In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
    WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
    This code was working fine till we were in BW 3.5 and is causing issues after we moved to BW 7.31 recently. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS. THE ERROR TEXT SAYS 'Unable to interpret '<LT_SOURCE_data>-DOC_NUMBER'.
    Can you pleasesuggest what can we do to this code to get is working correctly ? What has changed in ABAP Objects that has been introduced from BI 7.0 that could be causing this issue?
    Would appreciate any help we can get here.
    Thanks
    Arvind

    Hi,
    Please try this.
    data: lv_where type string.
    concatenate 'vbeln' 'in' 'r_vbeln' into lv_where separated by space.
    select *from table into itab where (lv_where).
    Also please check this sample code.
    REPORT ZDYNAMIC_WHERE .
    TABLES: VBAK.
    DATA: CONDITION TYPE STRING.
    DATA: BEGIN OF ITAB OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    END OF ITAB.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
    INTO CONDITION SEPARATED BY SPACE.
    SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
    WHERE (CONDITION).
    LOOP AT ITAB.
    WRITE 'hello'.
    ENDLOOP.
    Regards,
    Ferry Lianto

  • Can we call a stored procedure in a select statement

    Hi All
    I want to call a stored procedure inside a select statement is this possible.
    Regards
    Sravz

    You can create a pipelined function which gathers the data from your stored procedure and then use that in a select statement or directly write your script in any function or pipelined function. ;)
    There is no way you can call any stored procedure in a SELECT statement directly - i guess.
    Regards.
    Satyaki De.

  • DYnamic select statement in JDBC adapter?

    Hi guys,
                 Is it possible so send dynamic select statement in jdbc adapter?
    XIer

    Aamir,
    The poster did not specify whether this was sender or receiver channel, but it would only make sense that a "dynamic query" must be on the receiver communication channel since if it was on the sender channel, the channel would have to intelligently determine how to do dynamic queries.
    Also, the poster asked if there was a way to "send a dynamic query" to the channel.  This seems to imply that the channel is receiving information from somewhere to determine the query, which could only mean it is a receiver channel.
    If you would like more information on the JDBC sender communication channel, please open a new thread.

Maybe you are looking for

  • Family sharing - how to see allowed but not yet downloaded apps?

    I am using family sharing with some of my relatives - and I have to ask for permission since I am still under 18 years old. Is there a way to display a list of all apps the family organiser approved - even if I haven't buyed them yet (I pressed - by

  • Changing Win 8.1 Pro Store App Installation Folder

    I have a Dell Venue 8 Pro tablet with Windows 8.1.  The c:\ is very limited capacity at only 24GB.  With the OS only on the c:\ I just have 8.6GB of free space.  So I have added a 64gb SSD to the machine and want to install all my apps on it and not

  • Fcp x dosent open

    What to do fcp x dosent open.  it sticks on restoring window layout page

  • PO wise Credit Debit Values

    Dear All I need to develop PO wise costing report. for that i need to divide charges (VAT, NBT,PAL....) as Cridit and Debit. These values picked from KONV table. From table how to identify credt and debit rgds pramod Moderator message : Spec dumping

  • Moving AQ$_WF_CONTROL_D as part of a re-org

    DB - 11.2.0.3 - s390/zlinux APP - 12.1.2 - SLES SP2 (Linux x86_64) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ As part of the reorg, there's a table I need to move that wont. (AQ$_WF_CONTROL_D) I've been following note: 418238.1 from metalink which says to shutdown