How to process sql statements stored in a table

I have a rule table that contain rule_type, rule_status and rule_condition. The rule condition is a sql statement. In a report I need to be able to expand this condtion based on the status selected. E.g When rule status is terminated the rule_condition is as below. When a user pick terminated status, I need to be able to go to the table and expand the sql statement. Another example is active status.
RULE_STATUS TERMINATED
SELECT leaseid
FROM leatatt
WHERE txtattid = 'LEAS END'
and value = 'TERMINATED'
RULE_STATUS ACTIVE
SELECT leaseid
FROM lease
WHERE redoc_class = 'MASTER'
AND TRUNC(SYSDATE) <=
NVL(TRUNC(enddate),TRUNC(SYSDATE)+1)
AND functional_status IN ('ACTIVE','OVERHOLD')
Any suggestion will be appreciated.

Please refer to
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:246014735810
I am sure you would be twist this to bring it in to your use.
<PRE>
the proper way to do this is to NOT use a PLSQL table type but to use a SQL Object Type
instead. It would look like this:
[email protected]> create or replace type myScalarType as object
2 ( x int,
3 y date,
4 z varchar2(25)
5 )
6 /
Type created.
[email protected]> create or replace type myTableType as table of myScalarType;
2 /
Type created.
[email protected]> create or replace
2 function demo_proc( p_start_row in number,
3 p_end_row in number )
4 return myTableType
5 as
6 l_data myTableType := myTableType();
7 l_cnt number default 0;
8 begin
9 for x in ( select * from emp order by sal desc )
10 loop
11 l_cnt := l_cnt + 1;
12 if ( l_cnt >= p_start_row )
13 then
14 l_data.extend;
15 l_data(l_data.count) :=
16 myScalarType( x.empno,
17 x.hiredate,
18 x.ename );
19 end if;
20 exit when l_cnt = p_end_row;
21 end loop;
22
23 return l_data;
24 end;
25 /
Function created.
[email protected]> select *
2 from the ( select cast( demo_proc(2,6) as mytableType )
3 from dual ) a
4 /
X Y Z
7788 09-DEC-82 SCOTT
7902 03-DEC-81 FORD
7566 02-APR-81 JONES
7698 01-MAY-81 BLAKE
7782 09-JUN-81 CLARK
[email protected]>
</PRE>

Similar Messages

  • How to find sql statement with Unix process pid

    Hi
    how to find sql statement with Unix process pid
    is there any view to find that.
    please if so let me know
    Thanks in advance

    this is how I am doing this:
    oracle 7352340 7459066 0 07:47:10 - 0:00 oracleJDERED (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    oracle 7459066 5386396 2 07:47:10 pts/1 0:01 sqlplus
    select sid,serial# from v$session where process='7459066';
    SID SERIAL#
    2178 6067
    select sql_text
    from
    v$sqlarea a,
    v$session b
    where a.hash_value = b.sql_hash_value
    and b.sid = 2178
    ;

  • How to process each records in the derived table which i created using cte table using sql server

    I want to process each row from the CTE table I created, how can I traverse from first row to second row and so on....
    how to process each records in the derived table which i created using  cte table using sql server

    Ideally you would be doing a set based processing rather than traversing row by row as thats more efficient. To answer it specific to your scenario we may need more info. Can you explain with some sample data your exact requirement?
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to Capture  sql statement

    we have 1 server oracle and many clients.
    when client sends sql statement to server.How to Capture sql statement to analysis berfore it sent to server and execution.
    Edited by: 955185 on Aug 27, 2012 4:22 AM

    955185 wrote:
    yes. how to do this?Check these link all of them talking about Already executed sql in database by Users , but i don't know if what you ask is possible since they already connect to database
    If you attending to analysis sql read the below links and start your analysis,
    Last executed sql
    http://www.databasejournal.com/features/oracle/article.php/3373701/Watching-SQL-Execute-on-Oracle---Part-I.htm
    http://stackoverflow.com/questions/55899/how-to-see-the-actual-oracle-sql-statement-that-is-being-executed

  • Batch executing SQL Statements stored in a file in SAP DB

    hi,
    I am using SAP DB as database in my j2ee application. As a part of the application purpose, i need to insert a large no. of records in to the database directly. I have created the SQL file which contains the insert statements for the records
    Now i need to execute this file sothat the insert statement which are inside the file get executed. I am using SQL Studio to access to the Database.
    I would like to know whether any options are available in SQL Studio to for executing a SQL File.
    Kindly help
    Best regards,
    Sudheesh...

    Hi,
    I believe that the solution to your problem lies in creating sql studio objects.Please refer to the link below.Select the link "sql dialog" on the page.
    The following options are available for sql dialog.
    The following options are available in the SQL dialog:
    ·        Creating and executing SQL statements
    ·        Setting parameters for SQL statements
    ·        Importing and exporting SQL statements
    Select the "Importing and exporting sql statements" link on this page to know more about it.This will tell you how to import sql statements from ascii files.
    Basically,what you need to do is From the context menu for the SQL dialog, choose Import File or Export File.
    The link I have provided,gives a lot of other information as well.
    http://help.sap.com/saphelp_nw04s/helpdata/en/ee/1c5bdfeba711d4aa2800a0c9430730/frameset.htm
    Hope this helps.
    Regards,
    Harish
    (Please award points for helpful answers)
    Message was edited by: HARISH SUBRAMANIAN

  • How to let sql server 2008 know the table created at front end in c#

    How to let sql server 2008 know the table created at front end in c#

    The best solution is to create table type and pass the DataTable as table-valued parameter. I have an article on my web site about this:
    http://www.sommarskog.se/arrays-in-sql-2008.html
    The full article is a bit of overkill for what you are doing right now, but just the few first pages should get you going.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to Display IMAGE BLOB stored in a table in a html region APEX

    Need to know how to display an image stored in a table in a HTML APEX Region.
    Please

    Hi
    Please explain what you mean by it doesn't work?
    Are there errors messages, at what point, how far did you get and exactly what did you do????
    Please provide more information.
    Thanks
    Ben

  • Execute the sql statement stored in table

    friends i m in complication that, how can i execute sql statement which is stored in database table.
    how can i fetch that particular statement from table and make it execute!!!
    Thanks in advance

    I think we should stop at this point and have a little think.
    My understanding is that your plan is to do the following
    -Execute a Dynamic SQL statement which is constructed from values in several columns in a table (Bad idea to begin with)
    -The result of the execution is then loaded into PL/SQL.....not sure how you are handling different column lists but I'll assume you are not having to convert every column value to a VARCHAR2
    -The values returned are then used in an INSERT statement
    So basically your goal here is to take some data from one table and insert it into another table by moving data from SQL to PL/SQL then back to SQL in an elaborate, dynamic way. This is a costly waste of resources and will not scale (this is before we get to the problem of having to read the SQL statement from a table in the first place)
    I would recommend looking the INSERT SELECT statement here: http://psoug.org/reference/insert.html
    This will get the job done in one go. If you really do need it to be dynamic (which you don't, trust me) then you can still store this statement in your "dynamic SQL" table and execute it using EXECUTE IMMEDIATE although I can say for sure that you're going to run into more problems down the line with this architecture, it won't scale very well, and you'll probably waste at least *1* day of your time every week trying to fix a bug caused by the removal of a table, change to a column name etc.......
    However if you believe that storing SQL in a table is the best solution to your problem then go ahead.....at least when you find out that it isn't you'll have learned a valuable lesson.

  • Sender JDBC adapter : Update SQL Statement : stored procedure

    Hi,
    Can we use a stored procedure in the sender jdbc adapter in 'Update SQL Statement'.
    The problem i am facing is like, we are selecting data from two tables in 'SQL statement for query' and then in 'Update SQL Statement' , we need to delete that data from these two tables.
    Please let me know if it is possible.
    Thanks,
    Rohit

    you can use a Stored procedure in the
    Query SQL Statement
    You have the following options:
    ·        Specify a valid SQL SELECT statement to select the data to be sent from the specified database.
    ·        Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
    The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs.
    so have your whole select and update as part of this single Stored procedure

  • How to find SQL Statement fired using SYS.AUD$ - Database Auditing

    Dear Friends
    I am having Oracle 9i Database and have configured it with database auditing option by setting the following parameter in init.ora file
    AUDIT_TRAIL = "DB"
    I want to audit SELECT, INSERT , UPDATE and DELETE operations on PRACTICE.EMP table for which I did :
    1) Logged in as SYS
    2) SQL> AUDIT SELECT, INSERT, UPDATE, DELETE
    ON PRACTICE.EMP
    BY ACCESS
    WHENEVER SUCCESSFUL;
    Audit Succedded
    Now how should I find out the SQL statement that does the insert, update or delete operation on the EMP table using SYS.AUD$ table
    Thanks

    Hi,
    It's contents can be viewed directly or via the following views:
    * DBA_AUDIT_EXISTS
    * DBA_AUDIT_OBJECT
    * DBA_AUDIT_SESSION
    * DBA_AUDIT_STATEMENT
    * DBA_AUDIT_TRAIL
    * DBA_OBJ_AUDIT_OPTS
    * DBA_PRIV_AUDIT_OPTS
    * DBA_STMT_AUDIT_OPTS
    The audit trail contains a lot of data, but the following are most likely to be of interest:
    * Username : Oracle Username.
    * Terminal : Machine that the user performed the action from.
    * Timestamp : When the action occured.
    * Object Owner : The owner of the object that was interacted with.
    * Object Name : The name of the object that was interacted with.
    * Action Name : The action that occured against the object. (INSERT, UPDATE, DELETE, SELECT, EXECUTE)
    So, take a look at action_name column from DBA_AUDIT_TRAIL view.
    Cheers
    Legatti

  • How to find SQL statement = Database Auditing

    Dear All
    I have configured Database Auditing on Oracle 9i Enterprise Edition Server
    parameter init.ora file:
    AUDIT_TRAIL = "DB"
    I want to audit INSERT,UPDATE, DELETE STATEMENT on PRACTICE.EMP table
    for which i did :
    1) Logged in as SYS
    SQL> AUDIT INSERT,UPDATE,DELETE
    ON PRACTICE.EMP
    BY ACCESS
    WHENEVER SUCCESSFUL
    Audit Succedded
    2) Now I have to check the SQL statement that did insert update or delete operation using SYS.AUD$
    3) There is SQLTEXT field , datatype is CLOB.
    How should I check the SQL Statements that were fired on PRACTICE.EMP table
    Kindly help

    SQL> show user
    USER is "SYS"
    SQL> alter system set audit_trail = db,extended scope=spfile;
    alter system set audit_trail = db,extended scope=spfile
    ERROR at line 1:
    ORA-32001: write to SPFILE requested but no SPFILE specified at startup
    I have init.ora but no spifle so should I create SPFILE based on INIT.ORA and then give the command ?
    As of now I am using V$SQL view to find all the commands executed on my database.
    I found one good book "Oracle Security" OREILY PUBLICATION in which Auditing Database is discussed in good details.
    Thank you so much for all your efforts

  • How to push sql statements eariler in kodojdo

    Hi,
    I am using Websphere Studio Application Developer ver 5.0.1 and Kodo
    2.5.2.
    Is there any way of pushing the sql statements eariler,
    i have a table which has some columns with UNIQUE attribute, in my process
    i try to catch if any errors during the insert (persist in jdo)
    but, it doesn't throw any exception during persist call, it allows the
    process to go to next step then finaly through the exception (during the
    commit)
    is there any option to push the sql statements earlier and get the
    exception rather than doing at the end.
    one option i can think to put into new transaction, but it won't suite for
    all my cases.
    Thanks
    karup.

    You can cast the PersistenceManager to
    com.solarmetric.kodo.runtime.PersistenceManagerImpl and call flush ().
    See our JavaDoc for more info.
    kailasam.k wrote:
    Hi,
    I am using Websphere Studio Application Developer ver 5.0.1 and Kodo
    2.5.2.
    Is there any way of pushing the sql statements eariler,
    i have a table which has some columns with UNIQUE attribute, in my process
    i try to catch if any errors during the insert (persist in jdo)
    but, it doesn't throw any exception during persist call, it allows the
    process to go to next step then finaly through the exception (during the
    commit)
    is there any option to push the sql statements earlier and get the
    exception rather than doing at the end.
    one option i can think to put into new transaction, but it won't suite for
    all my cases.
    Thanks
    karup.
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • How to convert SQL server stored procedures to Oracle 11g

    Hi Experts,
    In SQL server 30 stored procedures are there how to convert all the stored procedure
    from SQL server to Oracle 11g.
    Please help me,
    Thanks.

    ramya_162 wrote:
    In SQL server 30 stored procedures are there how to convert all the stored procedure
    from SQL server to Oracle 11g.
    The single most fundamental concept you need to understand (grok in its fullness) is:
    ORACLE IS NOT SQL-SERVER
    There is very little, to NOTHING, in common between T-SQL (a language extension to SQL) and PL/SQL (integration of SQL with the language Ada, part of ALGOL family of languages that includes Pascal and C++).
    So taking a T-SQL procedure and porting it as is to PL/SQL is plain stupid.
    Why?
    Oracle sucks at trying to be SQL-Server.
    So how do you migrate from SQL-Server to Oracle?
    By taking the REQUIREMENTS that the T-SQL procedures address, and addressing these requirements using Oracle SQL and PL/SQL.

  • How to call SQL statements in InDesign CS6?

    Hi,
         My plug-in needs to interact with the database, and update the database content, how should I do, can I call SQL statements in InDesign CS6?
         Thanku very much.

    The same way you'd call them from any C++ program. You don't mention which platform, and that probably makes a difference.
    I'm accessing an SQL database in InDesign CS6 on Windows. I'm using the ODBC interface to SQL database that Windows provides, via the nanodbc wrapper. So I'm linking to odbc32.lib and odbccp32.lib, and including the nanodbc.cpp and nanodbc.h files. (See http://lexicalunit.github.io/nanodbc/ )
    Paul.

  • How to retrieve SQL statement in the CR 2008

    I'm using Crystal Reports 2008 in MS Visual Studio 2008, how can i retrieve SQL statement from *.rpt file, i have tried this code, but it doesn't work:
    ReportDocument rdReport = new ReportDocument();
    rdReport.Load("Reports/EmployeeTest.rpt", OpenReportMethod.OpenReportByTempCopy);
    CrystalDecisions.ReportAppServer.Controllers.RowsetController rsController;
    CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rdClient = rdReport.ReportClientDocument; // on this line it throws an exception "The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."
    CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath rdGroupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
    string temp;
    string sql;
    rsController = rdClient.RowsetController;
    sql = rsController.GetSQLStatement(rdGroupPath, out temp);
    maybe i'm doing something wrong ?
    thanks

    Hello Ludek,
    when I try to get the report from the session I got an error like this (I am using State Server Session mode i.e out proc in my application)
    ReportClientDocument     'reportDocument.ReportClientDocument' threw an exception of type 'System.InvalidOperationException'     CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument {System.InvalidOperationException}
    +base     {"The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."}     System.SystemException {System.InvalidOperationException}
    StackTrace     "   at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportClientDocument()"     string
    so is it the problem of not opened with RAS. Does installation of RAS solves the problem, If so Is it a free-ware or needs to be purchased.
    Ashok

Maybe you are looking for

  • Checking an object in Arraylist against empty string

    Hi all, Im storing a collection of objects in Arraylist.Among them , one of the objects has an empty string.How can i check whether an object contains empty string.I tried to check using the follwing snippet: ArrayList idList=new ArrayList(); if((idL

  • URL Portlet PDF format, in new window?

    I have successfully installed the URL portlet and can render an Oracle report within in HTML format. I want it to display in PDF format, but it doesn't work...it displays source code. Is there a way to do this? Also, the report display in place...how

  • In pse 9 when edited photo is saved it doesn't appear in organizer

    This happens even though the box entitled "include in organizer" has been checked.

  • Is it Better to downgrade to IOS 5.1.1?

    I want to know whether it is better to downgrade to IOS 5 so that many of the problems that caused due to upgrade can be solved by downgrade .

  • Cusctom tag with body

    I have written a custom tag with body. The intention is to process the body and replace any periods with line breaks (in HTML) before writing the BodyContent to the enclosing JspWriter. I find that replacing "." with ".<br>" does not take any effect.