Writing a Stored Proc which will execute the Queries passed to it as args

Hi,
I need to write a Stored Proc which gets the Query to be executed as an Argument and return the results in an OUT Variable.
The Stored Proc i wrote is
CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
l_returnValue out clob )
is
l_output utl_file.file_type;
l_theCursor integer ;
l_columnValue clob;
l_status integer;
l_results      clob;
begin
l_theCursor := dbms_sql.open_cursor;
-- Parse the Query
dbms_sql.parse( l_theCursor, ':x', dbms_sql.native );
DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
-- Define the coulmnValue Variables
dbms_sql.define_column( l_theCursor, 1, l_columnValue);
-- Execute the Query
l_status := dbms_sql.execute(l_theCursor);
-- Get the Results and prepare the return Value.
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
dbms_sql.column_value( l_theCursor, 1, l_columnValue );
     DBMS_LOB.APPEND(l_returnValue, l_columnValue);
end loop;
-- Close the Cursor
dbms_sql.close_cursor(l_theCursor);
end SP_FETCH_RESULTS;
As the Queries paased to it always return CLOB Types i declared the OUT Variable as CLOB
And when i try to execute is using the below given PL/SQL Block
DECLARE
l_Query CLOB ;
l_retVal CLOB;
l_results CLOB;
BEGIN
l_Query:='SELECT extract(object_value,''/AC'').getStringVal() into l_results from CommonAssetCatalog';
SP_FETCH_RESULTS(l_Query,l_retVal);
dbms_output.put_line ('Results =');
END;
I am getting the Error.
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
ORA-06512: at line 7
Could you guys pls give me some inputs on how to resolve this..
Thanks a lot
Sateesh

Hi James,
I tried with out the Bind Variable and got the Same Error..
The Code which i tried earlier is
CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
l_returnValue out clob )
is
l_output utl_file.file_type;
l_theCursor integer ;
l_columnValue clob;
l_status integer;
l_results      clob;
begin
l_theCursor := dbms_sql.open_cursor;
-- Parse the Query
dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
--DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
-- Define the coulmnValue Variables
dbms_sql.define_column( l_theCursor, 1, l_columnValue);
-- Execute the Query
l_status := dbms_sql.execute(l_theCursor);
-- Get the Results and prepare the return Value.
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
dbms_sql.column_value( l_theCursor, 1, l_columnValue );
     DBMS_LOB.APPEND(l_returnValue, l_columnValue);
end loop;
-- Close the Cursor
dbms_sql.close_cursor(l_theCursor);
end SP_FETCH_RESULTS;
and the Procedure got Compiled Successfully and when i ran the PL/SQL Block which calls the Above Stored Proc i got the Error
DECLARE
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
ORA-06512: at line 7
Pls let me know how can i resolve this..
Thanks
Sateesh

Similar Messages

  • SOAP TO JDBC scenario: calling stored procedure which will return the value

    Hi
    I have Soap To Jdbc scenario in which I am going to call the Stored Procedure at target side which will be executed and it is going to return the result set .
    Result contains following values.
    return code as ( 0 Or 1) and also specific exception message if its return code as 1.
    Could you suggest me the way by which I can handled this return code and send it back to the Sap PI system then the same thing is directed the to SMTP server for sending mail to consern person.
    Regards
    Kumar

    The OUT parameters of stored procedure will be returned as response. Where exactly are you facing the proble? Here is a complete walkthourgh
    /people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
    In your case, you don't want response at sender. Instead you want to mail it. For this you may use BPM to design your scenario with following steps
    Receive (to receive data from sender)
    Send Sync (to stored procedure and get response)
    Send Async (to mail receiver)
    Regards,
    Prateek

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".

    Hello,
    I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".
    Suppose , 
    Parameter value : person 1,person2,person3 
    table structure : 
    Project Name | officers 1 | officers 2
    here, officers 1 or officers 2 may contain names of multiple people.
    expected OUTPUT : distinct list(rows) of projects where person 1 or person 2 or person 3 is either officer1 or officer 2. 
    please explain or provide solution in detail 
    - Thanks

    Hi Visakh,
    Thanks for reply.
    But the solution you provided giving me right output only if officer 1 or officer 2 contains single value , not with comma seperated value.
    Your solution is working fine for following scenario : 
    Project 
    Officers 1
    Officers 2
    p1
    of11
    off21
    p2
    of12
    off22
    with parameter : of11,off22 : it will give expected output
    And its not working in case of :
    Project 
    Officers 1
    Officers 2
    p1
    of11,of12
    off21,off23
    p2
    of12,of13
    off22,off24
    with parameter : of11,off22 : it will not give any row in output
    I need patten matching not exact match :) 
    ok
    if thats the case use this modified logic
    CREATE PROC GetProjectDetails
    @PersonList varchar(5000)
    AS
    SELECT p.*
    FROM ProjectTable p
    INNER JOIN dbo.ParseValues(@PersonList,',')f
    ON ',' + p.[officers 1] + ',' LIKE '%,' + f.val + ',%'
    OR ',' + p.[officers 2] + ',' LIKE '%,' + f.val + ',%'
    GO
    Keep in mind that what you've done is a wrong design approach
    You should not be storing multiples values like this as comma separated list in a single column. Learn about normalization . This is in violation of 1st Normal Form
    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

  • Iphone 4 has a black screen which will display the apple logo for approx 10 seconds, then goes blank for 10 seconds and so on.  I have tried a hard reset with power button and home button but no change.  Get no response when attempting to connect to itune

    iphone 4 has a black scrren which will display the apple logo and appears to be at start up but then blacks out for approx 10 seconds and then displays apple logo again.  Same action over and over.
    I have attempted hard reset but cannot complete.  Also attempted to connect with itunes and it does not recongize device.
    Device is frozen in this display loop.  Have an appointment with genius bar tomorrow but it's a 2.5 hour round trip so suggestion appreciated.

    Your device may need to be restored as new in iTunes (instead of restored from a back up as it seems that there is a software issue on your phone).
    If your phone is not able to connect in iTunes try forcing recovery mode (http://support.apple.com/kb/HT1808)
    * power off your phone.
    * Hold the home button while connecting your phone to iTunes.  You should see the connect to iTunes window and your computer should give you the recover mode alert.
    *Restore your device as new. Being sure not to restore from a previous back up.
    You will then want to sync your information back to your device from Outlook, iCloud, Google or wherever your information is stored.

  • How to create a user  y which will have the same content of existing user x

    how to create a user y which will have the same content of existing user x ,
    like all the tables,procedures,functions and packages

    You can do the following.
    1. Use CREATE USER to create the new account/schema
    2. Use exp to export old schema
    3 Use imp with fromuser=<old user> and touser=<newuser>

  • Export an XML or EDL which will keep the clip's full name

    Greetings,
    I've been working with R3d (RED EPIC format) footages in premiere cs6 and i need to export an XML or EDL which will keep the clip's full name, in order to use it for further post production (davinci).
    How do i do it?

    i know that edl is an old format but i wonder if there is another format like avid's cmx 640.
    I've already exported xml and it doesn't keep the clip's full name.
    I'm more interested in exporting xml.
    Is there a way to import the R3D so it keeps the clip's full name in the metadata?

  • I need to use the "apple key" which is, I presume the command key, but I do not have an apple keyboard; is there a key on a logitech keyboard which will serve the purpose?

    I need to use the "Apple key" which I presume is the command key; my computer does not have an apple keyboard; is there a key on a logitech keyboard which will serve the same purpose?

    The "Windows flag" key on PC keyaboard in Commans, "Alt" is option.
    Go to Logitech website to see if they have Mac compatibility software (Logictech Control Center) to make mappings a bit more complex).

  • I own CS4, upgraded to CS5, then joined CS6, CC... and now I installed CC14. Which will be the best way to delete or uninstall the programs I don't need keeping only CC14 without running into issues? I have an Alienware Area 51 PC running Windows 7.

    I own CS4, upgraded to CS5, then joined CS6, CC... and now I installed CC14. Which will be the best way to delete or uninstall the programs I don't need keeping only CC14 without running into issues? I have an Alienware Area 51 PC running Windows 7.

    Which will be the best way to delete or uninstall the programs I don't need keeping only CC14 without running into issues?
    There is none. Whatever you do to get rid of the older versions will inevitably do damage to shared components and other stuff of the new versions as well. That's just how it is with this approach... Uninstall the older versions, run the cleaner tool then reinstall CC 2014.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    Mylenium

  • I am after a Video Converter which will convert the likes of a avi format to then play on a Humax FOXSAT-HDR PVR, any ideas anyone please?

    I am after a Video Converterfrom the App Store which will convert the likes of a avi format to then play on a Humax FOXSAT-HDR PVR, any ideas anyone please?

    Without knowing the exact details of the AVI files in question, or the formats and codecs supported by the Humax, I can only suggest Handbrake.  Simple and powerful.  Produces excellent results.
    S.

  • Which will be the more demanding product for future? Coherence or Weblogic

    Which will be the more demanding product for future?
    Coherence or Weblogic Server?
    If Coherence , Why?
    If Weblogic Server, Why?
    How will be demand for Coherence after 5 or 6 years?

    This isn't a question that I've heard before ;-)
    Today, a very good portion of the WebLogic customers are also buying Coherence with WebLogic, often as part of the product called "WebLogic Suite". Also, many large WebLogic customers have been using Coherence since long before Oracle acquired either BEA WebLogic or Tangosol Coherence.
    When it comes to building high-scale Java EE applications, Oracle Coherence is an invaluable tool, so as long as there are Java and Java EE applications, and as long as high scalability, high availability and high performance are important, there is demand for Coherence, and that demand has grown year after year.
    WebLogic is a much larger and more mature product, with many more customers. WebLogic continues to grow at Oracle, even though it is considered a mature product.
    So I guess you could say there is good demand for both :)
    Peace,
    Cameron Purdy | Oracle Coherence
    http://coherence.oracle.com/

  • I want to buy the photoshop which will change the background on a portrait?

    I want to buy the photoshop which will change the background on a portrait?

    Hi willielois, you can use Photoshop CC or Photoshop Elements to do this. I have shared a video tutorial that can help you learn to do this.

  • Which will execute first

    Hai,
    I am having Where class and having class in a single select query.. Which will execute at first.

    user12283394 wrote:
    Hai,
    I am having Where class and having class in a single select query.. Which will execute at first.select deptno, min(SAL), max(SAL) FROM EMP WHERE job='CLERK' group by deptno having count(*) > 3;
    You should read basic sql query comment..
    Refer :-
    http://dbis.ucdavis.edu/courses/sqltutorial/tutorial.pdf
    Regards
    Azar
    DBA

  • Calling a Oracle Stored Procedure which will take a while to complete

    Hey.
    I'm calling a Oracle stored procedure which goes of and do a whole lot of things and therefore takes a fair while to complete.
    Currently I am doing this:
    String sql = "begin concorde.start_transfer(); end;";
    HibernateUtil.getSessionFactory().openStatelessSession().connection().prepareCall(sql).execute();
    ....Where HibernateUtil is just a mean to get to the SessionFactory. The connection I get is the same one as a JDBC, I think.
    I would want to regain control of the application as soon as the procedure is called and continue with the rest of the logic.
    How do I do that? Do I have to initiate it from a different thread?
    Thanks

    If it was me I wouldn't have a stored proc that took a while to complete. Instead I would submit a job to job queue. In terms of implementation I would call a proc that writes a record to a table. Then a process in the database polls that table and runs jobs it finds there. Then reports results somewhere.
    Sometime later you collect the results.
    But without that then the solution in java is obvious - create a thread.

  • Which will execute first in File Adapter (parameter,Identifier,module)

    Hi,
    I have written a module for my sender file adapter, and choose FCC to parase my complex structure...here my doubt is whether adapter module will call first or FCC which is there in Identifier tab in file adapter?
    Regards,
    Irshad.

    Chandras sekhar,
    i have already seen that blog...
    could you plz read my message once again?
    Regards,
    Mansoor
    ya i got it..Call sap adapter module will store the message in send queue.
    just want to know which module is building the xi header whether it is same call sap adapter module or is there any specific module which will convert native message to xi message.
    Is call sap adapter module is the responsible for building the xi message header with the help of cpa lookup? if its so again confuse for me.....
    In File adapter we have 3 tabs one is parameter identifier and module...As u said first parameter tab will run as per FCC/ File message protocol then this parsed/content of text file will be input to the module tab .in this module tab we have custom modules and standard module these modules are executed in the same sequence as mentioned.
    what is the module name which converts native message to xi message?
    Regards,
    Mansoor

Maybe you are looking for

  • Problem with signing in to app store

    Trying to get into the app store, typed in my user and everything but a message saying "does not verify device/computer" popped up.

  • IPod Touch locked up after upgrading to 2.0.2.  Can I get it back?

    Last night, I upgraded to 2.0.2, and let it install completely. Then I saw that the Cube Runner app was upgraded to 1.2. I started the install process on the iPod to download and install the app via my WiFi connection. When I woke up this morning, It

  • Acrobat 9 Pro - Will it print to pdf with embedded pdf's from Word 2007?

    Hello All, We're considering upgrading to Acrobat 9 Pro or Extended.  One of our concerns is whether it will handle the following: 1. We create very large documents and we like the ability to use OLE of existing PDF documents imbedded into Word 2007

  • Accessing custom dll from Servlet

    Hello, I am trying to load a custom dll in iWS4.1SP9 but I seem no able to find the dll. Where do I have to place it on the system? I have placed it in WinNt/system32 dir but still could not find it. I was sucessful in loading the dll when running as

  • Replacement hard drive for T23

    I've got a 2647-HU8 and need a comatible replacement drive. It had a 4200 rpm, 40 gb drive. ATA-6. I parts list gives the number 08K9767 or a Travelstar 4K40. The Travelstar 4K40 is no longer available. Do I go with a 5K40? Thanks in advance. ThinkPa