How to write Inline queries in Oracle 10g

Hi all,
The following Procedure is written in SQL Server 2005 . It uses Inline queries and executes it in the end . I want to write the same stored procedure in Oracle 10g.
Could you guys please help me in doing the same .
CREATE PROCEDURE [dbo].[proc_MDM_ShowDetails]
@MASTERCODE VARCHAR(50),
@MDMCode VARCHAR(50),
@IsDrpDwnFill BIT,
@CntryCode INT,
@StateCode INT,
@CityCode INT = 0,
@GetParent INT = 0,
@PinCode BIT = 0
AS
BEGIN
DECLARE @strSQL VARCHAR(4000)
DECLARE @TableName VARCHAR(4000)
SET NOCOUNT ON;
SELECT @TableName = MASTER_TABLE FROM MDM_MASTER WHERE MASTER_CODE=@MASTERCODE
IF @IsDrpDwnFill = 0 AND @CntryCode = 0 AND @GetParent = 0
BEGIN
SET @strSQL = 'SELECT M.*,H.* FROM ' + @TableName + ' M LEFT JOIN MDM_HIERARCHY H ON M.MDM_MASTER_CODE=H.MASTER_CODE WHERE M.MDM_CODE=' + @MDMCode
END
ELSE IF @CntryCode = 0 AND @IsDrpDwnFill = 1
BEGIN
SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' + ' AND MDM_EXIST=1'
END
ELSE IF @CntryCode > 0 and @GetParent = 0
BEGIN
SET @strSQL = 'SELECT M.MDM_DESCRIPTION,M.MDM_CODE,H.* FROM ' + @TableName + ' M INNER JOIN MDM_HIERARCHY H ON M.MDM_MASTER_CODE=H.MASTER_CODE WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
' AND MDM_EXIST = 1 AND MDM_PARENT_CODE =' + str(@CntryCode)
END
ELSE IF @StateCode > 0 and @GetParent = 0
BEGIN
SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
' AND MDM_EXIST = 1 AND MDM_PARENT_CODE =' + str(@StateCode)
END
ELSE IF @CityCode > 0 and @GetParent = 0
BEGIN
SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
' AND MDM_EXIST = 1 AND MDM_PARENT_CODE =' + str(@CityCode)
END
ELSE IF @PinCode = 1 and @GetParent = 0 and @IsDrpDwnFill = 1
BEGIN
SET @strSQL = 'SELECT MDM_DESCRIPTION,MDM_CODE FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
' AND MDM_EXIST = 1 '
END
ELSE IF @GetParent > 0
BEGIN
SET @strSQL = 'SELECT * FROM ' + @TableName + ' WHERE MDM_STATUS=' + '''' + 'approved' + '''' +
' AND MDM_EXIST = 1 AND MDM_CODE =' + str(@GetParent)
END
EXEC(@strSQL)
SET NOCOUNT OFF;
END
Thanks
Shobhit

Hi,
I dont know sql server 2005. But by observing it I feel you are generating sql dynamically based on condition inside the proc.
DECLARE
   TYPE EmpCurTyp IS REF CURSOR;
   emp_cv   EmpCurTyp;
   emp_rec  employees%ROWTYPE;
   sql_stmt VARCHAR2(200);
   v_job   VARCHAR2(10) := 'ST_CLERK';
BEGIN
   sql_stmt := 'SELECT * FROM employees WHERE job_id = :j';
   OPEN emp_cv FOR sql_stmt USING v_job;
   LOOP
     FETCH emp_cv INTO emp_rec;
     EXIT WHEN emp_cv%NOTFOUND;
     DBMS_OUTPUT.PUT_LINE('Name: ' || emp_rec.last_name || ' Job Id: ' ||
                           emp_rec.job_id);
   END LOOP;
   CLOSE emp_cv;
END;something like this it will be. it is in oracle documentaion
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/dynamic.htm#i14500

Similar Messages

  • How to run a report from oracle 10g form in .csv format

    dear all,
    how to run a report from oracle 10g form in .csv format? i've already run in pdf & excel format.
    i'm using
    SET_REPORT_OBJECT_PROPERTY (ro_report_id, report_desformat, 'PDF'); --for pdf
    SET_REPORT_OBJECT_PROPERTY (ro_report_id, report_desformat, 'SPREADSHEET'); ---for excel
    Please Help..

    i have already tried.
    but the report show in htm or html format. that file will not save into csv. please help.

  • How to write join queries in Smartforms

    how to write join queries in Smartforms pls give me sample

    just as u write it in normal reports u can do the same in smartforms but it is suggested tht i u havve a custom print program do it thr and pass it thru interface
    кu03B1ятu03B9к

  • How to install Procedural Option in Oracle 10g Database express edition

    When i try execute exec send_mail shows error ORA-00900: invalid SQL statement.
    Error code shows "This error can occur if the Procedural Option is not installed "
    How to install Procedural Option in Oracle 10g express edition
    I'm using Oracle 10g Database express edition. Let me know how to run a procedure.

    I'm not sure of the meaning of ORA-00900 for Oracle XE but I think that PL/SQL is already installed by default according to the XE features list.
    See the Oracle® Database Express Edition 2 Day Developer Guide about procedure call.

  • How to find encrypted columns in oracle 10g database

    Hi,
    How to find encrypted columns in oracle 10g database? We can see using view dba_encrypted_columns or all_encrypted_columns .
    my question is apart from this is there anyother views or tables?
    Thanks..

    user602872 wrote:
    Hi,
    How to find encrypted columns in oracle 10g database? We can see using view dba_encrypted_columns or all_encrypted_columns .
    my question is apart from this is there anyother views or tables?Hmm not which I could find,
    SQL> select * from dict where lower(table_name) like '%encrypted%';
    TABLE_NAME
    COMMENTS
    DBA_ENCRYPTED_COLUMNS
    Encryption information on columns in the database
    ALL_ENCRYPTED_COLUMNS
    Encryption information on all accessible columns
    USER_ENCRYPTED_COLUMNS
    Encryption information on columns of tables owned by the user
    SQL>HTH
    Aman....

  • How can I change SGA_TARGET IN Oracle 10G.

    Dear Experts,
    Please tell me
    How can I change SGA_MAX_SIZE IN Oracle 10G.
    How can I change SGA_TARGET IN Oracle 10G.
    How Can i recreate SPFILE IN Oracle 10G.

    Dear Experts,
    Please tell me
    How can I change SGA_MAX_SIZE IN Oracle 10G.
    How can I change SGA_TARGET IN Oracle 10G.
    How Can i recreate SPFILE IN Oracle 10G.SGA_MAX_SIZE and SGA_TARGET are all to be changed by alter system statement.
    The difference is, you can't make change to SGA_MAX_SIZE effective while instance is running. Need restart database to make change effective.
    Your can change SGA_TARGET while instance is running, as long as it's smaller than SGA_MAX_SIZE
    to recreate a spfile,
    you can shutdown your database,
    find a copy of valid pfile,
    startup pfile=/directory/yourpfile
    and
    create spfile from pfile;

  • How to create new database on Oracle 10g

    Hi All,
    Can any one tell me how to create new database on oracle 10g.
    Thanks in Advance for your help.

    again some confusion here.....
    u said u need a new database in your first post and now you saying u need a new schema..
    one database has many schemas(users)..... ex: scott,sys,system are few of them...
    now it depends you need seperate database for test,dev environment - this is in the case u have many schemas under each database and many tables(objects) under each schema.
    OR
    You just need a separate schema (in same db) for test,dev environment...where in you will have multiple tables in each schema...U need to know the dba credentials of the db to create a new schema.
    ideally u need to have different database...You can create one with out sys/system(oracle users) password as these passwords are db dependent.
    what you need is access to the any machine where server is installed(can be the same mc where you have your dev db or a diff machine) and that will be the machine where your db will be installed (can do it through database configuration assistance),ofcourse you will need windows authentication for this.
    so you login to the same machine or access it from your machine using remote login.
    I hope that is clear.Hope i am not listing things that you already know..Just did it coz of confusion between db and schema
    Message was edited by:
    coolguy

  • How can I change SGA_MAX_SIZE IN oRACLE 10G.

    Dear Experts,
    Please tell me
    How can I change SGA_MAX_SIZE IN Oracle 10G.
    How can I change SGA_TARGET IN Oracle 10G.
    How Can i recreate SPFILE.

    another copy of dup How can I change SGA_TARGET IN Oracle 10G.

  • How to chage java version in Oracle 10g

    Hi all,
    I've installed on my server the Oracle 10g that includes the JRE 1.4.2_10. So, I have another JRE installed on my server and I would like to set the Oracle to use this one. How can I do this?
    Any Help will be appreciated,
    Alcides Flach

    Are you trying to write Java stored procedures that run inside Oracle's JVM? Or are you trying to write Java code that is executed on a middle tier application server that happens to connect to an Oracle database?
    Justin

  • How to trace an application in Oracle 10g

    Hi,
    I want to trace a complete application in Oracle 10g end-to-end.
    Here is the scenario,
    The are two systems:
    System A: Oracle 10g server
    System B: Windows server
    The application runs on system B.
    How do I trace the complete application in oracle 10g?
    I read about the trcsess tool but will like to know if there is a way to collate all *.trc produced by the application.
    Thanks in advance!
    -Thanks
    Karthik

    Tracing the Oracle transactions is easy, but you need to decide what level of trace you want and identify the database sessions to trace.
    Tracing can generate huge amounts of logs, so think carefully if you really need to do this.
    The tracing will only capture the database transactions. It won't track what happens in the application (e.g mouse clicks etc)
    Options to enable tracing :-
    -- ALTER SESSION
    alter session set tracefile_identifier = 'robert_trace'; # so that the trace files from this session are easily identified
    alter session set events '10046 trace name context forever, level 8';
    -- ALTER SYSTEM
    alter system set sql_trace=true;
    -- DBMS_SESSION
    exec dbms_session.set_sql_trace(sql_trace => TRUE);
    -- DBMS_SUPPORT
    exec dbms_support.start_trace(waits=>TRUE, binds=>FALSE);
    -- DBMS_SYSTEM
    exec sys.dbms_system.set_ev(72,21237,10046,12,'');
    -- ORADEBUG
    select username, spid from v$process;
    ORADEBUG SETOSPID 21237
    ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
    -- DBMS_MONITOR
    exec dbms_monitor.session_trace_enable(session_id=>75, serial_num=>21237);

  • Running Multiple queries in Oracle 10g Express Edition! Help Me!

    I am new to Oracle 10g Express Edition.
    I used my browser to navigated to http://127.0.0.1:8080/apex
    I saw the database page.. logged in.. went into the SQL section.. now am not able to run two or more queries at the same time.. i have given a screenshot too. Plz.. check it and reply me quickly..
    http://i71.photobucket.com/albums/i149/prasanna7287/546895215.jpg
    Help me plz..
    Prasanna.

    There are two possibilities:
    1) Run the SQL commands, one command at a time;
    2) Create a script of multiple commands, and run the script.
    These are discussed in some detail in the online documentation at http://www.oracle.com/pls/xe102/homepage
    In particular, look at
    http://download-east.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25108/xedev_sql.htm#BJEIEIFJ
    Message was edited by:
    Hans Forbrich
    No ... wait ... please do not read the documentation! <g>

  • How to archive and Purge in Oracle 10g based on data

    Hi,
    Our requirement is that based on some rules stored in static tables we want to perform Archiving, purging and compression of data in Oracle 10g.
    Can anyone guide me to proper information material for how to go about this?
    Thanks!
    Avinash.

    Hi,
    Thanks for the information.
    But this traditional way of doing is archiving is for maintenance and backup operations.
    We want to have this process online, without taking db offline. In this case will this approach work?
    In our case, the rules can be like -
    1. For table 'A', if rows exceed 10Million, then start archiving of the data for that table.
    2. For table 'B', if data is older than 6 motnhs start archiving of the data for that table.
    3. Archiving should be on for 15 minutes only after that should pause, and should resume whenever user wants to resume.
    4. Archiving should start on specified days only... ETC...

  • How to Switch between Databases in ORACLE 10g?

    Hi friends, im using ORACLE 10g.
    I have two databases namely ORCL and ORCL1.
    First I created ORCL and later ORCL1.
    Now I am able to see the tables from ORCL1 only.
    How can I switch to ORCL?
    Thanks in advance.

    Hi Aman, I am posting the results below.
    From the command prompt:
    C:\>SET ORACLE_SID=ORCL
    C:\>SQLPLUS
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Feb 19 18:12:24 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Enter user-name: scott
    Enter password:
    Connected to:
    Oracle Database 10g Release 10.2.0.1.0 - Production
    SQL> SELECT * FROM TAB;
    TNAME TABTYPE CLUSTERID
    DEPT TABLE
    EMP TABLE
    BONUS TABLE
    SALGRADE TABLE
    SB4782 TABLE
    EDNLN270042 TABLE
    CASE_DETAILS TABLE
    7 rows selected.
    SQL>
    And from the SQL*Plus Editor:
    SQL> SET ORACLE_SID=ORCL;
    SP2-0735: unknown SET option beginning "ORACLE_SID..."
    SQL> SELECT * FROM TAB;
    TNAME TABTYPE CLUSTERID
    DEPT TABLE
    EMP TABLE
    BONUS TABLE
    SALGRADE TABLE
    SQL>
    So, I am able to get the tables through the command prompt.
    But from the SQL*Plus Editor, I am not getting them.
    How to get those tables(from ORCL) through the SQL*Plus editor?
    Is there any other alternative for setting the ORACLE_SID permanently?
    Thank you.

  • How to verify stored procedures in Oracle 10g.

    I would like to locate default stored procedure in Oracle 10g database.
    And Suggest which stored procedure can be converted in to JAVA code ??

    If the Java part of the question refers to looking for potential to speed up your stored procedures:
    You should consider native compilation which transfers your code to shared libraries which are bound to the DB kernel.
    In this case however consider, that this does not make any sense/improvement for pure data access statements but only for procedures consisting of complex algorithmic processing.
    For details refer to
    [How native compilation works|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2280]
    and
    [Setting Up and Testing PL/SQL Native Compilation|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2309]

  • How to create ODBC connection between Oracle 10g and MS SQL Server

    Hi,
    Can someone help us with the steps to create an ODBC connection between Oracle APPS using Oracle 10g database and MS SQL Server.
    Requirement is to extract the transactional data from MS SQL Server on a daily basis and dump it into Oracle tables for an interface to be run. Currently it is being done through Dataloader tool which we feel is causing the data issue with Arabic characters. We want to create the ODBC directly between Oracle and MS SQL Server and check if the data is being pulled correctly.
    The data is in sql server 2000 which has data in Arabic_CI_AS character set which is moved to Oracle 10.2.0.3 database with characterset AL32UTF8. The table data is moved to oracle using the dataloader 3.6 standard edition licensed version. We cannot change the character set of Sql Server 2000.
    Please help
    Thanks
    Shanil

    Hi,
    If you're trying to PULL data from SQLServer into an Oracle database, you wouldnt use Oracle ODBC driver for that, so you may want to post in the Heterogeneous Services forum instead:
    Heterogeneous Connectivity
    If you're trying to PUSH data from SQLServer into an Oracle database, you could use ODBC but most folks use OLEDB for that, and the following note on MOS should help:
    How to Create a Sql Server Linked Server With The Oracle Provider for OLE DB     (Doc ID 191368.1)
    As with any NLS related issue, the first thing to do is dump the codepoints of the data in the Oracle database to see if it is stored validly, rather than relying on what the data "looks like" from some tool or other. It's best to check a single row, with only a few characters in it if you can, and you can do that via
    SELECT DUMP(<columname>,1016) FROM <tablename> WHERE ...
    Hope it helps,
    Greg

Maybe you are looking for

  • JCP4XDOBurstingEngine.java  BURSTING - UNABLE TO USE SPECIFIC FILENAME MORE

    Hello I am getting Bursting Issue duplicate entry: /XXXXXX.pdf issue in Oracle XML Publisher, I think I have same issue what is explain in ML#1109893.1 and I am thinking to apply the Patch. I NEED to Know the File location and version of JCP4XDOBurst

  • How to include chat Messaging in Apex

    Hi, does anyone have an idea as to how to use Message Chats in apex, using it for a peer to peer chat application i'm building. Thanks.

  • BAPI to create a position?

    Hi Guys,     Is there any BAPI/FM to create a position, relationships, vacancy and account assignment feature. And it should return the newly created position number. Thanks Edited by: Vin143 on Feb 10, 2010 8:52 PM

  • Hierarchy Restrictions as Per Query

    Hi , We have one query that is using GL Account InfoObject. We are displaying GL account as Hierarchy in Bex Output. There are 5 hierarchies in BW for GL Account Info Object. I created one Variable to select hierarchy while running the query. When us

  • Error Message ipod Service Module has encountered a problem

    I have just upgraded to iTunes 10, for some reason I receive two error messages, see below: '*ipodServiceModule (32-Bit)has encountered a problem and needs to close, we are sorry for the inconvenience.* If I then plug my iPod in iTunes firstly it doe