Multiple select, update statements in one script

Hi All,
I wrote a script that has multiple select, update statements. When I ran the script in the sqlplus, I got error on second update statement:
ORA-00936: missing expression
Have any idea what was the problem?
Thanks
OF

the following are my codes:
set termout off
set showmode off
set timing off
--set echo off
set echo on
set heading off
set verify off
set pagesize 0
-- Parameters
-- Transaction Date
-- Show dates this format by default
ALTER SESSION SET nls_date_format='DD-MON-YYYY';
-- Define bind variables to hold report parameters
var v_date varchar2(13)
var v__run_date varchar2(13)
begin
-- Get job sumission variable for Transaction Date
select gjbprun_value into :v_date
from general.gjbprun
where gjbprun_job = '&&1'
and gjbprun_one_up_no = &&2
AND gjbprun_number = '01' ;
End;
spool fwuodoc_&&2
select FABINVH_CODE, FABINVH_POHD_CODE,
FABINVH_INVOICE_DATE, FABINVH_PMT_DUE_DATE, FABINVH_TRANS_DATE,
fabinvh_complete_ind
from fabinvh
where fabinvh_complete_ind='R'
and trunc(FABINVH_TRANS_DATE) < trunc(to_date('&&dd_mon_yyyy','dd-mon-yyyy'))
update fabinvh set
fabinvh_trans_date=to_date('&&dd_mon_yyyy','dd-mon-yyyy')
where fabinvh_complete_ind='R'
and trunc(FABINVH_TRANS_DATE) < trunc(to_date('&&dd_mon_yyyy','dd-mon-yyyy'))
update fpbreqh set
fpbreqh_trans_date=to_date('&&dd_mon_yyyy','dd-mon-yyyy')
where fpbreqh_complete_ind='Y'
and nvl(fpbreqh_appr_ind,'x')<>'Y'
spool off
exit

Similar Messages

  • Multiple Oracle SQL statements in one Add Command

    I am creating a report that needs a bunch of processing(SQL DDL statements) before the final select statement is generated for the report.
    I am connecting to Oracle database however Crystal Report only allows me to give one SQL statement in one Add Command.
    Is there a way to give multiple statements in one "Add Command" for the report ?
    Thanks.

    you can add more than one "Add Command" in the same report, and you can also treat them as views or table, so you can link them to each others and so on
    good luck

  • Execution time difference between SELECT & UPDATE statement in JDBC Sender.

    Hi Experts,
    In my scenario, I have used the JDBC Sender Adapter with the SELECT and UPDATE statement.
    Now the problem is in between the execution of Select and update statement, few more entries are coming in the same DB Table.
    So result of this is updation take place for those entries which are not even picked up by the select statement.
    Can we avoid this execution time difference between the SELECT & UPDATE statemet on JDBC Sender side???
    Thanks & Regards
    Jagesh

    Hi
    Use serializable option in additional parameters, now all new entries would also be updated.

  • Inserting multiple selection from checkbox into one column of the database

    Hi,
    How to insert multiple selection values from checkbox into one column of the database.
    Anyone can u help me
    Thanx

    hi
    try to use request.getParameterValues("fieldname")

  • Multiple Alter Table Statements in one batch

    Hi Team,
    We have in one of our upcoming release two columns being added to a table that has over 20 million records and 14 indexes.
    We needed to add two columns to the table both not null (bit). Because it was taking a while to add the columns, we thought that putting these two alter statements in one batch would speed up the operation significantly but to my surprise it did not.
    Conclusion from my test: individual alter statements or batch alter statements take the same time
    Here are me test and results - table Order1 and Order2 are exactly the same structure and data.
    Test case 1:
    ===================
    ALTER TABLE Order1
    ADD OR_N BIT DEFAULT 0 NOT NULL
    go
    ALTER TABLE AccountTradeConfirmation_Alter1
    ADD OR_S BIT DEFAULT 0 NOT NULL
    Go
    Elapsed Time: 2 hrs
                 Mar 18 2015 5:56PM
    (1 row affected)
    Non-clustered index (index id = 3) is being rebuilt.
    Non-clustered index (index id = 4) is being rebuilt.
    Non-clustered index (index id = 5) is being rebuilt.
    Non-clustered index (index id = 6) is being rebuilt.
    Non-clustered index (index id = 7) is being rebuilt.
    Non-clustered index (index id = 8) is being rebuilt.
    Non-clustered index (index id = 9) is being rebuilt.
    Non-clustered index (index id = 10) is being rebuilt.
    Non-clustered index (index id = 11) is being rebuilt.
    Non-clustered index (index id = 12) is being rebuilt.
    Non-clustered index (index id = 13) is being rebuilt.
    Non-clustered index (index id = 14) is being rebuilt.
    (21777920 rows affected)
    Non-clustered index (index id = 3) is being rebuilt.
    Non-clustered index (index id = 4) is being rebuilt.
    Non-clustered index (index id = 5) is being rebuilt.
    Non-clustered index (index id = 6) is being rebuilt.
    Non-clustered index (index id = 7) is being rebuilt.
    Non-clustered index (index id = 8) is being rebuilt.
    Non-clustered index (index id = 9) is being rebuilt.
    Non-clustered index (index id = 10) is being rebuilt.
    Non-clustered index (index id = 11) is being rebuilt.
    Non-clustered index (index id = 12) is being rebuilt.
    Non-clustered index (index id = 13) is being rebuilt.
    Non-clustered index (index id = 14) is being rebuilt.
    (21777920 rows affected)
                 Mar 18 2015 7:52PM
    Test case 2:
    ===================
    ALTER TABLE Order2
    ADD OR_N BIT DEFAULT 0 NOT NULL, OR_S BIT DEFAULT 0 NOT NULL
    go
    2 hrs elapsed time
                 Mar 20 2015 11:10AM
    (1 row affected)
    Non-clustered index (index id = 3) is being rebuilt.
    Non-clustered index (index id = 4) is being rebuilt.
    Non-clustered index (index id = 5) is being rebuilt.
    Non-clustered index (index id = 6) is being rebuilt.
    Non-clustered index (index id = 7) is being rebuilt.
    Non-clustered index (index id = 8) is being rebuilt.
    Non-clustered index (index id = 9) is being rebuilt.
    Non-clustered index (index id = 10) is being rebuilt.
    Non-clustered index (index id = 11) is being rebuilt.
    Non-clustered index (index id = 12) is being rebuilt.
    Non-clustered index (index id = 13) is being rebuilt.
    Non-clustered index (index id = 14) is being rebuilt.
    (21777920 rows affected)
                 Mar 20 2015 1:12PM

    Hi Kiran,
    I have read your response a few times and I was not able to understand your angle. I assume based on the results of my test that Sybase does the following in processing the alter statements
    ALTER TABLE Order2
    ADD OR_N BIT DEFAULT 0 NOT NULL, OR_S BIT DEFAULT 0 NOT NULL
    go
    process alter ADD OR_N BIT
    -- > make copy of table
    ---> alter original table
    --> put data back in
    process alterOR_S BIT
    -- > make copy of table
    ---> alter original table
    --> put data back in
    rebuild index
    my expectation was that it would make a copy of the table only once and process the two alter statements. Also when doing the alter separately (test1) it rebuilt the index twice, however using the batch the index was rebuilt once (at least only one message displayed).
    Regards.

  • Inserting multiple selection from checkbox in to one column of the database

    Hi,
    how to insert multiple selection from checkbox into one column of the database.(I select array of values from checkbox ,then how to insert tat array of values iinto single column name).
    Anyone can u reply me
    Thanx

    hhhmmm.... is this what you mean?
    lets say you hava a checkbox1 with values value1, value2, value3 and you selected all there of them? then you want then to be stored in the database in one column?
    now the question is:
    Is it going to be one column one row?
    datafield
    value1,value2,value3
    Or one column multiple row?
    datafield
    value1
    value2
    value3
    Which is it?

  • Update statement in a procedure

    update pol_notification a
    set obj_id = v_presv_client_id
    where a.obj_id=v_client_id and a.obj_type='client' ;
    update pol_notification a
    set obj_id = v_address_id
    where a.obj_id=v_address_id and a.obj_type='address' ;
    I am using these two update statements in one procedure but the tables are not being updated.
    Any reason for that. Am i using the right statements?

    Here is the procedure.....
    CREATE OR REPLACE PROCEDURE SP_LOAD_CLIDUPDATA( )
         BEGIN
    DECLARE v_client_id integer ;
    DECLARE v_presv_client_id integer ;
    DECLARE v_processed_client_id integer;
         DECLARE v_address_id integer;
    DECLARE V_NUMBER integer;
    DECLARE v_counter integer DEFAULT 0;
    DECLARE cur_update CURSOR FOR
    SELECT client_id,presv_client_id,nvl(processed_client_id,0),nvl(address_id,0)
    FROM cli_dup_data ;
    DECLARE cur_num CURSOR FOR
    SELECT count(*) FROM cli_dup_data ;
    open cur_num;
    fetch cur_num into V_NUMBER;
    close cur_num;
    OPEN cur_update;
    loop
    IF v_counter = V_NUMBER THEN
    end loop;
    END IF;
    FETCH cur_update INTO v_client_id,v_presv_client_id,v_processed_client_id,v_address_id;     
    if v_client_id = 0 then
    COMMIT; --Commit transactions at batch level only
    ELSE
    If v_processed_client_id <> v_client_id then -- client_id is already processed
                   update pol_notification a set obj_id = v_presv_client_id --Update client_id
         where a.obj_id=v_client_id and a.obj_type='client';
         update pol_notification a set obj_id = v_address_id -- Update address_id
         where a.obj_id=v_address_id and a.obj_type='address';
    update pol_notify_history b set obj_id=v_presv_client_id,
    client_seq_nbr_i = 1
    where b.obj_id = v_client_id and b.obj_type='client';
    update pol_notify_history b set obj_id = v_address_id
    where b.obj_id = v_client_id and b.obj_type = 'address';
    update pol_int_name set client_id = v_presv_client_id --Update client_id
         where client_id=v_client_id;
         update cli_dup_data set processed_client_id=v_client_id --Keep a record of updated client_id in processed_client_id
         where client_id=v_client_id;
    end if;
              END IF;
    set v_counter = v_counter+1;
    END loop ;
    CLOSE cur_update;

  • Doubt about UPDATE STAT COLUMN

    Hi,
    I have a doubt of when to execute update stat:
    i create this SQL to generate an SQL script to generate update stat for all my tables:
    select 'UPDATE STAT ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
    and created this SQL to generate an SQL script for update stat for all columns.
    select 'UPDATE STAT COLUMN(*) FOR ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
    my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
    thanks for any insight
    Clóvis

    > my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
    Hi Clovis,
    hmm... good question.
    There are a few things to know about the UPDATE STAT command here.
    1) It will always generate statistics for key or indexed columns.
    2) The optimizer won't be able to generate a better plan when there are column statistics for non-indexed columns present.
    3) The command will also collect column statistics for all columns that already have statistics.
    The direct effect of 3) is that by running your second command just once - all column statistics will always be collected.
    Since you can easily change the default sample size for your tables via
    ALTER TABLE SAMPLE SIZE 20 PERCENT
    I would say: drop your script and just use
    UPDATE STAT DBUSER.* ESTIMATE
    This single command would lead to the same statistics as your script does.
    And if you really, really want to leave out the JDBC tables - then just set their default sample size to 0 and they will be ignored by the UPDATE STAT command.
    regards,
    Lars

  • Re write Update statement

    Hi All,
    I need to re-write below update statement. existing one is taking long time to update. Please help me on that. thanks in advance
    UPDATE xxx a
    SET a.bb = 'NG',
    a.cc = '12'
    WHERE EXISTS (
    SELECT 1
    FROM dt , lm
    WHERE dt.ln_dt = (SELECT MAX (insert_date)
    FROM ccc
    WHERE source_system_id = 36)
    AND dt.id = 36
    AND dt.ln = a.ln
    AND lm.lnr = dt.ln
    AND NVL (lm.ind, 'XX') <> 'NG')
    AND (
    NOT EXISTS(
    SELECT 1
    FROM mt, lp
    WHERE mt.ln=a.ln
    AND lp.ln=a.ln
    AND a.dt IS NOT NULL
    AND mt.m_id = 1
    AND lp.p_date >= trunc(sysdate,'mon')
    AND EXISTS(
    SELECT 1
    FROM my_view p
    WHERE p.ln = a.ln
    AND p.pay_dt > TRUNC(ADD_MONTHS(SYSDATE, -3),'mon')
    AND p.past_due > 29)
    );

    You haven't posted anything we can use to help you.
    Please read these:
    When your query takes too long
    When your query takes too long ...
    How to Post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting

  • Sender JDBC: help to construct Update statement

    Hi,
    I need help in writing a update statement to DB2 database in sender JDBC adapter.
    The sender adapter picks up only few records say 10 at a time which match the Select query condition. So I would need to update only those selected "n" records and not all the records that match the Select query condition.
    Select looks like :
    Select * from <table> where <condition> fetch first <n> rows only.
    But it is not allowing the following update
    update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> fetch first <n> rows only)
    The above statement errors because DB2 does not allows u201CFetchu201D statement within the update sub query.
    Any pointers to a write update statement for n records is highly appreciatedu2026
    ~SaNvu2026

    Hi Santosh,
    In JDBC Sender Adapter provide the following select & update statements
    Select Statement:
    select * from <table> where <condition> AND ROWNUM<N (N==No.of Rows)
    Update Statement:
    update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> AND ROWNUM<N)
    (N==No.of Rows)
    And for the error you are facing is because of the server communication link failure between the two systems.
    Check the connections and try to stop & start communication channels once.
    Regards
    Venkat Rao .G

  • Multiple users and multiple select options

    Hi,
    First of all, let me congratulate Oracle HTML DB team for this great product! This is extremely powerful and useful.
    I have multiple selection item on the form to generate report for the selected multiple schools. I have two critical questions.
    1) Currently I am deleting all records from database tables for multiples selects and similarly selecting all records from these tables to populate dependent LOVs and so on. This is a major issue when multiple people use this application at the same time. I looked at couple of examples to create, delete and select records based on IDs (unique) and it is not clear to me if I need to create parameter/hidden params on the reports side or on the HTML DB side or .. how do they communicate etc. Could any one clarify this process of checking for unique IDs please.
    2) Is there any way to give an option to the user to treat multiple selected item as just one single and to treat them separate? For example, if we let the user count number of students at two schools, how can we let the user count two schools separate as well as both schools together? This should also further ask for the possible options separate for both schools separate if they were to run separate.
    This is very important for me and appreciate any help from you. Thanks in advance.

    Hi,
    Could any one point me in the right direction, please!
    Thanks,

  • How to return the result set of multiple select statements as one result set?

    Hi All,
    I have multiple select statements in my stored procedure that I want to return as one result set 
    for instance 
    select id from tableA
    union 
    select name from table b 
    but union will not work because the result sets datatypes are not identical so how to go about this ?
    Thanks

    You have to CAST or CONVERT (or implicitly convert) the columns to the same datatype.  You must find a datatype that both columns can be converted to without error.  In your example I'm guessing id is an int and name is a varchar or nvarchar. 
    Since you didn't convert the datatypes, SQL will use its data precedence rules and attempt to convert name to an int.  If any row contains a row that has a value in name that cannot be converted to an int, you will get an error.  The solution is
    to force SQL to convert the int to varchar.  So you want something like
    select cast(id as varchar(12)) from tableA
    union
    select name from tableb
    If the datatypes are something other that int or varchar, you must find a compatable datatype and then convert one (or both) of the columns to that datatype.
    Tom

  • Can we give multiple select statements in one function in PL/SQL

    Hi All,
    I am new to the PL/SQL. Can you please help me with the following problem.
    I am cretaing a function in which I have to extract some fields from three tables and to handle three tables I am first extracting the primary key from one table(acting as a foreign key for other table) in a variable declared in declare section, then I am selecting the required fields from the other table by giving that variable name in Where condition. My code is attached as well.
    e.g
    Create or Replace function <function name>(arguments)
    Return return type
    AS
    a1 a%TYPE;
    b_new b%TYPE;
    n fn%TYPE
    Select a into a1 from table1 where b like b_new;
    Select fn into n from table2 where id like a1;
    return a1,n; (can we pass record like this?)
    end;

    Left's first look at the approach you use.. 2 SQL statements that can be done using a single SQL statement.
    Actually it is not as bad as some other code posted here where people go and write complex PL/SQL code to do what could have been done using a single SQL statement.
    There are a couple of golden rules in Oracle development. One of these is to 'Maximise SQL and Minimise PL/SQL'.
    Why take a value from one SQL statement into PL/SQL and then use that value in a second SQL statement?
    Rather do this:
    select
    fn into n
    from table2
    where id like (Select a from table1 where b like b_new);Also keep in mind that in PL/SQL the above SQL construct is only able to fetch a single row - look at the bold above. The variable N can only hold a single value. If that SQL SELECT returns more than one value, how is variable N suppose to hold it?
    I suggest that you read [url http://www.oracle.com/pls/db102/to_toc?pathname=appdev.102%2Fb14261%2Ftoc.htm&remark=portal+%28Books%29]Oracle® Database PL/SQL User's Guide and Reference guide.

  • How do I pass multiple values from a text box to an update statement

    I hope this does not sound to lame. I am trying to update multiple values Like this:
    Code|| Computer Desc || Computer Price || Computer Name
    SEL1 || Apple macbook || 1564 || Apple Macbook Basic
    SEL2 || Dell 630 || 1470 || Dell Latitude
    I want to change all six values at once in one update statement based on the Code, I can't find a good tutorial/example to help me.
    Can anyone point me in the right direction?
    Thanks so much,
    Laura

    You can do conditional updates with decode or case statements e.g.
    SQL> create table t as
      2  select 'SEL1' as code, 'Apple macbook' as comp_desc, 1564 as comp_price, 'Apple Maxbook Basic' as comp_name from dual union
      3  select 'SEL2', 'Dell 630', 1470, 'Dell Latitude' from dual
      4  /
    Table created.
    SQL>
    SQL> update t
      2  set comp_desc = CASE code WHEN 'SEL1' THEN 'Test1' Else 'Test2' END,
      3      comp_price = CASE code WHEN 'SEL1' THEN 1234 Else 2345 END,
      4      comp_name = CASE code WHEN 'SEL1' THEN 'Test1 Name' Else 'Test2 Name' END
      5  /
    2 rows updated.
    SQL>
    SQL> select * from t
      2  /
    CODE COMP_DESC     COMP_PRICE COMP_NAME
    SEL1 Test1               1234 Test1 Name
    SEL2 Test2               2345 Test2 Name
    SQL>

  • How can i use multiple row subquery in update statement

    Hai All
    I using group function in my update statement.. and i need to update more rows so i need to use multiple row
    subquery pls tell me how to use multiple row subquery in update statement
    For example
    while i am using this like this i got an error
    update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
    barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
    Pls tell me how to use with example
    Thanks & regards
    Srikkanth.M

    Hai Man
    Thanks for ur response Let me clear what i need
    First step Fetch the records as text file and stores into table T1
    and the next step is i have seperated the text using substring and stores in different columns of a table
    There are two shifts 0815 to 1645 and 1200 and 2000
    Here I rep IN and O rep OUT
    Empno date time inout
    001 01-01-10 0815 I
    002 01-01-10 0815 I
    003 01-01-10 0818 I
    001 01-01-10 1100 0
    001 01-01-10 1130 I
    002 01-01-10 1145 0
    002 01-01-10 1215 I
    004 01-01-10 1200 I
    005 01-01-10 1215 I
    004 01-01-10 1315 O
    004 01-01-10 1345 I
    001 01-01-10 1645 0
    002 01-01-10 1715 0
    003 01-01-10 1718 0
    004 01-01-10 2010 0
    005 01-01-10 2015 0
    This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
    T2 contains like this
    Empno Intime Intrin Introut Outtime Date
    001 0815 1100 1130 1645 01-01-10
    002 0815 1145 1215 1715 01-01-10
    003 0818 1718 01-01-10
    004 1200 1315 1345 2010 01-01-10
    005 1215 2015 01-01-10
    This what i am trying to do man but i have little bit problems Pls give some solution with good example
    And my coding is
    declare
         emp_code varchar2(25);
    in_time varchar2(25);
    out_time varchar2(25);
    Cursor P1 is
    Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
    From temp_att
    group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
    ORDER BY enpno,pdate,ptime;
    begin
         for r2 in p1 loop
    declare
    bar_code varchar2(25);
    begin
    select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
    For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
    if r2.inout ='O' then
    update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
    end if;
    end loop;     
    exception
         when no_data_found then
         if r2.inout ='I' then
                   insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
         end if;
    end;
    end loop;
    commit;     
         end;
    Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
    and how can i use it in the update statement
    Thanks In Advance
    Srikkanth.M

Maybe you are looking for

  • Is there an easy way to find apps that will run on an ipod touch gen 2 with iOS 4.2.1?

    My grandson's ipod touch gen 4 was stolen so I picked up a used ipod touch gen 2 only to find out I can't upgrade beyond 4.2.1 iOS, so I am trying to find apps that run on that iOS. Enter an unfriendly App Store for those of us not used to using it!

  • CD-R, DVD Drive

    I have some footage on the mini-DVD's.......Do I need some sort of sleeve to play the small sized DVD's or should they just insert into the drive? I tried and it didn't seem to work. I thought I possibly lost the DVD in the drive but it popped out a

  • SQL Developer no more free ?

    I noticed a new functionality, schema compare in SQLD 1.5. One that is used by develoeprs in my company extensively out of Toad. To my surprise, it asked to confirm licence for Oracle Change Management Option. I am shocked!! Didn't SQL Developer star

  • Invoking rules from bpel.

    Im trying to create a decision service in bpel. However there is not much docs on how to accomplish this. Ive created a rule following chapter 4 of the users guide for business rules. However when i go to jdev to select the ruleset. i can select it b

  • Flex 4.6 unable load module, if it contains a chart component.

    Hi All, I am facing a problem in 4.6 flex SDK however it is working fine in earlier version sdks. I used a column chart in a module and tried to load the module in flex 4.6 Application . It gives the following error. 12/27/2011-18:17:29.625-[ FATAL ]