Solved

Oracle PL Sql

Posted on 2013-12-19
2
344 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
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now