Using DBMS LOB in a procedure

Hi,
Does anybody have a code example showing the use of DBMS_LOB in a procedure to UPDATE a CLOB field in table?
Thanks in advance,
Marc.

An advanved example from Oracle documentation:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14249/adlob_design.htm#sthref323

Similar Messages

  • Using Copy statement in Stored procedure

    The following statement works in sqlplus session:
    copy from comment/password@servername append amcomment_temp using
    select * from amcomment
    where commentid in(1,2,3,4)
    I want to use this in a stored procedure. There is a long datatype in this table. The
    procedure will not compile. Have tried execute immediate and compiler rejects this statement also.

    'COPY' is a SQL*Plus command, not PL/SQL. This is why the PL/SQL compiler throws it out.

  • How to use bind variables in this procedure

    Hi Experts,
    How to use bind variables in this procedure for static queries.
    PROCEDURE DELETE_MER_PROC (M_id IN NUMBER)
    IS
    BEGIN
    V_date DATE;
    SELECT PD_DATE INTO v_date FROM PD_MAINTAIN;
        DELETE FROM MER_CLEAR
        WHERE MER_DT < v_date
        AND ID = M_ID;
    COMMIT;
    END;   
    How to use  v_date and m_id as bind variables in this procedure to avoid hard parsing.
    Please help me.
    Thanks.

    976208 wrote:
    How to use  v_date and m_id as bind variables in this procedure to avoid hard parsing.
    You cannot avoid hard parsing - as the 1st time a SQL statement (like the SELECT or DELETE statements in your code) is encountered, it does not reside in the server's Shared Pool, and needs to be added into the pool via a hard parse.
    Bind variables does not prevent hard parsing. Hard parsing happens when the SQL statement (with or without bind variables) is a brand new statement encountered by the server.
    Bind variables enables the same SQL cursor to be reused, by simply changing the bind variable value.
    Not using bind variables means that each SQL statement is unique and not shareable - as the value is hardcoded into the statement and cannot be changed via a bind value. This typically means LOTS of different SQL statements (where the only difference is the changed value in the statement) are created - with each statement being a new statement not seen before in the Shared Pool and needing to be hard parsed.
    One does not design one's code not to be hard parsed. There ALWAYS will be a hard parse in order to get a SQL statement into the Shared Pool. One designs one's code to REUSE cursors in the Shared Pool.

  • How to use order by in stored procedure base block?

    How to use order by in stored procedure base block? I need to change order by dynamically

    Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');

  • Two related questions: using htmldb_Get to call stored procedure and passing in an array of items

    I have the need to save dynamically generated ApEx items via AJAX.  I am using APEX_ITEM API to generate the items.  At run-time, I have no idea how many of items will be generated on the page, but I know that they will all have discreet and distinct "name" attributes, i.e. f01, f02, f03, etc.  As a basic example, if I have to generate a select list, I know that the "p_idx" parameter of the APEX_ITEM call is say "3", so all select lists that get generated will have a "name" attribute in the DOM of "f03", all text items will be "f01", etc.
    I want to save this data to the database via AJAX.  It is typical to call the standard htmldb_Get javascript function for use of an on-demand process, but I am interested in using the rarely-called-upon "procedure" and queryString" options of that javascript function so that I can build the queryString on the fly based on what is on the DOM when the tries to save the data they entered into these APEX_ITEM-generated items.  Does anyone have any good examples of how to use the "procedure" and "queryString" parameters of the htmldb_Get javascript function?
    I have found a smattering of some blogs, posts, etc. online related to this, but mostly just people regurgitating the documentation.  I found this post (https://forums.oracle.com/thread/2549237) which had a glimpse of hope to be able to pass an array (which is something I will need) as a parameter, but would like someone to sanity check this before I go down that road.
    Shane.
    ApEx 4.2.1

    Shane
    Since you mention you are on APEX 4.2  I would recommend using apex.server.process which is the documented replacement of the officially undocumented htmldb_Get.
    In the documentation it is set that the first parameter is the ajaxidentifier but it actually is the process name.
    The data object would be something like
    var lData ={f01 : get_value_array('f01')}
    Where get_value_array is
    function get_value_array(pColumnName) {
      var l_values =[];
      apex.jQuery('[name="'+pColumnName+'"]').each(
       function(){
        var l_value;
        l_value = apex.item(this.id).getValue();
        l_values.push(l_value);
      return l_values
    For a working example see this demo.
    Nicolette

  • Using VIEW inside a stored procedure

    Hi,
    So I have a View designed in one file that validates someone who is authorized.
    Then I have a stored procedure to display authorized stationeries created before a given date. Its takes a parameter @CreatedOn.
    How can I use VIEW in my stored procedure so I can display all the authorized which are set 1 before a given date?
    My VIEW:
    ALTER VIEW vw_AuthorizedStationeries AS
    SELECT Authorized
    FROM dbo.Stationeries
    WHERE Authorized = 1
    And my stored procedure:
    CREATE PROCEDURE usp_stationeries (@CreatedOn datetime)ASBEGINSELECTFROMENDGO
    Thanks!

    Try something like below, You need to replace CreatedDate column with appropriate date column in your table.
    1. Alter the view to get the required date:
    ALTER VIEW vw_AuthorizedStationeries AS
    SELECT Authorized, CreatedDate
    FROM dbo.Stationeries
    WHERE Authorized = 1
    2. Alter SP:
    CREATE PROCEDURE usp_stationeries (@CreatedOn datetime)
    AS
    BEGIN
    SELECT Authorized
    FROM vw_AuthorizedStationeries
    WHERE CreatedDate <= @CreatedOn
    END
    GO
    OR
    You can pull required information directly from your table:
    CREATE PROCEDURE usp_stationeries (@CreatedOn datetime)
    AS
    BEGIN
    SELECT Authorized
    FROM dbo.Stationeries
    WHERE CreatedDate <= @CreatedOn and Authorized = 1
    END
    GO
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • Using temporary tables in stored procedures

    Suppose that I have created a temporary table in a stored procedure using an "EXECUTE IMMEDIATE" statement. When I compile the procedure, that table is not created yet, so the compiler says that the table does not exist.
    What is the way of using temporary tables in stored procedures?

    It's a good practice to avoid using DDL statements being executed from stored procedures. "Truncate Table" via dynamic SQL from stored procedure is a different story and is useful in DSS environments.
    But if you insist on "creating" tables using Dynamic SQL from Stored Procedures then you must also embed your DML statements in Dynamic SQL to avoid compilation errors.
    Example:
    Create or Replace Procedure Proc_TestDynamicSQL is
    Begin
    Execute Immediate 'Create table myTable as select * from user_tables' ;
    Execute Immediate 'Update myTable set table_name = ''Test'' ' ; --two single quotes before and after the string "Test"
    End;
    In this case, Oracle wouldn't care about the table references during compilation.

  • How to know a table is using in any packeges or procedures

    Dear All
    How can I know that a table is using in any packege or procedure or function ?
    I mean , let say I have 10 Packages , 10 Procedures and 5 Functions .
    I need to know in which Packages , Procedures or Functions are using the table EMP .
    How can I search ? Is there any command or I need to open all the procedures and then search one by one ?

    Hi everyone,
    Did anyone interest in the topic search for dependencies between objects in the database?
    I want to see the PL/SQL code which is an appeal to a particular procedure or function or package and where and how does an object use in any PL/SQL code.
    Often do you have a need to get answers to these questions?
    I say about an object usage presentation, not about its relations only.
    Do you want to know, how opbject used?
    If it's a table - what's DML?(insert/select/...)
    If it used in a package - which procedure of package uses in?
    The object usage in an external objects - Oracle*Forms/Reports,Flat/Word files, Informatica.
    I'll want to know, if everybody interested to one.

  • In SQLScript, how to use EXEC to call another procedure with parameters in procedure?

    Hi experts,
    In SQLScript, How to use EXEC to call another procedure with input and output parameters in procedure?thanks very much

    Hi Sagar,
    thank you! I generate another procedure with an input parameter and an output parameter in a procedure. Then i need to call the generated procedure using EXEC. Here is my code:
    create procedure ftest1(out sum_num bigint)
    as
    begin
    declare fa_output bigint;
    declare v_sql_drop varchar(200);
    declare v_sql varchar(500);
    declare cursor c_cursor1 for select num from TABLE1;
    --v_sql_drop := 'drop procedure fe';
    --exec v_sql_drop;
    v_sql := 'create procedure fe(in i_num bigint,out o_num bigint) as begin';
    v_sql := :v_sql || ' o_num := :i_num * 2 + :i_num * :i_num;';
    v_sql := :v_sql || ' end';
    exec v_sql;
    open c_cursor1;
    for c_item as c_cursor1 do
    exec 'call fe(c_item.num,o_num=>fa_output)';
    if sum_num is null then
    sum_num := fa_output;
    else
    sum_num := :sum_num + fa_output;
    end if;
    end for;
    close c_cursor1;
    end;
    The underline code is using exec to call the generated procedure. But this method cannot work. Any suggestion? thanks again!

  • Can rs.last() be used after calling the stored procedure?

    Can rs.last() be used after calling the stored procedure? If yes what should be the CURSOR types?

    Can rs.last() be used after calling the stored
    procedure? If yes what should be the CURSOR types?That would depend on the driver/database.
    And as I said in your other post it is far more efficient to count records by just returning a count rather than a complete collection regardless of how you get to the end.

  • When we use SQLScript/CE Functions or procedures in real time scenario

    Hi,
    Can anyone explain me, when we use Scripted Calculation view or procedure using SQL/CE functions in real time project implementations.
    Let me know some business requirement why we choose these instead of graphical view.

    Hi Kumar,
    <i>So in real time if you want to develop some interface whether we use existing components or we will create own user defined products and components ??</i>
    We can do both.
    If the pre-delivered content actually solves ur purpose by providing the exact format of data, then u should go for the <b>existing components</b>
    If there is any change from the content provided, then u should change it and<b> create own user defined products and components</b>
    <i> What is the criteria behind choosing either of them ??</i>
    Thus the criteria is purely based upon the type of data formats u have to use. Existing component always saves lot of development time
    Regards,
    Prateek

  • Use database inside a stored procedure

    Hi guys, a stupid question: I'm working with several database and sometimes I'm afraid to run an alter or a create something in the wrong database, bear in mind that several database have the same tables. Sometime happens to run a query oin the db A
    instead in the db B. So, the question: If I create a procedure like this,
    create procedure creatingPillar as
    use USA
    begin
    IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
    OBJECT_ID(N'pillarretail') AND type in (N'U'))
    DROP TABLE PillarRetail
    create table PillarRetail (anid int , ancore varchar(20), period dec(18,6), settlem datetime2,
    settlementper int, asf dec(18,6),astlf dec (18,6), tot dec (18,6) )
    insert into PillarRetail select anid, ancore, Period, settlem, settlementper,
    asf, astlf, tot from createsemipillar2011
    insert into PillarRetail select select anid, ancore, Period, settlem, settlementper,
    asf, astlf, tot createsemipillar
    end
    but I'm wondering if is useless to put the use USA in the stored procedure by the moment that I'm creating the procedure in USA. I mean, having the SP in the USA db even if I run the procedure from another db it should run in USA. Just a stupid question
    I know but I got this doubt...
    Thanks 

    You may try as below:
    create proc as below: (This will create the proc in USA database.
    use USA
    Go
    create procedure dbo.creatingPillar as
    begin
    IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
    OBJECT_ID(N'pillarretail') AND type in (N'U'))
    DROP TABLE PillarRetail
    create table PillarRetail (anid int , ancore varchar(20), period dec(18,6), settlem datetime2,
    settlementper int, asf dec(18,6),astlf dec (18,6), tot dec (18,6) )
    insert into PillarRetail select anid, ancore, Period, settlem, settlementper,
    asf, astlf, tot from createsemipillar2011
    insert into PillarRetail select select anid, ancore, Period, settlem, settlementper,
    asf, astlf, tot createsemipillar
    end
    Then you can call as below:
    Exec USA.dbo.creatingPillar

  • Using AIR as source for procedure generators??

    We currently have procedure generators for support people to choose the documentation they want to see and download it. Problem is the output (and input) is all Word based and the choice is not to go back from Frame to Word.
    Could AIR be used as sources for a procedure generator, to output in XML format?
    Thanks!

    It is my understanding you need at least 10.1.3.3.2 (upgrade/patch).
    I'm currently on 10.1.3.3.0 and will be using ESSBASE shortly - so we actually have purchased 10.1.3.3.3 (OBIEE Plus).

  • Using temporary LOB

    I am trying to use temporary LOB to store texts. When I am manipulating with LOB I can see some IO spikes on server from 50 to 100 % of IO. According to
    Oracle documentation V$TEMPORARY_LOBS view should give me enough information but I couldn't find any description of the columns. Can someone point me to any resource that describes LOB and monitoring of about memory/resource
    utilization. Can someone tell me how to interpret CACHE_LOBS,NOCACHE_LOBS
    numbers.
    Thanks in advance for any suggestions
    Bob

    Hello,
    Disclaimer: I've not tried to run your sample...
    Question:
    You have:
    case OracleDbType.NClob:
    lobTypeName = "clob";
    //NB: Using the constructor without the connection throws an exception
    tempLob = new OracleClob(conn, true, true);
    tempOracleDbType = OracleDbType.Clob;
    break;
    Why tempOracleDbType = OracleDbType.Clob; ? Should this be tempOracleDbType = OracleDbType.NClob; ?
    I don't understand the comment "//NB: Using the constructor without the connection throws an exception".
    There are two OracleClob constructors, both of which require a connection object. There is no constructor that does not take a connection.
    - Mark

  • Using APEX_MAIL from within a procedure invoked from DBMS_JOB

    I have done a lot of googling and wasted a couple of days getting nowhere and would appreciate some help. But I do know that in order to use APEX_MAIL from within a DBMS_JOB that I should
    "In order to call the APEX_MAIL package from outside the context of an Application Express application, you must call apex_util.set_security_group_id as in the following example:
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = p_app_id )
    loop
    apex_util.set_security_group_id(p_security_group_id =>
    c1.workspace_id);
    end loop;
    I have created a procedure that includes the above (look towards the end)
    create or replace procedure VACANCIES_MAILOUT
    (p_application_nbr number,
    p_page_nbr number,
    p_sender varchar2)
    AS
    Purpose: Email all people registerd in MAILMAN [email protected]
    with details of any new vacancies that started listing today.
    Exception
    when no_data_found
    then null;
    when others then raise;
    l_body CLOB;
    l_body_html CLOB;
    l_vacancy_desc VARCHAR2(350);
    to_headline varchar2(200);
    to_org varchar2(100);
    l_vacancies_desc varchar2(2000);
    to_workspace_id number(22);
    CURSOR vacancies_data IS
    select DISTINCT v.headline to_headline,
    ou.org_name to_org
    from VACANCIES v,
    Org_UNITS ou
    where
    ou.org_numb = v.Org_Numb
    and v.public_email_sent_date is Null
    Order by ou.org_name, v.headline;
    BEGIN
    BEGIN
    FOR vacancies_rec in vacancies_data
    -- build a list of vacancies
    loop
    BEGIN
    l_vacancy_desc := '<br><b>' ||
    vacancies_rec.to_org || '<br>' ||
    vacancies_rec.to_headline || '</b><br>';
    -- l_vacancy_desc :=
    -- vacancies_rec.to_org || ' - ' ||
    -- vacancies_rec.to_headline ;
    l_vacancies_desc := l_vacancies_desc || l_vacancy_desc;
    END;
    END LOOP;
    END;
    l_body := 'To view the content of this message, please use an HTML enabled mail client.'||utl_tcp.crlf;
    l_body_html :=
    '<html>
    <head>
    <style type="text/css">
    body{font-family:  Verdana, Arial, sans-serif;
                                   font-size:11pt;
                                   margin:30px;
                                   background-color:white;}
    span.sig{font-style:italic;
    font-weight:bold;
    color:#811919;}
    </style>
    </head>
    <body>'||utl_tcp.crlf;
    l_body_html := l_body_html || l_vacancies_desc
    || '<p>-----------------------------------------------------------------------------------------------------------------</strong></p>'
    ||utl_tcp.crlf
    || '<p>The above new vacancies have been posted on the <strong>Jobs At Murdoch</strong> website.</p>'
    ||utl_tcp.crlf
    ||'<p>For futher information about these vacancies, please select the following link</p>'
    ||utl_tcp.crlf
    ||'<p> Jobs At Murdoch </p>'
    ||utl_tcp.crlf
    ||'<p></p>'
    ||utl_tcp.crlf;
    l_body_html := l_body_html
    ||' Regards
    '||utl_tcp.crlf
    ||' <span class="sig">Office of Human Resources</span>
    '||utl_tcp.crlf;
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = 1901)
    loop
    apex_util.set_security_group_id(p_security_group_id => c1.workspace_id);
    end loop;
    apex_mail.send(
    p_to => '[email protected]',
    p_from => '[email protected]',
    p_body => l_body,
    p_body_html => l_body_html,
    p_subj => 'Jobs At Murdoch - new vacancy(s) listed');
    update VACANCIES
    set public_email_sent_date = trunc(sysdate,'DDD')
    where public_email_sent_date is null;
    commit;
    END;
    but still get the error
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /oracle
    System name: Linux
    Node name: node
    Release: 2.6.18-194.17.1.el5
    Version: #1 SMP Mon Sep 20 07:12:06 EDT 2010
    Machine: x86_64
    Instance name: instance1
    Redo thread mounted by this instance: 1
    Oracle process number: 25
    Unix process pid: 5092, image: (J000)
    *** 2011-07-12 09:45:03.637
    *** SESSION ID:(125.50849) 2011-07-12 09:45:03.637
    *** CLIENT ID:() 2011-07-12 09:45:03.637
    *** SERVICE NAME:(SYS$USERS) 2011-07-12 09:45:03.637
    *** MODULE NAME:() 2011-07-12 09:45:03.637
    *** ACTION NAME:() 2011-07-12 09:45:03.637
    ORA-12012: error on auto execute of job 19039
    ORA-20001: This procedure must be invoked from within an application session.
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 290
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 325
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 367
    ORA-06512: at "HRSMENU_TEST.VACANCIES_MAILOUT", line 94
    ORA-06512: at line 1
    Can someone please tell me what what stupid thing I am doing wrong? The procedure worked when invokded from SQL Workshop but fails in a DBMS_JOB.
    much thanks Peter

    I think that might help...
    http://www.easyapex.com/index.php?p=502
    Thanks to EasyApex..
    LK

Maybe you are looking for

  • IOS 8.1 Excel % Issue

    Hi Applemates, With the update to 8.1 (from 7.1) on my iPhone & iPad, I am having issues reading my Excel reports that come through mails. The issue is the % numbers are shown incorrectly. E.g. 39% is shown as 0%, 90% is shown as 1% and 200% is shown

  • How do I fix a word doc. that turned to asterisks? Or find an earlier version of the document?

    I was typing a paper and the entire doc. turned to asterisks. Then I panicked and hit save thinking that would be beneficial. Now I only have a doc. with symbols. Is there a way to find an earlier version of the paper? I have saved it at least a doze

  • ERROR WHILE UPLOADING EXECL FILE IN SECATT

    HI ALL I HAVE DONE RECORDING BY USING SECATT AND CREATED THE TEST CONFIGURATION FOR THE PLMD_AUDIT T-CODE AND FILLED THE TEMPLATE WHICH I HAVE DOWNLOADED FROM THE SCEATT BUT WHEN I EXECUTE I AM GETTING AN ERROR AS VARIANTS THAT MATCH SELECTION CANNOT

  • App Store asks for password to wife's apple id

    Had my Iphone 4 replaced at the store yesterday, all restored fine from backup however when I go to update my apps it asks for my wifes password to her id! My wifes phone is synced on the same pc. I have checked all settings in the phone and they con

  • No mouse cursor during Windows 8.1 OSD

    Hi, I have a problem that is bugging me. Not really a biggie but a frustrating one. When deploying Windows 8.1 using a MDT 2013 TS from CM12R2 the mouse cursor gets disabled when the OS reboots into minisetup/windows. As long as the TS is in WinPE al