How to execute PL/SQL query based on given input parameter

Hi all,
I have a pl/sql code which is in Region source. It extracts data from database. I want to execute the code based on input I give. I have to give date as a input parameter.
e.g.
If I give date1 as a parameter, then following code should executed
select col1, col2,..... from Table where date1 between '01-jan-2010' and '31-jan-2010'
If I give date2 as a parameter, then following code should executed
select col1, col2,..... from Table where date2 between '01-jan-2010' and '31-jan-2010'
Your help is very much appreciated.
Leo

Check the datatemplate,lexicals and beforeTrigger for this in documentation.
check this
Lexical reference issue in EBS

Similar Messages

  • How to execute an SQL query present in a string inside an ABAP program?

    hello,
    How to execute an SQL query present in a string inside an ABAP program

    Raut,
    You can execute Native SQl statements.
    Ex: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    EXEC SQL [PERFORMING <form>].
      <Native SQL statement>
    ENDEXEC.
    There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database.
    In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). You can use elementary structures as host variables. Exceptionally, structures in an INTO clause are treated as though all of their fields were listed individually.
    If the selection in a Native SQL SELECT statement is a table, you can pass it to ABAP line by line using the PERFORMING addition. The program calls a subroutine <form> for each line read. You can process the data further within the subroutine.
    As in Open SQL, after the ENDEXEC statement, SY-DBCNT contains the number of lines processed. In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement. Cursor operations form an exception: After FETCH, SY-SUBRC is 4 if no more records could be read. This also applies when you read a result set using EXEC SQL PERFORMING.
    EXEC SQL PERFORMING loop_output.
      SELECT connid, cityfrom, cityto
      INTO   :wa
      FROM   spfli
      WHERE  carrid = :c1
    ENDEXEC.
    Pls. Mark If useful

  • How to execute this SQL Query in ABAP Program.

    Hi,
    I have a string which is the SQL Query.
    How to execute this sql Query (SQL_STR) in ABAP Program.
    Code:-
    DATA: SQL_STR type string.
    SQL_STR = 'select * from spfli.'.
    Thanks in Advance,
    Vinay

    Hi Vinay
    Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
    REPORT dynamic_sql_example .
    DATA: BEGIN OF gt_itab OCCURS 1 ,
    line(80) TYPE c ,
    END OF gt_itab .
    DATA gt_restab TYPE .... .
    DATA gv_name(30) TYPE c .
    DATA gv_err(120) TYPE c .
    START-OF-SELECTION .
    gt_itab-line = 'REPORT generated_sql .' .
    APPEND gt_itab .
    gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
    APPEND gt_itab .
    gt_itab-line = SQL_STR .
    APPEND gt_itab .
    gt_itab-line = 'ENDFORM.' .
    APPEND gt_itab .
    GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
    PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
    IF FOUND .
    WRITE:/ gv_err .
    LOOP AT gt_result .
    WRITE:/ .... .
    ENDLOOP .
    *--Serdar

  • Executing SQL-query based on user input in text-box on APEX page

    Hi,
    I'm new to developing in APEX, and I encountered a problem...
    Is it even possible to make such thing: use text area for input of some SQL-query and then execute it on my schema and show results in report item? And if the answer is yes, can somebody provide me tips on how to do that?
    Thanks in advance.

    Denes Kubicek wrote:
    I think this example shows something similar:
    https://apex.oracle.com/pls/apex/f?p=31517:91
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    https://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------I see there is executing stored queries example, and text area showing executed one, but not quite understand how to sent sql-query directly from text input, based on your example :/

  • How to execute a sql query in VO????

    Hi every body.
    Can you show me the way to execute a sql query in VO.
    For example: I have a viewobject1, and I add a new method void execSQL() before the last '}' of the java file of viewobject1 like this:
    public void execSQL() {
    String strSql = "Select sysdate from dual";
    I want to execute strSql query and return a Resultset, how can I perform ???
    Thanks a lot.

    The executeQuery method in ViewObjectImpl does not return a ResultSet.
    ViewObjectImpl voImpl;
    voImpl.setQuery(strSql);
    voImpl.executeQuery();

  • How to execute a SQL  Query in Ms-Access

    Hi,
    I've a query which fetches the data from the tables based on daily transactions.
    I mean, the data gets updated daily basis.
    Now, i want to send the user a Ms-access work sheet with the query written, so that when ever the query is executed, it would fetch the records (with latest updates).
    I found some documents in google to, how to write sql query in ms-access.
    How ever, i'm unable to find the connection setup.
    how do i connect to oracle database using ms-access??
    Can any one please help me regarding this.
    Thanks,
    Santhosh

    You can try this tutorials
    http://www.reo.gov/gis/tools/infobase/LinkAccessToOracle.pdf
    Basically steps include,
    Install and configure Oracle client
    Configure ODBC DSN using correct TNS name configured in first step
    Link the table from Msaccess, make sure you linked the table not import it.

  • How can i dynamically select columns based on the input parameter?

    I have an input parameter which takes single numeric value.
    Based on this value i have to dynamically select table-columns .
    For eg: if i have following fields in my table :
    SEM_1
    SEM_2
    SEM_3 and SEM_4.
    And if i give numeric input as 2 , then i have to select "SEM_2" column only.
    if the input is 3 then i have to select "SEM_3" only and leave the rest of the columns.
    how do i achieve this dynamic feature in the "Select .....  From...... table...." statement in the ABAP??

    Hi,
    you should try something like this.
    TYPES: cond(72) TYPE c.
    data: condtab TYPE TABLE OF cond,
             condw type cond.
    data: lv_field(30) type c value 'SEM_'.
    write p_num to lv_field+4(1).
    condw = lv_field.
    append condw to condtab.
    SELECT (CONDTAB) FROM table INTO.....
    Kostas
    Message was edited by:
            Kostas Tsioubris

  • How to execute multiple sql query in one time?

    HI
    I'm trying to convert my sql project In Oracle. In sql i could run multiple select statement/query in once and they return in multiple table result respectively. but in oracle its not executed.
    like:
    sqlQry := "Select * from abc; select * from qwe; select * from kkk; select * from xyz"
    its return 4 table abc, qwe,kkk,xyz to my dataset result
    how it is possible in oracle 10g

    Saten Chamoli wrote:
    I'm trying to convert my sql project In Oracle. In sql i could run multiple select statement/query in once and they return in multiple table result respectively. but in oracle its not executed.
    like:
    sqlQry := "Select * from abc; select * from qwe; select * from kkk; select * from xyz"
    its return 4 table abc, qwe,kkk,xyz to my dataset result That is pretty much a hack - there are no ANSI SQL standards supporting this syntax. It makes no sense either.
    If you want to combine 4 data sets, there are the UNION and UNION ALL set commands.
    If you want to create 4 cursors with a single call, then use the following (anonymous PL/SQL block) call:
    begin
      open :c1 for select * from abc;
      open :c2 for select * from qwe;
      open :c3 for select * from kkk;
      open :c4 for select * from xyz;
    end;Bind 4 client cursor variables to the ref cursors c1 to c4 and make the call to Oracle.
    And I suggest that you read up on Oracle concepts and fundamentals as your approach with you "sql project" shows ignorance in this regard.

  • How to change a region title based upon the input parameter?

    Hi All,
    I need to change the region's title dynamically based on the value of a select list in another region.
    Can anyone help me in this?
    Regards,
    Sakthi.

    Hi,
    You can use &P1_ITEM_NAME. (including the & and the .) in a region title - this string will be replaced by the value from the page item called P1_ITEM_NAME, so change the name to suit your page item
    Andy

  • Dynamic structure creating based on the input parameter

    Hi all,
                 How to create a dynamic structure based on the input parameter given in the selection screen. I have a file path given and it contains three fields in common, but after that depending upon the input given the fields get changed. For example, i have 0002 infotype given in the selection screen, my file path structure should contain pernr begda endda and PS0002 structure, if the infotype is changed the PS structure has to be changed dynamcially.
    Thank you,
    Usha.

    Ans

  • Include Button that executes PL/SQL procedure to SQL query based region

    I would like to add two columns to a SQL query region.
    These columns would not be sourced from the query, but rather would be used to execute a PL/SQL procedure.
    For example, I would like to have a manager approve or deny adding an additional employee to the department.
    There would be one button for APPROVE. And, one button for DENY.
    The PL/SQL procedure would execute to perform the required DML based upon the selected action (either APPROVE or DENY).
    A sample output would look like this:
    <APPROVE>, <DENY>, John Doe, Accountant
    <APPROVE>, <DENY>, Jane Doe, Accountant
    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?
    Thanks!
    -Reid

    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?Conditional page item? You can associate processes with buttons on a page

  • How to execute an sql function containing a SELECT query as paramete

    Hi
    I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
    select dbms_xmlgen.getxml(select * from departments) from dual
    please some one help with appropriate java code to execute it.
    Thank you

    >
    I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
    select dbms_xmlgen.getxml(select * from departments) from dual
    please some one help with appropriate java code to execute it.
    >
    Java code? You can't execute that query at all since it is invalid. The parameter needs to be a query string NOT a query.
    select dbms_xmlgen.getxml('select * from departments') from dual See the DBMS_XMLGEN package in the docs
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_xmlgen.htm#i1013206
    >
    Converts the results from the SQL query string to XML format, and returns the XML as a temporary CLOB, which must be subsequently freed using the DBMS_LOB.FREETEMPORARY call:
    DBMS_XMLGEN.GETXML (
    sqlQuery IN VARCHAR2,
    dtdOrSchema IN number := NONE)
    RETURN CLOB;
    >
    Then you execute that query like any other query that returns a result set. The result set will consist of one row and one column of CLOB datatype.
    See the JDBC Developer's Guide - it has examples of how to execute queries that return result sets.
    And this section shows how tow read/write CLOBs
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/oralob.htm#sthref755

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • SQL Query based BI Pub report - Taking too long to produce the output

    Hi All,
    I was trying to produce a BI Publisher based report through enterprise edition of BI Publisher 10.1.3.4
    Its a sql query based report and it has around 20 columns and it has around 1 lakh records.
    The query actually takes only 2 seconds to execute in the database but when we execute from BI Publisher it takes a long time and also it times out most of the time
    Is there something I am missing in the configuration options ?
    Thanks
    Shasi

    I am facing the same problem as well. I am using the Publisher Web service API to run a report with 1 Million records. This report is configured to use OBIEE. It takes a lot of time to generate the report ( around 30 Mins) and even though OBIEE generates the data, my web service client either timesout. Even after increasing the timeout, a 500 internal server error is thrown . Does anyone know of a solution to this.
    Thanks

  • How Can I find SQL Query in Database

    Dear Experts,
    How Can I find SQL Query in Database.

    Hi,
    U mena what query got executed in db? u can try V$SQL for it.
    Regards
    Bharath

Maybe you are looking for