SQL UPDATE from PL/SQL triggered by button

I have a form with the normal buttons (create/save/delete) working.
For 2 of the fields I want to introduce a calculation on demand system. What I did is: created a button compute and associated some PL/SQL with it. The button submits as "compute" (something I made up) and has a branch that goes back to the same page. The button's PLSQL code is the following process (After Submit):
DECLARE
  rasaDom VARCHAR2(2);
  pRasaDom NUMBER;
BEGIN
tRace(:APP_SESSION, to_number(:P5_K));
domRace(:APP_SESSION, rasaDom, pRasaDom);
if (pRasaDom > 0 and pRasaDom <= 100) then
     :P5_RASADOM := rasaDom;
     :P5_PRASADOM := pRasaDom;
     update BOVIS.S_CIV_F SET RASADOM=rasaDom, PRASADOM=pRasaDom where K = to_number(:P5_K);
     commit;
     wwv_flow.debug('THEN! rasaDom=' || rasaDom || ' %=' || pRasaDom);
end if;
END;
The problem is the the above UPDATE simply does not work!
I should also mention that:
- the normal update process does not run (which is fine), because:
0.03: ...Do not run process "Apply MRU", process point=AFTER_SUBMIT, condition type=REQUEST_IN_CONDITION, when button pressed=
- my process displays the success message
- the "then" debug message shows just fine.
It looks like the is a big rollback somewhere (this is why I added the commit there). My guess is that APEX is doing an update to the old value. What am I doing wrong?
Thanks!
Edited by: Şerban on 12.02.2009 03:43

Hello:
update BOVIS.S_CIV_F SET RASADOM=rasaDom, PRASADOM=pRasaDom where K = to_number(:P5_K);Your update statement is updating the columns back to their current values !
If you want the rasaDom and prasadom updated to what is contained in p5_rasadom & p5_prasadom your code should be
     update BOVIS.S_CIV_F SET RASADOM=:P5_RASADOM , PRASADOM=:P5_PRASADOM  where K = to_number(:P5_K);
....Varad
Edited by: varad acharya on Feb 12, 2009 4:51 AM

Similar Messages

  • Error -While create a connection to Microsoft SQL Sever from Oracle SQL Dev

    Dear All,
    While I am trying to create a connection to Microsoft SQL Sever from Oracle SQL Developer. The following error: "Cannot connect to Microsoft SQL Server on localhost" has been occurred.
    Can anyone please guide me to solve this..
    Thanks in advance,
    Rider

    Hi,
    Issue not supported in sharepoint on-premise team.
    In addition, as this issue is related to Powerview, I suggest you create a new thread on for Powerview forum, more experts will assist you.
    https://social.technet.microsoft.com/Forums/en-US/home?forum=powerview
    Best Regards,
    Lisa Chen
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Running sql script from pl/sql

    Is there any standard way to run an external sql script from pl/sql
    I really appreciate any assistance.

    If you want, I did start writing a function reading and executing statements out of sql script with utl_file.
    can I issue this command in PL/SQL: EXECUTE IMMEDIATE '@filename.sql';
    the function could be extended for DDL, session setting, etc...
    Regards
    Laurent

  • Copying SQL Script from Oracle SQL Developer into Excel with formatting

    I need to copy a SQL Script into Excel in order to develop some VBA code. Is there any nice way that I can copy SQL Script from Oracle SQL Developer into Excel and retain its formatting? I am a stickler for having legible, readable SQL and like to have all my columns lined up and aliases lined up. When we used to use SQL Navigator, the tab formatting seemed to copy and paste just fine. Now that we have migrated to Oracle SQL Developer, the formatting seems to get all messed up.
    And suggestions are greatly appreciated and Thanks in advance for your review and am hopeful for an answer.
    Thanks.
    PSULionRP

    I suppose you want a real tabulator instead of spaces. You can configure this in the preferences (SQL Formatter - Oracle). You have to apply it then to your existing code (e.g. CTRL-F7), but new code should get it right from the start.
    Hope that helps,
    K.

  • Calling sql script from pl/sql block

    Hi
    I want to call a sql script from pl/sql block.
    like
    CREATE OR REPLACE procedure DataBaseExport(user_name in varchar2, pwd in varchar2)
    as
    begin
    execute immediate  '@ C:\Documents and Settings\umesh\emp.sql';
    end DataBaseExport;
    /

    Try something like this -
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host
         public static void executeCommand(String command)
         try {
                String[] finalCommand;
                   if (isWindows())
                        finalCommand = new String[4];
                        // Use the appropriate path for your windows version.
                        finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
                        //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
                        finalCommand[1] = "/y";
                        finalCommand[2] = "/c";
                        finalCommand[3] = command;
                   else
                        finalCommand = new String[3];
                        finalCommand[0] = "/bin/sh";
                        finalCommand[1] = "-c";
                        finalCommand[2] = command;
              final Process pr = Runtime.getRuntime().exec(finalCommand);
             pr.waitFor();
             new Thread(new Runnable()
                public void run()
                      BufferedReader br_in = null;
                   try
                        br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                        String buff = null;
                        while ((buff = br_in.readLine()) != null)
                                  System.out.println("Process out :" + buff);
                               try {Thread.sleep(100); } catch(Exception e) {}
                        br_in.close();
                   catch (IOException ioe)
                        System.out.println("Exception caught printing process output.");
                        ioe.printStackTrace();
                 finally
                     try {
                              br_in.close();
                          } catch (Exception ex) {}
         ).start();
         new Thread(new Runnable()
           public void run()
                BufferedReader br_err = null;
                try
                   br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
                   String buff = null;
                   while ((buff = br_err.readLine()) != null)
                        System.out.println("Process err :" + buff);
                        try
                           Thread.sleep(100);
                         } catch(Exception e) {}
                   br_err.close();
               catch (IOException ioe)
                   System.out.println("Exception caught printing process error.");
                   ioe.printStackTrace();
              finally
                  try
                          br_err.close();
                   catch (Exception ex) {}
          ).start();
         catch (Exception ex)
                  System.out.println(ex.getLocalizedMessage());
      public static boolean isWindows()
              if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
              return true;
              else
              return false;
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');And, finally,
    create or replace procedure call_sql_file(usr  in varchar2,
                                              pwd  in varchar2,
                                              host_str in varchar2)
    is
    begin
       host('sqlplus -s usr/pwd@host_str C:\UAX_Auto_Count.sql');
    exception
      when others then
        dbms_output.put_line(sqlerrm);
    end;Now, you can pass all the argument in order to execute that file.
    N.B.: Not Tested...
    Regards.
    Satyaki De.

  • How to call one .sql file from other .sql

    I am trying to call no of .sql files from one .sql file.
    But it gives me error in SQL*PLUS that unable to open file.
    Suggest me solution.
    Thanks
    Chanda

    Are the sql files in the current directories where sqlplus has been started ?
    If not, did you give the full path name for the called sql files when calling them from sqlplus ?
    Could you give us the complete sqlplus command that you use to call your files and the physical location of the called files with the exact error message ?

  • How to update or populate table in SQL server from PL/SQL

    Hello - I am starting in the fascinating world of PL/SQL. One of the first task I've been assigned is to rewrite a code (basically I was thinking of creating a package with proc included) on PL/SQL that updates and/or populates tables in MS SQL Server. How should I do this? Is it doable? I guess it is. How can I call tables from others databases from PL/SQL? How to establish the conecction? where? It should be included in the package?
    Any help will be appreciated
    Thanks,
    CC

    See PL\SQL and SQL Server

  • Table update from T-SQL question

    Ok, I have a T-SQL query that I'm trying to convert in Oracle SQL.
    Here is the T-SQL:
    Update E
    Set field1 = 'some text',
    field2 = NULL
    from table1 E
    Left join table2 A
    On e.fieldx = a.fieldx
    and e.fieldy = a.fieldy
    I think I'm close, but I'm not sure about the left join:
    Update table1 E
    set (field1, field2) = (
    select 'sometext', NULL
    from table2 A
    where a.fieldx = e.fieldx
    and a.fieldy = e.fieldy)
    What can I do to fix this?
    Thanks.

    The equivalent to your T-SQL Query would be:
    Update table1 E
    set (field1, field2) = (
    select 'sometext', NULL
    from table2 A
    where a.fieldx (+) = e.fieldx
    and a.fieldy (+) = e.fieldy);
    But since you don't do anything with the columns from table A and it is left joined, you can simply write:
    Update table1 E
    set field1 = 'sometext', field2 = NULL ;

  • SQL Injection from PL/SQL function.

    WE have some issues with a third party application which has vulnerabilities to SQL Injection, we have delivered a proof of concept to the developers demonstrating that it is possible to return additional (unrestricted) results to the front end, we have also found the following function in the back end. Assuming that its possible to call this function (which it is) and we can pass in whatever we want and that the user has exp_full_database and imp_full_database roles granted is there anything destructive possible with the following function?
    FUNCTION row_count (tab_name VARCHAR2) RETURN INTEGER AS
    rows INTEGER;
    BEGIN
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || tab_name INTO rows;
    RETURN rows;
    END;
    version 11.2.0.3, linux x86

    Simple example.
    SQL> --// table to hack in production - we are going to nuke it
    SQL> create table production_table1(
      2          some_data       number
      3  );
    Table created.
    SQL> --// production code typically executes with production rights (authid definer)
    SQL> create or replace function RowCount( tabName varchar2 ) return integer authid definer is
      2  --// code executes with the privs of the owner of the code
      3          cnt     integer;
      4  begin
      5          execute immediate 'SELECT COUNT(*) FROM ' || tabName into cnt;
      6          return( cnt );
      7  end;
      8  /
    Function created.
    SQL> --// expected use of production code
    SQL> var i number
    SQL> exec :i := RowCount( 'EMP' );
    PL/SQL procedure successfully completed.
    SQL> print i
             I
            14
    SQL>
    SQL> --// create the following in any schema that I, as hacker, have access to and the
    SQL> --// right to create a procedure - and using "access/security escalation", I'm going
    SQL> --// to get production code to run my code with production rights
    SQL>
    SQL> create or replace function InjectCode return integer authid current_user is
      2  --// code executes with the privs of the caller of the code
      3          pragma autonomous_transaction;
      4  begin
      5          execute immediate 'drop table PRODUCTION_TABLE1 purge';
      6          return( 0 );
      7  end;
      8  /
    Function created.
    SQL>
    SQL> --// production table is there
    SQL> select object_type, object_name from user_objects where object_name = 'PRODUCTION_TABLE1';
    OBJECT_TYPE                    OBJECT_NAME
    TABLE                          PRODUCTION_TABLE1
    SQL>
    SQL> --// inject my code into production code
    SQL> exec :i := RowCount( 'EMP where InjectCode() = 0' );
    PL/SQL procedure successfully completed.
    SQL> print :i
             I
            14
    SQL> --// production table is nuked
    SQL> select object_type, object_name from user_objects where object_name = 'PRODUCTION_TABLE1';
    no rows selected
    SQL>

  • Calling Sql-loader from PL/SQL

    What is the command(s) to call Sql-Loader from inside a PL/SQL procedure?
    Regards,
    Ahmad.

    I don't think it is possible ...

  • To Restrict SQL account from accessing Sql server via SSMS

    Hi All,
    We are planning to tighten the security of our SQL Server.
    In the initial phase, we want to restrict all the SQL accounts(except sa) from accessing SQL Server via SSMS
    Since the SQL passwords are used in the connection strings(plain text) of our .NET Applications, developers are able to see it and they are accessing SQL server through SSMS with the credentials in the connection string.
    The requirement is, SQL accounts should only be accessing the databases through .NET applications and not through any other applications like SSMS, SQLCMD...etc
    1) We tried "Logon Trigger", but later we came to know that there is security breach in it.
    2) Application Roles - Password is plain text, again back to square one.
    We are looking for an alternate. Please share some ideas.
    Thanks & Regards,
    K.P.Senthil Kumar

    The basic presumption here is that there is on way you can tie a connection to an application as such. There is app_name(), but since this is passed from the application, the application can call itself whatever you want.
    As long as it is only a matter of keeping business users out, you can solve the issue with some three-tiered solution. Either by having a true middle layer, or just having a web server, or the application running on Terminal Server or Citrix.
    But you want to keep the developers out who work with the code. That makes it difficult to lock them out of the middle layer.
    Then again, you say "our SQL Server" is that singular? Don't you have more than one SQL Server? One for developement, one for test and one for production? If you only want to keep the devs out from development, you have different usernames
    and password for different environments, and they are read from config files. The config files for production should be well-protected.
    By the way, only permitting sa from logging in from SSMS is bad idea. Rather, you should disable sa, and everyone should log in with their individual Windows account. And those who should perform system-administration tasks should be member of sysadmin.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Transferring 3 SQL databases from both SQL Express 2005 and Standard to a new physical server

    I am trying to figure out the best method for transferring SQL 2005 databases from 2 different physical servers to a new server running windows server 2008 64bit.
    I own a fully registered copy of Microsoft SQL 2005 32bit Standard Edition. However all of my SQL databases together are only 4GB in size thereby making 2008 SQL Express an option.
    Here is the breakdown of the servers:
    1) (Old Server1) Windows 2003 Server 32bit - SQL Express 2005 32bit
    2) (Old Server2) Windows 2003 Server 32bit - SQL Server 2005 32bit Standard
    3) (New Server) Windows 2008 Server 64bit - (Not sure which version to install)
    **The objective is to migrate 2 SQL databases from Old Server1 and 1 SQL database from Old Server 2 to the New Server. What version should I install on the new server??? Do I go with 2008 express or install the 2005 Standard Edition?
    Pending your response to which version to install, what are the correct steps to migrate (which I have never done before) the databases from both of these servers to the new server?
    I have researched this online and I think this particular situation is unique in that I am transferring from both SQL Express and Standard from 2 different physical servers to a 2008 server that is 64bit. I cannot find anything online that I feel confident
    in trying. Please help me, as I have this migration deadline of this weekend. Any help is appreciated. Thanks.

    Hello,
    You may choose between using backup/restore or using detach/attach methods to migrate the databases.
    https://msdn.microsoft.com/en-us/library/ms187858(v=sql.90).aspx
    You can transfer logins using the following article.
    http://support.microsoft.com/en-us/kb/918992
    To decide if you migrate to Express Edition or to another edition, please review the features supported by each edition. For instance, Express Edition does not support jobs (SQL Server Agent is not available).
    https://msdn.microsoft.com/en-us/library/cc645993(v=sql.100).aspx
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Invoke SQL Loader from PL/SQL Procedure

    hi
    Is there any way to invoke sqlloader from a PL/SQL Procedure ?
    Thanks
    Ashish

    'HOST' is not a PL/SQL command, it's a SQL*Plus command.
    If you think about it for a moment, being able to run an O.S. command, such as SQL*Loader, from within the database is pretty dangerous. I suspect this is why Oracle has no way of doing it. Otherwise, a you'd be able to execute an O.S. command as the user 'oracle' (on UNIX - probably 'SYSTEM' on NT, which is even worse!!!).
    All it takes is to change this :
    execute '/usr/oracle/bin/sqlldr user/password@DB file=input.txt' ;
    to this :
    execute 'rm -rf /usr/oracle' ;
    and you can start checking the job adverts...

  • How to call SQL script from PL/SQL block

    Hi All,
    I have a pl/sql block from which i need to call a *.sql script file.
    Please tell me that how can i do this?
    Thanks and Regards.

    > Though just for knowledge sake, would you please tell if there is a way
    to call a sql script from a pl/sql block.
    This question stems usually from a confusion about client-server and which is which in Oracle.
    SQL*Plus is a client. PL/SQL is a server side language. SQL is a server side language.
    When entering either one of these two languages in SQL*Plus (or TOAD, SQL-Developer, etc), the content is shipped to an Oracle server process, is parsed there, and is executed there.
    The Oracle server process servicing the client can accept a single SQL statement or PL/SQL block at a time.
    It cannot accept a block of SQL statements delimited with a semicolon. That is a client concept where the client will read each delimited statement and send that, one after the other (in synchronous call mode) to the Oracle server for execution.
    The Oracle server does not have a "script parser". It understands SQL. It understands PL/SQL. And that is what it expects from the client.
    Whether the client supports the SET command, the HOST command, SPOOL command, ability to run scripts, and so... have no bearing on what the server itself is capable of doing. The server does not care what feature set the client has. It is tasked with servicing the client via SQL and PL/SQL.
    It is not tasked to support or emulate client features like running SQL scripts.
    Nor confuse PL/SQL with the very limited command set of SQL*Plus. The two has nothing in common. And just as PL/SQL cannot understand C# or Delphi commands, it cannot understand SQL*Plus commands.

  • OBIEE Dashboard:- how to trigger a sql update from obiee dashboard?

    I want to trigger an update database query from a click in obiee dashboard.What is the best way to do it
    Edited by: Tataji vijjapu on Aug 7, 2012 11:20 PM

    Check WriteBack functionality
    http://gerardnico.com/wiki/dat/obiee/write_back
    Hope this helps

Maybe you are looking for