Update using the Select statement

I have a requirement of the main table was updated. Here is an example
Example (a) works in PL SQL but does not work in Forms6i.
Example (b) works in PLSQL so in Forms 6i.

I need work example (a) in forms 6i. What is the solution


one)
UPDATE fman_validation_master SET TOT_HRS = TOT_HRS +.
(SELECT SUM (FAV. H TOT_HRS)
OF FMAN_ACTQTY_VALIDATION FAV
WHERE fman_validation_master. = PROJECT: CONTROL. PROJECT AND
fman_validation_master. PROJECT = fav. PROJECT AND
fman_validation_master. ACTIVITY_CODE = FAV. ACTIVITY_CODE
FAV GROUP. PROJECT, FAV. ACTIVITY_CODE
) where of the = project: CONTROL. PROJECT;


(b)
UPDATE fman_validation_master SET TOT_HRS =
(SELECT SUM (FAV. H TOT_HRS)
OF FMAN_ACTQTY_VALIDATION FAV
WHERE fman_validation_master. = PROJECT: CONTROL. PROJECT AND
fman_validation_master. PROJECT = fav. PROJECT AND
fman_validation_master. ACTIVITY_CODE = FAV. ACTIVITY_CODE
FAV GROUP. PROJECT, FAV. ACTIVITY_CODE
) where of the = project: CONTROL. PROJECT;

Hello

According to Oracle 8.1, you can say:

UPDATE  table_x
SET     column_a = exp;

where exp is any expression, or

UPDATE  table_x
SET     column_a = (ssq);

where ssq is now called a scalar subquery. Oracle 8.1 sometimes allowed scalar subqueries in places where the documentation did not say that they were allowed. The first statement is an example, when you use

tot_hrs + (ssq)

as an expression. It works in SQL * Plus and also in PL/SQL, but (apparently) not in the forms.

Re-write your UPDATE statement so that the scalar subquery appears in itself to the right of the sign =, like this:

UPDATE     fman_validation_master
SET     tot_hrs =
     (
     SELECT     fman_validation_master.tot_hrs + SUM (fav.tot_hrs)
     FROM     fman_actqty_validation     fav
     WHERE     fman_validation_master.project          = fav.project
       AND     fman_validation_master.activity_code     = fav.activity_code
     )
WHERE     project = :control.project;

In other words, just move the original fman_validation_master.tot_hrs (to which you add the SUM) of the main request in the subquery.

Tags: Database

Similar Questions

  • How to pass parameter in the function using the select statement?

    Hello

    I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?

    For example,.
    Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.

    but

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.

    Thank you for trying to help him. Thank you.

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">

    Try like this

    select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')
    

    Just make sure that your subquery returns only 1 row.

  • How to use the select statement in loop for

    Hi all

    My question is can I use a select statement in for loop like as follows.

    for the key in the selection of one_table key.

    When I use this am getting an error as found select invalid I ID

    How to select a statement use in loop for

    Please suggest me.

    Thank you
    Sree

    Hello

    You can use code below

    For key in (select button from table_a)
    loop
    If key.key = 1 then
    -insert statement
    on the other
    -Select statement
    end loop;

    Thank you
    Naveen.

  • Insert and update by the select statement

    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.

    Florian wrote:
    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.
    >

    How can I insert and update in a table of database oracle 10g via a select statement. do not merge.

    Do you mean by using subqueries?

    Something like

    insert into whatever
      ...select statement
    
     update whatever
        set (column, column) = (select column, column ...)
    

    There is a lot of information on this topic in the online documentation

  • How to display the data type long using the select statement

    Hai All

    I have to select the text of a view. But the text is declared as long and I need to see full view

    When I use this

    Select the text in all_views where view_name = "DAILY_ATTEND_VIEW";

    I have got only half of a select statement

    Concerning

    Srikkanth.M

    Hello

    SQL> SET LONG 100000
    SQL> select text from user_views
      2   where view_name='MVIEW';
    
    TEXT
    ------------------------------------------
    select e.empno,e.deptno,d.dname
    from emp@sdblink e,dept@sdblink d
    where e.deptno=d.deptno
    

    But it is limited to sql alone. If you use the double click TOAD on the text column in the grid will show you the entire SQL views.
    Unfortunately, there is limitation to consider,
    The largest value that you return from the function would be 32 k (RETURN VARCHAR2), both.

    Twinkle

  • Insert a variable + string using the select statement with cfquery

    I'm doing an insertion by a select statement where the insert for one of the fields should be a combination of a vaule comes from the selection and concatenated with a string of text. Is this possible and if what the correct syntax so? Here is an example of what I'm trying, but does not.

    < name cfquery = "createnote" datasource = "#application.datasource #" >
    INSERT INTO gtbl_notes (notedate, strCustomerID, notetype, note, notecreatedby)
    SELECT "#currentdate #", strCustomerID, "miscellaneous", "#gtbl_people.email # DELETED because of HARD BOUNCE ', 'Bounce Routine.
    OF gtbl_people, gtbl_bounces
    WHERE gtbl_bounces.email = gtbl_people.email AND gtbl_bounces.subscriber = 1 AND gtbl_bounces.status = 2

    < / cfquery >

    Any input would be greatly appreciated.

    Concatonation is possible with most, if not all of the databases.  The syntax is a specific software and you do not your specify.

  • Creating a table using the Select statement of the physical layer

    Hello

    I use 10G, and I have the sub query in my physical layer. I chose the type of Table as Select and gave the SQL below. When I say the number of lines of update updates lines 93, that is correct, but does not show me the columns, or when I say display data, it does not show me the data, please see if I'm doing something worng. Thanks for your time and your help.

    Select (select program_id, project, actvty_id, commitment_date, row_number() over (partition by order project by commitment_date desc) as rnk project, actvty_id, program_id, commitment_date)
    of project_detail) a
    where rnk = 1

    Yes, create columns individually and click view data, you'll be able to get data

  • Update using a function in the select statement

    Hello

    Is it possible to do the follwing.

    I tabele and a custom function, the custome service will update the column (amount) of the table based on the value of going through the function of the select statement.

    SELECT id, stock, where an id = get_update (id);

    Now


    Get_update function will return the same id I'm passing and update the column amount to a value in the
    table a.

    When I run the satament selection I have the updated data in the column amount in my first executtion, but if execute the same statement, again, I see the changes reflected. is it possible to get data updates to the first performance himself.

    the function is of type PRAGMA AUTONOMOUS_TRANSACTION

    Concerning

    Indeed a strange requirement and probably not the way to go in a production environment. But anyway is a way to achieve your goal

    SQL> create table a
    as
       select   12 id, 500 amount from dual
       union all
       select   13 id, 600 amount from dual
    /
    Table created.
    
    SQL> create or replace type a_typ as object (id number, amount number)
    /
    Type created.
    
    SQL> create or replace function get_id (pid number)
       return a_typ
    is
       pragma autonomous_transaction;
       l_a_typ   a_typ := a_typ (null, null);
    begin
          update   a
             set   amount = 800
           where   id = pid
       returning   id, amount      into   l_a_typ.id, l_a_typ.amount;
    
       commit;
    
       return l_a_typ;
    end get_id;
    /
    Function created.
    
    SQL> select   id, d.a_typ.amount amount
      from   a, (select get_id (13) a_typ from dual) d
     where   id = d.a_typ.id
    /
            ID     AMOUNT
    ---------- ----------
            13        800
    1 row selected.
    
  • Update a field using a select statement?

    Hello
    I guess it's pretty easy, but I do not understand.
    I have 2 tables REQUEST and NOBODY and I want to update

    UPDATE REQUEST SET SysKD = (SELECT DISTINCT PERSON. SysPERSON OF PERSON WHERE PERSON. SysVM = REQUEST. SysVK PER PERSON. SysVM > 0) WHERE REQUEST. SysLS IN (11,12).

    This book error "subquery returns multiple rows. I assume that due to the fact that I have more than one record in REQUEST which fullfills REQUEST. SysLS IN (11,12).
    NO ONE. SysVM > 0 is necessary because they are in PERSON and REQUEST with ANYONE. SysVM = 0 and REQUEST. SysVK = 0 (where does not REQUEST.) SysLS is 11 or 12, they all REQUEST. SysVK > 0).

    I have no idea how to get a single returnvalue out of the select statement.

    Thanks for help
    Concerning
    Carsten

    Hi CarstenDD,

    In the script you

    SELECT DISTINCT PERSON.SYSPERSON) FROM PERSON
      WHERE PERSON.SYSVM = ANTRAG.SYSVK
        AND PERSON.SYSVM > 0
    

    return of two or more lines, using subquery on implementation day you can use only the single row function.

    You can modify your script

    UPDATE ANTRAG SET SYSKD =
    (SELECT MAX(PERSON.SYSPERSON) FROM PERSON
      WHERE PERSON.SYSVM = ANTRAG.SYSVK
        AND PERSON.SYSVM > 0)
     WHERE ANTRAG.SysLS IN (11,12);
    

    then ty this please

  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

  • Why I can't use the procedure in the select statement

    Why I can't use the procedure in the select statement

    And you may not usa a SQL function if it has out parameters

    SQL> create function myfun(p1 in out number) return number is
      2  begin
      3  p1:=1;
      4  return 2;
      5  end;
      6  /
    
    SQL> select myfun(5) from dual;
    select myfun(5) from dual
           *
    ERRORE alla riga 1:
    ORA-06572: Function MYFUN has out arguments
    

    In fact, the problem is that an output parameter is passed 'ref' and not 'val '...

    Max

  • How to use the variable instead of the table name in the select statement of procedure

    I have a procedure with a select statement with dynamic from clause. How can I use instead of the name of the table variable.

    create or replace procedure scc_chemical_analysis
    is
    v_table_name varchar2 (100);
    Start

    declare
    cursor c1 is select * from v_table_name; -This is the variable name. How can I use it in the select statement.
    .
    .
    .
    .



    end;

    Hello

    something like that.

      1  declare
      2     vSQLString      VARCHAR2(32000);
      3  pTableName varchar2(1000):='EMP';
      4  BEGIN
      5     vSQLSTRING :=
      6  'SELECT ''x'' FROM ' || DBMS_ASSERT.sql_object_name(pTableName) || ' WHERE rownum<=1 ';
      7     EXECUTE IMMEDIATE vSQLSTRING;
      8* END;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
  • uniol all in the select statement

    Hi I have a situation where I have to return the value based on the if statement, is it possible to put union all in the select statement

    My use case is

    IN the column State

    If column01 > 0 to condtion 't'

    IF column02 > 0 that the condition of 'Y '.

    Condition IF COLUMN03 > 0 THAN 'w '.

    If COLUMN04 > 0 that the condition of "Z".

    Select 't'

    TableName

    where column01 > 0

    Union of all the

    Select "y".

    TableName

    where column02 > 0

    Union of all the

    Select 'W '.

    TABLENAME

    WHERE COLUMN03 > 0

    I have what it takes to show value as it

    EmpName, condition, empno

    Jerry, T, 0158754585

    TOM, Y, 0054789568

    Am in oracle database 11 g 2

    Yes you can put all THE UNION here

    Select empname, 't' State, empno from tablename where column01 > 0

    Union of all the

    Select empname, 't' State, empno from tablename where column02 > 0

    Union of all the

    Select empname, condition of "W", empno FROM tablename WHERE COLUMN03 > 0

    Union of all the

    Select empname, condition of "Z", empno FROM tablename WHERE COLUMN04 > 0

    and if you are looking for how to remove duplicates because your line might have satisfied all the conditions and my happen 4 times in your result set, you just need to give them an order and filter it.

    For example, you want this

    If column01 > 0 to condtion 't'

    ELSE IF column02 > 0 that the condition of 'Y '.

    Another condition of THAN > 0 IF COLUMN03 'w '.

    otherwise if COLUMN04 > 0 that the condition of "Z".

    Select empname, condition, empno, in

    (

    Select a.*, row_number() over (partition by empno arrested by myorder) rn

    Of

    (

    Select empname, 't' State, empno, 1 myorder tablename where column01 > 0

    Union of all the

    Select empname, 't' State, empno, 2 myorder tablename where column02 > 0

    Union of all the

    Select empname, condition of "W", empno 3 myorder FROM tablename WHERE COLUMN03 > 0

    Union of all the

    Select empname, empno, condition of 'Z', 4 myorder FROM tablename WHERE COLUMN04 > 0

    ) a

    ) where rn = 1

  • I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?

    I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?

    11.1 and especially you have virtual column

    SQL> create table t
      2  (
      3     a number
      4   , b number
      5   , c generated always as (a+b) virtual
      6  );
    
    Table created.
    
    SQL> insert into t (a, b) values (1, 2);
    
    1 row created.
    
    SQL> select * from t;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    

    Before that, a front insert - trigger

    SQL> create table t
      2  (
      3     a number
      4   , b number
      5   , c number
      6  );
    
    Table created.
    
    SQL> create or replace trigger t_default before insert on t for each row
      2  begin
      3    :new.c := :new.a+:new.b;
      4  end;
      5  /
    
    Trigger created.
    
    SQL> insert into t (a, b) values (1, 2);
    
    1 row created.
    
    SQL> select * from t;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    
  • mixture of column type in the select statement

    Oracle 11g r2.

    tab_test (name varchar2, blob... photo)

    (1) select general use *.

    Stored procedure: open ref_cursor to some * of table_test...

    Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR);  Call.Execute ();

    It works very well.

    (2) enter the name of the column in the select such as

    Stored procedure: open ref_cursor to select name, photo table_test...

    Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR);  Call.Execute ();

    ERROR: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent data types: expected - got BLOB

    My question, if I specify the column names in the select statement, including the varchar2 and blob, how can I registerOutParameter (1, OracleTypes.CURSOR);?

    Thank you

    Scott

    PS The number of returned columns, in real case schenario, is a little, so I prefer to specify column names.

    Wrong forum. This forum is for questions of sql and pl/sql.

    Enter the question ANSWER and the repost in the JDBC forum

    https://community.oracle.com/community/developer/english/java/database_connectivity/java_database_connectivity _(jdbc)

    When repost you provide the necessary information to help you:

    1. information on the full version for Oracle DB

    2 version of the JDK

    3. the name and version of the JDBC jar file

    4. real code that demonstrates the problem

    You should also review the info re REF CURSOR in the JDBC Developer's Guide

    http://docs.Oracle.com/CD/E16655_01/Java.121/e17657/oraint.htm#i1058743

Maybe you are looking for