Executing SQL From A Forms Procedure

I am looking to execute a composed SQL command (ALTER USER ***** IDENTIFIED BY ****). The old execute immediate command in forms 5 would be the one I would have used, does any know the Forms 6i equivalent.
Regards
Stephen

Hi John,
What I was having a problem with is that the following code from a Forms 5 procedure isn't working with Forms 6i :
Procedure dropSynonyms ()
sql_stmt carchar2(2000);
BEGIN
sql_stmt := 'drop synonym RT_'| |rec.runtime_table_name;
execute immediate sql_stmt;
END;
The method of executing the sql_stmt sees to have changed with Forms 6i but the help documentation isn't clear on the new syntax.
Any help appreciated.
Regards
Stephen

Similar Messages

  • Executing sql from table with in plsql procedure

    I wonder if anyone can help.
    I have a table that stores sql statements. They are actually a set of rules that I want to apply to my application. My intention is to execute the statement in plsql.
    EG a sql statment held in the table might be:
    'select count(id) from item where item_id = ' || constants_pkg.c_test_item || ' and client_id = ' || client_id_in
    I am trying to call this from a plsql procedure, I’ve CUT OUT some of the procedure task_rec.rule holds the statement above. The procedure is failing “invalid SQL statement”, I think the client_id_in may not be evaluating as the variable, passed into the procedure and constants_pkg.c_test_item not being taken from the constants pkg.
    EG.
    PROCEDURE create_additional_info_list(
    client_id_in IN client.id%TYPE,
    IS
    result VARCHAR2(100);
    BEGIN
    EXECUTE IMMEDIATE
    task_rec.rule
    INTO result;
    END;
    If I was to do below the code would work ok. However I require the rule to come from the table.
    EXECUTE IMMEDIATE
    'select count(id) from item where item_id = ' || constants_pkg.c_test_item || ' and client_id = ' || client_id_in
    INTO result;
    Is there anyway constants_pkg.c_test_item and client_id_in can be evaluated as variables?

    Not that I've tried this but, if possible, change the SQL in the table to have bind variable; e.g.,
    'select count(id) from item where item_id = :1 and client_id = :2 ';
    Then in the procedure
    execute immediate task
    INTO result
    USING constants_pkg.c_test_item ,
    client_id_in ;

  • How to execute .sql file in Stored Procedure?

    Hi,
    I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
    This .sql file will have set of update statement. I need to pass value to this update statement.
    Kindly please help me.
    Regards,
    Irfan

    This is required as part of Data Migration where  i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
    How have you determined that it's "better" to have seperate scripts?  I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
    So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
    Question: Why do you have tables with different names that all need the same process doing to them?
    Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
    e.g.
    create procedure update_table(tbl_name varchar2) is
    begin
      execute immediate 'update '||tbl_name||' set lastupdate = null';
    end;
    As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer.  Please do take the time to read the FAQ and post appropriate details so people can help you.

  • How to run dynamic SQL from an ODI procedure step

    I am on ODI 11.1.1.6.4. From within an ODI IKM step I have no problem running a procedure step like the following which calls a pl/sql procedure to get SQL text then later runs that code. Is there anyway to do the same from within an ODI procedure? I've tried a couple of variations and can not seem to get the parsing levels to resolve within a procedure like they resolve from within a KM step.
    <@
    /* Setup Java variables */
    String out_SQL = "";
    try
    java.sql.Connection sourceConnection = odiRef.getJDBCConnection("SRC");
    String sqltxt = "{call set_sql(?)}";
    java.sql.CallableStatement pstmt = sourceConnection.prepareCall(sqltxt);
         try
         pstmt.registerOutParameter( 1, java.sql.Types.VARCHAR);
         pstmt.execute();
    out_SQL = pstmt.getString(1);
         catch(java.sql.SQLException ex)
              errMessage = ex.getMessage();
              errMessage = errMessage.replace("'","");
         finally
              pstmt.close();
    catch(java.lang.Exception e)
         errMessage = e.getMessage();
         errMessage = errMessage.replace("'","");
    @>
    BEGIN
    -- The SQL that I want to run
    <@
    out.println(out_SQL);
    @>
    -- Error handling
    <@ if ( out_SQL.length() ==0 ) { @>
         raise_application_error(-20101, '<@=errMessage@>');
    <@ } else { @>
         dbms_output.put_line('Successful.');
    <@ } @>     
    END;
    ------

    Please understand that I know that I can do this all within PL/SQL -- I am explicitly doing it the way I have outlined because I want to better understand the parsing levels/behavior within ODI procedures and I want to understand why KMs steps behave differently.
    Another observation -- putting this all within a pl/sql block prevents ODI from properly capturing insert/update/delete row counts like it would if it were running a SQL statement.
    So the question remains -- is there a way to run a dynamic SQL statement in an ODI procedure where the SQL statement is generated from within an Oracle procedure call and then run as SQL within an ODI procedure step? Best would be if there is an example of how this can be done.

  • Call an executable file from oracle forms 6i

    Hello ,
    i want to call a local .exe file from oracle forms 6i passing along a couple of parameters in the command line .
    Can anyone help me out here ?
    thanks
    C.
    Edited by: user539712 on Jan 21, 2011 11:55 AM
    Edited by: user539712 on Jan 21, 2011 11:55 AM

    that worked...now i am facing a different issue now which i didnt have without the start command . i am calling iexplorer.exe but i am passing a long a url in the command line . the 2nd parameter in the url is not working so when i do :
    "start c:\progra~1\intern~1\iexplore.exe" http://localhost/hello.jsp&a=ddd&b=333
    the &b=333 is not passed (some issue with the & character i am guessing). Would you know a workaround ?
    thanks

  • How to execute a statement in forms procedure like SQL EXECUTE IMMEDIATE

    Hi to all,
    In a form I have created this procedure:
    PROCEDURE insert_rows (
    tbName IN VARCHAR2,
    list_of_fields IN VARCHAR2,
    origin_table IN VARCHAR2,
    wCondition IN VARCHAR2 DEFAULT NULL)
    IS
    where_clause VARCHAR2 (2000) := ' WHERE ' || wCondition ;
    table_to_fill VARCHAR2 (30);
    BEGIN
    -- Exist the table ?
    SELECT OBJECT_NAME INTO table_to_fill FROM USER_OBJECTS
    WHERE OBJECT_NAME = UPPER(origin_table) AND OBJECT_TYPE = 'TABLE' ;
    IF wCondition IS NULL THEN
    where_clause := NULL;
    END IF ;
    EXECUTE IMMEDIATE 'INSERT INTO ' || table_to_fill || ' SELECT ' || list_of_fields || ' FROM ' || origin_table || where_clause ;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    -- Here the Alert
    END;
    But, when I compile this error is displayed:
    Function not supported from client side application corresponding to SQL statement EXECUTE IMMEDIATE
    How can to correct this script for my form ?
    I hope in Your help.
    Best Regards
    Gaetano

    You have two options:
    1)To create this procedure in database
    2)Yo use the forms built-in FORMS_DDL instead of execute immediate , altering the one provided
    Sim

  • Solution to execute sql from mysql application logs

    We have some custom mysql application, which generate logs that are stored on common location on open linux box which has below format
    $ cat minor20100809.log
    20100809001^Aselect count(prod_id) from product_logs;
    20100809002^Aselect count(order_id) from order_logs;
    ID and the SQL statement with control A as seperater and daily 1000 logs files are generated
    Now we have one oracle DWH, where we import all the mysql data and we need to test these counts on daily basis.
    Could you please suggest a solution in oracle for this?
    at high level we need to follow below steps
    a) Import these logs in a table --> which is better way sqlldr, impdp, or plsql read file ?
    b) execute these sql statement one by one
    c) store the counts in log table on daily basis

    Hi,
    It is a simple two step process.
    Step 1. Convert your log files statements to meaningful oracle statements. like removing prefixes 20100809001^A from each line.
    This can be done in two ways.
    (a). Using OS editors OR
    (b). Following PL/SQL code...
    -- Connect as sysdba
    create or replace directory dir_tmp as '/tmp';                        -- If oracle server is on Unix
    create or replace directory dir_tmp as 'C:\your_folder';            -- If oracle server is on Windows
    -- Grant permission to your_schema
    grant read, write on directory dir_tmp to your_schema;    Removing prefixes using:
           SELECT regexp_replace (vNewLine, '([[:alnum:]]{1,})\^A', '\2')
             INTO vStmt
             FROM DUAL;
    CREATE OR REPLACE PROCEDURE convert_to_sql_stmts
    ( input_file     in varchar2,
      output_file   in varchar2
    AUTHID CURRENT_USER
    IS
        InFile   utl_file.file_type;
        OutFile  utl_file.file_type;
        vNewLine VARCHAR2(4000);
        vStmt    VARCHAR2(4000);
        i        PLS_INTEGER;
        j        PLS_INTEGER := 0;
        SeekFlag BOOLEAN := TRUE;
    BEGIN
      -- open a file to read
      InFile := utl_file.fopen(dir_tmp, input_file,'r');
      -- open a file to write
      OutFile := utl_file.fopen(dir_tmp, output_file, 'w');
      -- if the file to read was successfully opened
      IF utl_file.is_open(InFile) THEN
        -- loop through each line in the file
        LOOP
          BEGIN
            utl_file.get_line(InFile, vNewLine);
            i := utl_file.fgetpos(InFile);
            dbms_output.put_line(TO_CHAR(i));
            SELECT regexp_replace (vNewLine, '([[:alnum:]]{1,})\^A', '\2')
              INTO vStmt
              FROM DUAL;
            utl_file.put_line(OutFile, vStmt, FALSE);
            utl_file.fflush(OutFile);
            IF SeekFlag = TRUE THEN
              utl_file.fseek(InFile, NULL, -30);
              SeekFlag := FALSE;
            END IF;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              EXIT;
          END;
        END LOOP;
        COMMIT;
      END IF;
      utl_file.fclose(InFile);
      utl_file.fclose(OutFile);
    EXCEPTION
      WHEN OTHERS THEN
        RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
    END convert_to_sql_stmts;
    Step 2. Directly executing above output log file
    Use spool to generate the count....
        set termout off
        set feedback off
        set trimspool on
        set pagesize 0
        set timing OFF
        spool   count.log
        @new_file.log
        spool off;Hope this helps...

  • Help! Executing SQL from ASP

    This is my Code..
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.DbOpenDatabase(strDB, strID & "/" &
    strPASS, 0)
    OraDatabase.DbExecuteSQL("DELETE tmp_clean;")
    It then runs a SQL statement which populates the table
    tmp_clean. I don't really want to have to write a procedure to
    do this. It seems not to like the semi colon, but with out it
    it doesn't execute the SQL. Please Help.

    It's okay, I worked it out. I hadn't done a COMMIT from my SQL
    Plus session, so the table was still empty, and it musn't like
    that.

  • After executing sql from batch, its disconnecting

    Hello All,
    I have written a batch program to execute a pl/sql procedure. But after execution, it disconnects.
    But i want to continue in the same session
    echo exec tracer.trace_pck.start_('alter session set sql_trace=true') | sqlplus hr/hr
    Output:
    Press any key to Enable Tracing
    SQL*Plus: Release 11.2.0.2.0 Production on Thu Oct 10 15:59:56 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL>
    PL/SQL procedure successfully completed.
    SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 -
    Production
    Trace Enabled Successfully. Press any key to input you sql

    If you are using a batch file I assume you are using the windows OS.
    Essentially what you need to do is to call a sql file from the batch file and then get the sql file to call all the other files.
    Batchfile test.bat  calls sql file test.sql
    sqlplus  <username>/password @test.sql
    test.sql calls test1.sql and test2.sql and then exits
    @test1.sql;
    @test2.sql;
    exit;
    test1.sql shows the current sid, and serial# fro our session and our filename
    select 'test1',sid,serial# from v$session
    where audsid=userenv('sessionid');
    test2.sql shows the current sid, and serial# for our session and our filename
    select 'test2',sid,serial# from v$session
    where audsid=userenv('sessionid');
    When you run this you get t output similar to the following: (Your SID and Serial# will be different )
    'TEST        SID    SERIAL#
    test1        771         97
    'TEST        SID    SERIAL#
    test2        771         97
    This shows that two separate sql files were called but are still in the same session

  • EXECUTE sql file in an procedure,just like sql prompt.

    Hi,
    I am using ORACLE 11g on an AIX box.
    Just to explain first :- Assume we have an .sql file in which i have 20 DML statements. Like 10 inserts,5 updates and 5 deletes. Now if i want to run this file in any particular DB , the best thing for one file i can do is .. simply go to the prompt i.e. SQL> on that DB and run that file :-
    SQL>@/oracle/scripts/metadata_update.sql
    just this will execute the whole file. Also here i can spool and keep the log of execution.
    Now i want the same functionality but this time their are many files and and i have to run them on different DB's.
    Can anyone suggest me some code in which if i pass the filename and the DB's name .. it should execute in that DB and create a log file in the same directory as the sql file.
    Something like procedure, which will take file name and DB name as parameter
    and then we will read file using UTL_FILE
    and then go to the destination DB with the help of TNSENTRIES we have.
    execute it and store the log for the same.
    Please suggest some sample code or ideas.
    thanks in advance.

    VIRU wrote:
    Our team gets those scripts on regular basis. We need to apply them on different DB's around 4 of them.
    So i wanted a utility by which i can apply it from one procedure.PL/SQL is wrong tool for this job.
    When your only tool is a hammer, all problems are viewed as nails.
    While a hammer is a GREAT tool, it is suboptimal to divide 1 board into 2 pieces
    sqlplus user/pass@remote1 @new_script.sql
    sqlplus user/pass@remote2 @new_script.sql
    sqlplus user/pass@remote3 @new_script.sql
    sqlplus user/pass@remote4 @new_script.sql

  • How to execute sql from table

    For a migration I have created a sql script that puts the full statement to be executed in a specific table column
    I'm now looking for a way how to execute those statements.
    Table structure like: oldName, newName, sqlStatement, id, otherField, otherField2
    Instead of the full statement(sqlStatement) it would also be possible to use the oldName, newName and id field if that simplifies the problem.
    The reason for building the statement and running that one is a) to validate upfront b) a self join is applied to the query result table to prevent some items for update.
    The initial idea was to take the sql statements and execute them as a sql script but that process is pretty slow.

    user2833655 wrote:
    For a migration I have created a sql script that puts the full statement to be executed in a specific table column
    I'm now looking for a way how to execute those statements.That is wrong, tables are for data not executable code
    Re: ref cursor - result set not known
    http://en.wikipedia.org/wiki/Data_%28computing%29
    >
    Data is often distinguished from programs. A program is a sequence of instructions that detail a task for the computer to perform. In this sense, data is thus everything that is not program code.
    >
    user2833655 wrote:
    The initial idea was to take the sql statements and execute them as a sql script but that process is pretty slow.This alternative will just make it difficult, complicated and unreliable as well.

  • Urg:Executing SQL From Java App using Jdbc Driver

    Hi
    I am using JDBC Driver version 9.0.1.1.0.
    I am running this in Thin Client Mode
    My Code Snippet Looks Like This:=
    ==========================================================
    String url = "jdbc:oracle:thin:@localhost:1521:VpDb";
    String userName = "scott";
    String password = "tiger";
    Connection conn = null ;
    Statement st = null ;
    ResultSet rs = null ;
    String categoryCode="ABC";
    try
    conn = DriverManager.getConnection (url, userName, password);
    st = conn.createStatement ();
    String sqlStatement = "Select Count(*) From News Where CategoryCode=" +"\'" + categoryCode + "\'" + ";";
    System.out.println(sqlStatement);
    rs = st.executeQuery ( sqlStatement );
    if( rs.next() )
    System.out.println("Headline Exists");
    else
    System.out.println("No Headline Exists");
    catch (SQLException e )
    System.out.println();
    System.out.println (" SQL ERROR IN IS_NEWS_EMPTY: " + e) ;
    =========================================================
    I have added the classes12.zip and nls_charset12.zip in the classpath.
    Now when i run this it gives me an error saying the following error message:-
    SQL ERROR IN IS_NEWS_EMPTY: java.sql.SQLException: ORA-00911: invalid character
    Can anyone help me with this as to whats going wrong because the exact equivalent of my sqlStamenet runs on SQL command line but not from java code.Why??
    Any Help appreciated
    Thanks
    Mum

    I think it is complaining about the ";" that you add at the end of your string. You don't need to add that to the query.

  • How do you extract SQL from Oracle Forms and Reports files?

    I am developing an "as is" data model for a government client for a 14 year old system that has three databases, 20 schemas, over 1500 tables, and over 23,000 columns. Needless to say, I do not plan to perform a manual mapping of data to screens and reports.
    Most of the system has been developed in Oracle Forms and Reports. I am trying to map the live tables and columns to forms and reports.
    The process here has been to save the forms and reports files as .fmb and .rdf files. The client does not have an available copy of Oracle Designer, which I understand could be used to extract the SQL.
    Is there a utility somewhere that can parse the .fmb and .rdf files to extract the SQL?
    Thanks,
    Jim Gearing

    Jim,
    I don't know of any utility that will do this. You can convert and save each fmb as a fmt so you can view/search the contents , but I don't recommend that approach.
    On the other hand, you download a copy of Oracle Designer:
    http://www.oracle.com/technology/software/index.html
    It usually is included with Oracle Forms and Reports.

  • Querying data from External Source from within FORMS

    I have a form that is built based on Oracle tables.
    I need to execute a Select statement via ODBC from within Forms procedures. This is going to a SQL Server DB to get some information for validation purpose.
    I do not need to bring this in to a Forms Block.
    Any thoughts?
    Thanks

    Hi
    What version of forms do you use? If you use forms 6i, take a look at the EXEC_SQL package. You can access oracle databases and ODBC databases (using OCA) independently of the main database connection -- well, I never tried but that is what the documentation says.
    I am not sure about version 9i... the package is there, but I could not find anything in the help about it (what is not a good sign...)
    hth
    Luis Cabral

  • Calling sql script in plsql procedure

    Hello,
    I have a sql script named mytest.sql and i want to execute this from a stored procedure.
    following is the contents of this script
    spool d:\mytestsql.txt
    select * from tab;
    spool off
    Actually i want my sql script to run daily to export some tables data.
    I can execute this script from a sql prompt but i want to run it from enterprise manager.
    I am using oracle 10gR2 on windows2000 system.
    Any idea about scheduling the sql script to run automatically??
    How to execute this sql script from a plsql procedure??
    Thanks

    Hi all,
    Thanks for all the replies. I have found the solution with external procedures.
    Following is the complete step by step guide.
    1. Create the OSCommand Java Class using the following statement:
    connect as any user:
    create or replace and compile java source named oscommand as
    import java.io.*;
    public class OSCommand{
    public static String Run(String Command){
    try{
    Runtime.getRuntime().exec(Command);
    return("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    2. Create the following Wrapper Function using the following statement:
    CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
    RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'OSCommand.Run(java.lang.String) return int';
    3. connect as sys
    Execute dbms_java.grant_permission( 'FKHALID','SYS:java.io.FilePermission', '<<ALL FILES>>','execute');
    execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '*' );
    execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'readFileDescriptor', '*' );
    commit;
    note: here fkhalid is the oracle user.
    connect as fkhalid user:
    Declare
    expdp_cmd Varchar2(2000);
    Begin
    expdp_cmd := OSCommand_Run('cmd /c sqlplus fkhalid@mtcedwt/pwd @d:\ORA_DUMPS\mydbexp.sql');
    DBMS_OUTPUT.Put_Line(expdp_cmd);
    End;
    In Unix
    Set Serverout On
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/home/test/myoscommand.sh')
    DBMS_OUTPUT.Put_Line(x);
    End;
    I will check the dbms_scheduler also and will let you know the results.
    Thanks

Maybe you are looking for

  • How to give a relative path from a button in the master page header?

    so I have this code in the header of my Master page in RoboHelp: <input type="image" value="View graphics legend" onclick="window.location.href='Graphics_legend.htm'" src="Images\graphic legend.png" name="image1" title="View graphics legend" style="w

  • Lead to Oppy Method call or Workflow

    Hi All, When shall we use the option of method call and workflow for automatic creation of Oppt from lead. We can use method call and also workflow for  it. but whats the pros and cons of these two methods.when do we use what. Sanjana

  • CVI IDE: Is it possible to see list of functions for faster navigation?

    Colleagues, Very simple question about CVI IDE. Is it possible to see whole list of functions for fast and convenient navigation, like in Micro$oft Visual Studio: When I have C code with more than 20-30 functions and 2000+ lines - its a very inconven

  • I am new to Workflow!!!

    Hi, Any documentation related to workflow please email me [email protected] It will be greatly appreciated.and info for workflow certification. Thanks in advance points will be rewarded. Aysam.

  • Mass role import

    Hi guys, i have a problem with mass role import. When i want to do a mass role import the system warns me with the following error: Failed processing; role not imported and the log does not help. Thanks in advance!!! Kind regards!!! Isaac