?
Solved

Oracle PL Sql

Posted on 2013-12-19
2
Medium Priority
?
353 Views
Last Modified: 2013-12-19
Hi im trying to run an insert statement only if it is a current trading day, getting a compile error though PLS-00103

create or replace procedure import_sum_trades as
begin
declare c_is_trading_day char(1);

select c.is_trading_day into c_is_trading_day from calendar c where c.date = trunc(sysdate);


if (c_is_trading_day = '0') then
 
    (insert into sum_trades_info (trade_time, trader, trade_desk, firm_id, sponsor, ttl_trd_cnt, ttl_trd_vol
    , ttl_val_money_saved, ttl_vol_mpp_or_better, firm_type, source, route_destination, gateway_id)
    select trade_time, trader, trade_desk, firm_id, sponsor, ttl_trd_cnt, ttl_trd_vol, ttl_val_money_saved, ttl_vol_mpp_or_better, firm_type, source, route_destination, originating_gateway
    from stats.import_sum_trades_info);
    commit;

end if;
end;
0
Comment
Question by:Extreme66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 39730336
get rid of declare, move the begin, remove extra parentheses around the insert

CREATE OR REPLACE PROCEDURE import_sum_trades
AS
    c_is_trading_day CHAR(1);
BEGIN
    SELECT c.is_trading_day
      INTO c_is_trading_day
      FROM calendar c
     WHERE c.date = TRUNC(SYSDATE);

    IF (c_is_trading_day = '0')
    THEN
        INSERT INTO sum_trades_info(
                        trade_time,
                        trader,
                        trade_desk,
                        firm_id,
                        sponsor,
                        ttl_trd_cnt,
                        ttl_trd_vol,
                        ttl_val_money_saved,
                        ttl_vol_mpp_or_better,
                        firm_type,
                        source,
                        route_destination,
                        gateway_id
                    )
            SELECT trade_time,
                   trader,
                   trade_desk,
                   firm_id,
                   sponsor,
                   ttl_trd_cnt,
                   ttl_trd_vol,
                   ttl_val_money_saved,
                   ttl_vol_mpp_or_better,
                   firm_type,
                   source,
                   route_destination,
                   originating_gateway
              FROM stats.import_sum_trades_info;

        COMMIT;
    END IF;
END;
0
 

Author Closing Comment

by:Extreme66
ID: 39730367
Excellent catch, thanks for the quick response, it helped immensely!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question