Change schema runtime in procedure

Hello friends,
I have one query in procedure. I have same table with same structure and name in more than 10 schema. I want to access these table records dynamically using procedure.
I want to change schema name in procedure.
Please check below PL/SQL code i have wrote.
declare
     cursor c1 IS
     select deptno,dname,loc from &schema..dept;
begin
     for rec in c1
     loop
          dbms_output.put_line(rec.deptno || ' ' || rec.dname || ' ' || rec.loc);
     end loop;
end;
I want same functionality using procedure. Please check procedure code below:
create or replace procedure diff_schema (schema_name IN varchar2)
Declare
     cursor c1 IS
     select deptno,dname,loc from schema_name.dept;
AS
begin
     for rec in c1
     loop
          dbms_output.put_line(rec.deptno || ' ' || rec.dname || ' ' || rec.loc);
     end loop;
end;
but it returns error.
Please help me to solve this issue.
Pradip Patel

BluShadow wrote:
Venkadesh wrote:
Agree..
Hope this work.
create or replace procedure r_test (p_schema in varchar2)
is
v_rc sys_refcursor;
v_all emp%rowtype;
begin
open v_rc for 'select * from '||p_schema||'.emp';
loop
fetch v_rc into v_all;
exit when v_rc%notfound;
dbms_output.put_line(v_all.ename);
end loop;
close v_rc;
end;
That still assumes that the emp table exists in the schema in which the procedure is compiled because you have:
v_all emp%rowtype;Essentially what the OP is asking for indicates that whereve the procedure is defined is going to need to know the structure of the tables it's going to use otherwise everything about it would need to be dynamic.
We have a process on one of our databases that has a similar setup, where there are several schema's all containing the same table structure, but different data, and we need a central setup of code that can process each of those as required.
For us we looked at it from a different perspective. Rather than having the central procedure try and access all the other schemas, for which it would need to know which schemas it has to access etc. and because sometimes some of those schemas should be excluded from the process if they have had an issue with their data being populated (it's a regular job to repopulate them and determine changes on them etc. - a bit of an ETL task really), we leave it up to the individual schemas to determine when the processing is necessary (i.e. when they each know their own data is ready to be processed). The advantage of that is that the central procedure's those schemas use all use the AUTHID CURRENT_USER, so the central schema just has a blank copy of the tables so the code can compile, but when the other schemas call the procedure, they are running the code against their own tables because of the AUTHID setting. It avoids any dynamic coding, or any (mis/ab)use of ref cursors, and it gives the flexibility that each schema is in control of it's own destiny, and other schemas can be added or removed as necessary without having to have some central control mechanism to know which schemas need processing.Thank you Blu,i'm learning lot of things from you...you are a champion

Similar Messages

  • Can date format be changed at runtime in patterLayout(log4J)

    Hi,
    I would like to know if the date format can be changed at runtime when i am using pattern layout. My application can have a particular date format. How do i specify that for the %d specifier in pattern layout, as i will only know the format at runtime.
    anjali

    Hello Mike,
    If your location is equivalent to the parsing schema you can use the APEX built-in substitution string *#OWNER#*.
    You still need to resort to Peter’s advices where dynamic table names are concerned. Bear in mind that in this case, you won’t be able to use the APEX built-in DML processes, and you’ll need to write your own fetch/insert/update/delete processes, which might be a lot of work. Working in a multi-user environment adds the complexity factor of concurrency control (lost updates).
    Regards,
    Arie.
    ♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    ♦ Author of Oracle Application Express 3.2 – The Essentials and More

  • Change schema's user name

    Isthere any way to change schema's user name. I have looked but couldnt find how to change. With "Alter user" name cant be changed.
    Thanks for the help...

    Hi,
    SQL> host exp system/oracle owner=scott file=c:\scottschema.dmp log=c:\scott.log
    Export: Release 10.1.0.2.0 - Production on Tue Dec 12 09:36:37 2006
    Copyright (c) 1982, 2004, Oracle.
    All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 -
    ProductionWith the Partitioning, OLAP and Data Mining options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified users ....
    exporting pre-schema procedural objects and actions.
    exporting foreign function library names for user SCOTT.
    exporting PUBLIC type synonyms.
    exporting private type synonyms.
    exporting object type definitions for user SCOTT
    About to export SCOTT's objects ....
    exporting database links.
    exporting sequence numbers.
    exporting cluster definitions.
    about to export SCOTT's tables via Conventional Path .... .
    exporting table A 0 rows exported. .
    exporting table ABCDEFGHIJKLMNOPQRSTUVWXYZ 0 rows exported. .
    exporting table ABCDEFGHIJKLMNOPQRSTUVWXYZ1234 0 rows exported. .
    exporting table A_12345678901234567890123456$# 0 rows exported. .
    exporting table B 100 rows exported. .
    exporting table BIG 46968 rows exported. .
    exporting table BIG_TABLE 46967 rows exported. .
    exporting table BONUS 0 rows exported. .
    exporting table C 1000 rows exported. .
    exporting table D 1000 rows exported. .
    exporting table DEPT 4 rows exported. .
    exporting table E 1000 rows exported. .
    exporting table EMP 14 rows exported. .
    exporting table FINAL_OUTPUT. .
    exporting table Q 10000 rows exported. .
    exporting table SALGRADE 5 rows exported. .
    exporting table T 1000 rows exported. .
    exporting table TEST 7 rows exported.
    exporting synonyms.
    exporting views.
    exporting stored procedures.
    exporting operators.
    exporting referential integrity constraints.
    exporting triggers. exporting indextypes.
    exporting bitmap, functional and extensible indexes.
    exporting posttables actions.
    exporting materialized views.
    exporting snapshot logs.
    exporting job queues.
    exporting refresh groups and children.
    exporting dimensions.
    exporting post-schema procedural objects and actions.
    exporting statistics
    Export terminated successfully without warnings.
    SQL> select user_id,username from user_users;
    USER_ID USERNAME
    57 SCOTT
    SQL> select count(*) from session_privs;
    COUNT(*)
    81
    SQL> select count(*) from session_roles;
    COUNT(*)
    6
    SQL> set echo off
    SQL> set feedback off
    SQL> set heading off
    SQL> spool c:\scottpriv.sql
    SQL> select 'grant 'privilege' to newscott;' from session_privs;
    SQL>spool off
    SQL> spool c:\scottroles.sql
    SQL> select 'grant 'role' to newscott;' from session_roles;
    grant CONNECT to newscott;
    grant RESOURCE to newscott;
    grant IMP_FULL_DATABASE to newscott;
    grant SELECT_CATALOG_ROLE to newscott;
    grant HS_ADMIN_ROLE to newscott;
    grant EXECUTE_CATALOG_ROLE to newscott;
    SQL> spool off
    SQL> set heading on
    SQL> set feedback on
    SQL> set echo on
    SQL> select default_tablespace from user_users;
    DEFAULT_TABLESPACE
    TEST
    1 row selected.
    SQL> conn system/oracleConnected.
    SQL> create user newscott identified by newscott default tablespace test;
    User created.
    SQL>@c:\scottpriv.sql <>
    SQL>@c:\scottroles.sql <>
    SQL> host imp system/oracle fromuser=scott touser=newscott file=c:\scottschema.dmp log=scottimp.log
    Import: Release 10.1.0.2.0 - Production on Tue Dec 12 09:54:39 2006Copyright (c) 1982, 2004, Oracle.
    All rights reserved.Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsExport file created by EXPORT:V10.01.00 via conventional pathimport done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set. importing SCOTT's objects into NEWSCOTT. .
    importing table "A" 0 rows imported. . importing table "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 0 rows imported. .
    importing table "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234" 0 rows imported
    SQL>drop user scott cascade;
    SQL> select username,user_id from user_users;
    USERNAME USER_ID
    NEWSCOTT 5
    81 row selected.
    SQL> select count(*) from session_privs;
    COUNT(*)
    81
    1 row selected.
    SQL> select count(*) from session_roles;
    COUNT(*)
    6
    1 row selected.
    SQL>Try above scripts if it is help
    regards
    Taj
    Message was edited by:
    M. Taj

  • Is it possible to change schema or name of locally built provider in portal

    Is it possible to change schema or name of locally built provider in portal 9.0.4?
    We have built an application as a pagegroup and locally built provider in Oracle portal. We can deploy the application to different portals using transport sets. However, it is not possible to install the same provider twice to a shared portal because a provider's name and schema cannot be changed. Does anyone know of a way to rename and change the schema of locally built providers? I was once told that substition strings at import would be available in an upcoming release to do that, but I haven't seen anything like that.
    Thanks,
    Trenton

    Maybe use a MHT archive.
    *Mozilla Archive Format: https://addons.mozilla.org/firefox/addon/mozilla-archive-format/
    *UnMHT: https://addons.mozilla.org/firefox/addon/unmht/

  • Broken DCs after changing the runtime systems in track

    Hello,
       I am making some WebDynpro changes to ESS using NWDI and NWDS. All was working fine until I changed the runtime systems in the track. Eversince I added the test runtime system in the track, I am getting broken DC errors in sap.com_SAP_ESS_1 compartment. When I looked at the details in CBS, it says that Used Component "tc/bi/bp/pcd" not found. I looked at the compartment sap.com_SAP_BUILDT_1 and this DC is not available in that. When I did sync used DCs in NWDS, I am getting the error "ERROR: Check for used DCs failed: Used component not found: sap.com/tc/bi/bp/pcd. DC not found in DC syncdb." . I performed restore system state and reimported all the required .sca files in to the track. I am still having this problem even after reimport. 
    Any help is appreciated.
    Thanks,
    Srihari

    Hi Krishna and Snehal,
        Thanks for your responses. I have done some more research and found out that the missing DC is available in EP_BUILDT SCA file. I have downloaded sca file for EP_BUILDT from market place and placed it in CMS inbox. I also deployed the .sca file in NWDI system. In CMS, I can not see this .sca file of EP_BUILDT in the check-In tab. I tried to add it as dependency to SAP_ESS SC in Landscape Navigator. But, EP_BUILDT is not available in the list of SWCV when I click on "Define Dependencies". I checked SLD and found out that it is not in the list of SWCV, but is there in "Installed Products" tab  of NWDI technical system. Any idea on how to get it as SWCV in SLD or how to get the .sca file in to my "Check-In" tab of  track? Please share your thoughts.
    Thanks,
    Srihari

  • How to list all physical schemas in ODI procedure

    Dear Experts,
    I am trying a requirement which is to execute a set of sqls in all the schemas configured in ODI.
    for example
    1) I have four data servers/physical schemas configured in Physical Architecture under Oracle techonlogy.
    2) Created corresponding 4 logical schemas for Oracle.
    3) Mapped using two different contexts.
    4) one context mapped two schemas and another mapped two other schemas.
    now, I need to exeture the following sql for all the Oracle schemas mapped in context selected.
    just for testing: select dummy from dual
    I would like to execute this sql in ODI procedure for every schema mapped in the selected context in single execution.
    Can any expert help me on this solution?
    - Raja

    Raja,
    I was actually talking about multiple ODI Step command rather than multiple procedure. What you are trying to achieve is difficult unless you specify the logical schema in ODI Procedure , becuase getInfo will throw Null pointer if we dont specify the logical schema ,
    the getSchema needs Logical schema . The other way i can think query in work rep tables and get the schema name and pass it .
    Any way in case your figure out without passing Logical schema . Please share with us , i would be interested in learning the trick .

  • ClockIn/ClockOut Error: Class interface was changed at runtime

    Hi,
    We are testing clock in / clock out corrections and the following error is arising when we call the functionality by this link:
    http://server:port/sap/bc/webdynpro/sap/hress_a_corrections?sap-wd-configid=HRESS_AC_CORRECTIONS&sap-client=400&sap-language=PT
    Error:
    Class interface was changed at runtime
    The strange is that before it was working fine and now we are getting this dump.
    Any Idea?
    Thanks
    Bruno

    I have found the error. Someone in the project run some process and input  wrong data in infotype 2006.
    I cleaned it and it worked!
    Thank Siddharth.
    Regards,
    Bruno

  • Compiling different schema Synonym through Procedure

    Hi,
    I have created a user with DBA access called DBA_USER.
    I want to compile invalid synonym present in another schema through a procedure present in this schema.
    What system privilege should I grant for this.
    DBA_USER>
    CREATE OR REPLACE PROCEDURE TEST_COMPILE AS
    BEGIN
    EXECUTE IMMEDIATE 'ALTER SYNONYM SCOTT.EMP_TAB_SYNONYM COMPILE';
    END;
    DBA_USER>EXEC TEST_COMPILE;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "DBA_USER.TEST_COMPILE", line 3
    ORA-06512: at line 1
    Note: I faced same problem with compiling procs/packages. After physically granting
    "ALTER ANY PROCEDURE" to DBA_USER it got resolved. I could not able to find a similar one for Synonyms.
    Thanks
    Balaji Chellappa

    Justin,
    Granting "CREATE ANY SYNONYM" does not solves the problem.
    Here is the SQL Script
    ==============================
    SQL> SHOW USER
    USER is "DBAAUX"
    SQL> GRANT CREATE ANY SYNONYM TO DBAAUX;
    Grant succeeded.
    SQL> GRANT DROP ANY SYNONYM TO DBAAUX;
    Grant succeeded.
    SQL> CREATE SYNONYM SFA.DD FOR DUAL;
    Synonym created.
    SQL> SELECT * FROM SFA.DD;
    D
    X
    SQL> DROP SYNONYM SFA.DD;
    Synonym dropped.
    SQL> -- Now trying the same through PL SQL
    SQL> begin
    2 execute immediate 'CREATE SYNONYM SFA.DD FOR DUAL';
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM SFA.DD;
    D
    X
    SQL> -- Compiling the same
    SQL> ALTER SYNONYM SFA.DD COMPILE;
    ALTER SYNONYM SFA.DD COMPILE
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL> begin
    2 execute immediate 'ALTER SYNONYM SFA.DD COMPILE';
    3 end;
    4 /
    begin
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at line 2
    SQL> spool off
    =================================================
    Thanks
    Balaji Chellappa

  • Passing a Parameter to the Procedure and changing it in the Procedure

    Hi all,
    I am trying to pass a parameter to a procedure like this.
    PROCEDURE FLASH_PHY
    (date_begin IN DATE, date_end IN DATE)
    IS
    I am trying to do SELECT and INSERT based on the date range passed in the procedure as mentioned above. And I am trying to do something like this.
    SELECT NVL(sum(charges),0),count(summary_balances_id)
    INTO lnu_charges_6months,c_summary
    FROM SUMMARY_BALANCES
    WHERE period_begin BETWEEN ADD_MONTHS((date_begin), -6) -- AND ADD_MONTHS((date_end), -1);
    UPDATE summary_balances
    SET cummulative_charges_6mo = lnu_charges_6months;
    how should I do this parameter change. Right now if I use this select statement than it does not return anything as the parameter is passed on the procedure level. I am under the impression that when you pass a parameter to the procedure like this you can't change it into the procedure.
    PLEASE GUIDE. Thanks a bunch. I really appreciate it.

    From what I understand your variables that are passed into the
    procedure can be manipulated as local variable to the procedure.
    Here is my interpretation of what your attempting to do:
    create or replace procedure A (x in number) IS
    yes varchar2(3) := 'No';
    begin
    dbms_output.put_line('Start value for yes:'||yes);
    select 'yes' into yes from dual where x+1 = 2;
    dbms_output.put_line('End value for yes:'||yes);
    end;
    Call the procedure called "A" passing in a "1".
    EG:
    BEGIN
    A(1);
    END;
    Does this answer your question?
    ,Russ

  • Calculation schema under pricing procedure

    in pricing procedure under calculation schema what is <b>Condition formula for alternative calculation type</b> and <b>Alternative formula for condition base value</b>
    what is the use of these functions?

    in this field u can creat ur own formuls to calculat base price or condition type value
    this are called routine.
    eg if u want to calculate the cond value on some logic the u can write ur logic in this routine and change the valuer of ur base price or Condution type
    simple eq will be rounding up the values of condition type 17 is the routien u can use
    hope this helps
    Reward if useful

  • How to change schema

    newbie question:
    I have some mapping that I created in owb (Oracle 11.2), and I would like to change source/target schema (for example, because of export/import).
    Is it only way to create new Location and to change Data location to a new one, or there is another way?
    regards

    ...Or you can unregister the location, change the values and reregister. There is only one value for that location in the runtime though.
    If you are trying to have multiple dynamic sources are runtime the following may be useful;
    http://blogs.oracle.com/warehousebuilder/entry/owb_reuse_mapping_for_different_data_sources
    Cheers
    David

  • Can substitution strings be changed at runtime?

    I need to deploy my application such that it can run with different sets of tables, which are otherwise identical in design.
    My client has multiple versions of the tables. For instance, they may have
    CHICAGO.EMPLOYEES
    CHICAGO.DEPARTMENTS
    or
    LONDON.EMPLOYEES
    LONDON.DEPARTMENTS
    or even
    CHICAGO.EMPLOYEES_V01
    CHIGAGO.DEPARTMENTS_V01
    I can of course create a separate installation for each one of these, but this is neither elegant nor efficient.
    Is there I way I can have a UNIQUE APEX application installation and then use substitution strings to switch between variants?
    Ideally, I should modify the LOGIN screen adding two new fields, Location and Version and then designate the tables as
    $LOCATION..EMPLOYEES_$VERSION.
    $LOCATION..DEPARTMENTS_$VERSION
    This means that I need to retrieve the two variables at login and then use them to help point to the right tables.
    I know about substitution strings, but as far as I am aware they can only be changed statically during the development. Is it possible to change them at runtime? If yes, how?
    I would greatly appreciate any response.
    Mike

    Hello Mike,
    If your location is equivalent to the parsing schema you can use the APEX built-in substitution string *#OWNER#*.
    You still need to resort to Peter’s advices where dynamic table names are concerned. Bear in mind that in this case, you won’t be able to use the APEX built-in DML processes, and you’ll need to write your own fetch/insert/update/delete processes, which might be a lot of work. Working in a multi-user environment adds the complexity factor of concurrency control (lost updates).
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • Nice solution to change a lot of procedures at once.

    if you have to do little changes in a lot of your Procedures / Functions or Packages here is a nice solution to do this in a very short time:
    CREATE TABLE T_SOURCE
    SOURCE_ID NUMBER,
    NAME VARCHAR2(30 BYTE),
    SOURCETEXT CLOB
    CREATE OR REPLACE PROCEDURE CIAS_PUFFER.pr_t_source
    IS
    NAME: pr_t_source
    $Archive: //PVCS/archives/10gh/PR_T_SOURCE.prc_v $
    $Author: ext0523 $
    $Date: Aug 04 2008 17:26:54 $
    $Revision: 1.2 $
    CURSOR c_all_obj
    IS
    SELECT object_name
    FROM all_objects
    WHERE owner <>'SYS'
    AND object_type = 'PROCEDURE'
    ORDER BY object_name;
    CURSOR c_prog (cp_name VARCHAR2)
    IS
    SELECT *
    FROM all_source
    WHERE NAME = cp_name
    ORDER BY line;
    v_replace VARCHAR2 (999);
    v_st CLOB;
    i PLS_INTEGER := 0;
    BEGIN
    EXECUTE IMMEDIATE ('truncate table t_source');
    FOR rec_all_obj IN c_all_obj
    LOOP
    i := i + 1;
    v_st := '--$ARCHIVE$'||chr(10)||'--$AUTHOR$'||chr(10)||'--$DATE$'
    ||chr(10)||'--$REVISION$'||chr(10)||chr(10);
    v_st := v_st||'CREATE OR REPLACE ';
    FOR rec_prog IN c_prog (rec_all_obj.object_name)
    LOOP
    v_replace := UPPER (rec_prog.text);
    if instr(v_replace,'$ARCHIVE') >0 then v_replace :=''; end if;
    if instr(v_replace,'$AUTHOR') >0 then v_replace :=''; end if;
    if instr(v_replace,'$DATE') >0 then v_replace :=''; end if;
    if instr(v_replace,'$REVISION') >0 then v_replace :=''; end if;
    v_replace :=
    REPLACE (v_replace,
    '[email protected]',
    'prot_easy_cias'
    v_replace :=
    REPLACE (v_replace, '[email protected]', 'easy2cias');
    v_st := v_st || v_replace;
    END LOOP;
    INSERT INTO t_source
    VALUES (i, rec_all_obj.object_name, v_st);
    END LOOP;
    COMMIT;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END pr_t_source;
    // classpath= /ORACLE/u01/app/oracle/product/10.2.0.3/jdbc/lib/ojdbc14.jar
    // Java SQL classes
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    // Oracle JDBC driver class
    import oracle.jdbc.OracleDriver;
    // Java IO classes
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    //Java Util classes
    import java.util.Properties;
    * This class demonstrates the Oracle JDBC 10g enhanced features for inserting
    * and retrieving CLOB data from the database. Using the new features, large
    * data of more than 32765 bytes can be inserted into the database using the
    * existing PreparedStatement.setString() and PreparedStatement.getString()
    * methods.
    public class ClobMan {
    /* Database Connection object */
    private Connection conn = null;
    /* Variables to hold database details */
    private String url = null;
    private String user = null;
    private String password = null;
    // Create a property object to hold the username, password and
    // the new property SetBigStringTryClob.
    private Properties props = new Properties();
    /* String to hold file name */
    private String fileName = null;
    * Default Constructor to instantiate and get a handle to class methods
    * and variables.
    public ClobMan(String fileName) {
    this.fileName = fileName;
    * Main runnable class.
    public static void main(String[] args) throws SQLException {
    // Instantiate the main class.
    ClobMan clobMan = new ClobMan(args[0]);
    // Load the Oracle JDBC driver class.
    DriverManager.registerDriver(new OracleDriver());
    // Load the database details into the variables.
    String dbUrl = "jdbc:oracle:thin:@pmol:1550:dbpmol";
    clobMan.url = dbUrl;
    clobMan.user = "gh10";
    clobMan.password = "secret";
    // Populate the property object to hold the username, password and
    // the new property 'SetBigStringTryClob' which is set to true. Setting
    // this property allows inserting of large data using the existing
    // setString() method, to a CLOB column in the database.
    clobMan.props.put("user", clobMan.user );
    clobMan.props.put("password", clobMan.password);
    clobMan.props.put("SetBigStringTryClob", "true");
    // Check if the table 'CLOB_TAB' is present in the database.
    //clobMan.checkTables();
    // Call the methods to insert and select CLOB from the database.
    //clobMan.insertClob();
    clobMan.selectClob();
    * This method will insert the data into a CLOB column in the database.
    * Oracle JDBC 10g has enhanced the existing PreparedStatement.setString()
    * method for setting the data more than 32765 bytes. So, using setString(),
    * it is now easy to insert CLOB data into the database directly.
    private void insertClob() throws SQLException {
    // Create a PreparedStatement object.
    PreparedStatement pstmt = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create SQL query to insert data into the CLOB column in the database.
    String sql = "INSERT INTO clob_tab VALUES(?)";
    // Read a big file(larger than 32765 bytes)
    String str = this.readFile();
    // Create the OraclePreparedStatement object
    pstmt = conn.prepareStatement(sql);
    // Use the same setString() method which is enhanced to insert
    // the CLOB data. The string data is automatically transformed into a
    // clob and inserted into the database column. Make sure that the
    // Connection property - 'SetBigStringTryClob' is set to true for
    // the insert to happen.
    pstmt.setString(1,str);
    // Execute the PreparedStatement
    pstmt.executeUpdate();
    } catch (SQLException sqlex) {
    // Catch Exceptions and display messages accordingly.
    System.out.println("SQLException while connecting and inserting into " +
    "the database table: " + sqlex.toString());
    } catch (Exception ex) {
    System.out.println("Exception while connecting and inserting into the" +
    " database table: " + ex.toString());
    } finally {
    // Close the Statement and the connection objects.
    if (pstmt!=null) pstmt.close();
    if (conn!=null) conn.close();
    * This method reads the CLOB data from the database by using getString()
    * method.
    private void selectClob() throws SQLException {
    // Create a PreparedStatement object
    PreparedStatement pstmt = null;
    // Create a ResultSet to hold the records retrieved.
    ResultSet rset = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create SQL query statement to retrieve records having CLOB data from
    // the database.
    String sqlCall = "SELECT rownum, name, sourcetext FROM t_source";
    pstmt= conn.prepareStatement(sqlCall);
    // Execute the PrepareStatement
    rset = pstmt.executeQuery();
    String rownum = null;
    String o_name =null;
    String clobVal = null;
    // Get the CLOB value from the resultset
    //java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.FileWriter("pr_all.sql"));
    while (rset.next()) {
    rownum = rset.getString(1);
         o_name = rset.getString(2);
         clobVal = rset.getString(3);
    System.out.println(" length: "+clobVal.length()+" "+o_name+" "+rownum);
         java.io.BufferedWriter out =
         new java.io.BufferedWriter(new java.io.FileWriter(o_name+".prc"));
         out.write(clobVal);
         out.newLine();
         out.write("/");
         out.newLine();
         out.newLine();
    out.flush();
    out.close();
    } catch (SQLException sqlex) {
    // Catch Exceptions and display messages accordingly.
    System.out.println("SQLException while connecting and querying the " +
    "database table: " + sqlex.toString());
    } catch (Exception ex) {
    System.out.println("Exception while connecting and querying the " +
    "database table: " + ex.toString());
    } finally {
    // Close the resultset, statement and the connection objects.
    if (rset !=null) rset.close();
    if (pstmt!=null) pstmt.close();
    if (conn!=null) conn.close();
    * Method to check if the table ('CLOB_TAB') exists in the database; if not
    * then it is created.
    * Table Name: CLOB_TAB
    * Column Name Type
    * col_col CLOB
    private void checkTables() {
    Statement stmt = null;
    ResultSet rset = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create Statement object
    stmt = conn.createStatement();
    // Check if the table is present
    rset = stmt.executeQuery(" SELECT table_name FROM user_tables "+
    " WHERE table_name = 'CLOB_TAB' ");
    // If the table is not present, then create the table.
    if (!rset.next()) {
    // Table does not exist, create it
    stmt.executeUpdate(" CREATE TABLE clob_tab(clob_col CLOB)");
    } catch (SQLException sqlEx) {
    System.out.println("Could not create table clob_tab : "
    +sqlEx.toString());
    } finally {
    try {
    if( rset != null ) rset.close();
    if( stmt != null ) stmt.close();
    if (conn!=null) conn.close();
    } catch(SQLException ex) {
    System.out.println("Could not close objects in checkTables method : "
    +ex.toString());
    * This method reads the specified text file and, returns the content
    * as a string.
    private String readFile()
    throws FileNotFoundException, IOException{
    // Read the file whose content has to be passed as String
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    String nextLine = "";
    StringBuffer sb = new StringBuffer();
    while ((nextLine = br.readLine()) != null) {
    sb.append(nextLine);
    // Convert the content into to a string
    String clobData = sb.toString();
    // Return the data.
    return clobData;
    sqlplus -s @pr_all.sql;

    Is there a better way to satisfy such claim?I have to say I would not consider doing this in the database. Source control would allow you to manage (review / commit, not to mention revert) the results of such a potentially dangerours global search and replace.
    Such as if it UPPERcased all my source code for example.
    v_replace := UPPER (rec_prog.text);

  • How to change DataSource runtime in Oracle ADF.

    Hi All,
    In my requirement,Its seems to selecting dynamic data-source.let me explain my requirement i have a table in database username,passwords and schema name. from the login page i ll pass username,password and as drop-down I ll select schema.once i successfully logged-in can i access (execute, display data from ) selected schema from UI.in all sachems tables remain same but data is different.
    how to execute/change selected data-sources at run time if i am using Bc4J.
    please give me some solution.
    regards
    Siva

    Check Jobineshs blog http://jobinesh.blogspot.de/2011/04/modifying-application-modules-jdbc.html and Andrejus blog http://andrejusb.blogspot.de/2012/08/sample-application-for-switching.html
    Timo

  • Change from tax calc procedure TAXUS to TAXUSJ - Any experiences?

    It looks like we are going to have to change a basic function (as a result of a change in law).  That is we are currently configured to use the calculation procedure TAXUS (for non-jurisdictional tax calculations) to TAXUSJ (jurisdictional).  (We are using the US country code and will only be selling within state, but now have to base sales tax on ship-to location rather than point of sale).
    I've been looking over the docs on what needs to be changed in config/customizing, and found a little note that says "Once you choose your method, with or without jurisdiction codes, itis difficult to switch to another."  Yikes!
    So I'm looking for anyone who has "been ther done that" or who may have information I can use as I begin laying out a plan to do just that.
    Any advice or suggestions are very welcome.
    Thanks
    Laurie

    Hi,
    Please check the following:
    1. SPRO--->Financial Accounting --> Financial Accounting Global Settings --> Tax on Sales / Purchases -->
    Basic Settings -- > Assign Country to Calculation Procedure
    2. SPRO--> Financial Accounting --> Financial Accounting Global Settings --> Tax on Sales / Purchases --> Calculation --> Define Tax Codes for Sales and Purchases
    3. SPRO-->Financial Accounting --> Financial Accounting Global Settings --> Tax on Sales / Purchases --> Calculation --> Assign Company Code to Document date for Tax determination
    4. SPRO--> Financial Accounting --> Financial Accounting Global Settings --> Tax on Sales / Purchases --> Posting --> Define Tax accounts
    I doubt more on Tcode:FV11.
    hope its useful.
    Reward points if useful. Revert back with the error message and number if any other issue.
    thanks..

Maybe you are looking for

  • Final Cut Pro Export To You Tube blurry

    Hello there I have just finished editing an HD video using final cut pro. I output as a mater file and it looks great! Crystal clear! I then tried to upload to YouTube, the 360 version (lowest quality) is very blurred but the HD version is crystal cl

  • Hidden Field Value

    I want to import a value from a visible field to a hidden field. The data will be sent to a mySQL DB via php. I've tried changing the php script to obtain the results I want unsuccessfully. A hidden field should also do the trick but I'm not sure how

  • Share to Facebook is broken

    Hi! I noticed that I can't share to Facebook anymore. And I can't update my twitter or Facebook status from Notification Center in Mountain Lion. When I click to share buttons nothing happens. How Can I fix it?

  • Upgrade or not?

    I have the snow leopard program on my mac book pro 10.6.8. Should i upgrade to yosemite or to another package?

  • Illustrator CS3

    Hi I have a user at my company, Illustrator cs3 opens fine, but if file new or file open and select a file is done, the app completely crashes and closes down, have tried uninstalling then re-installing + installing the updates from adobe site and st