473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Basic PL/SQL script needed

I have taken over management of a data warehouse running on
Oracle/Windows. I would like to add some code to the daily load
processing scripts that would check that a table has been loaded, that
is, has more than 0 records. I have .bat scripts that call SQL
scripts. I'd like the SQL scripts to do a record count and if it is
zero end with a non-zero return code. I think what I want to use is a
PL/SQL block in the SQL script. I've come up with the following basic
process. Can someone fill in the correct code to make it work?
Thanks.

DECLARE
recs number := 0;
BEGIN
SELECT count(*) INTO recs FROM WarehouseTable;
IF recs = 0 THEN
EXIT FAILURE;
END IF;
END;
/
Jul 19 '05 #1
1 9245
Jack Overhiser wrote:
I have taken over management of a data warehouse running on
Oracle/Windows. I would like to add some code to the daily load
processing scripts that would check that a table has been loaded, that
is, has more than 0 records. I have .bat scripts that call SQL
scripts. I'd like the SQL scripts to do a record count and if it is
zero end with a non-zero return code. I think what I want to use is a
PL/SQL block in the SQL script. I've come up with the following basic
process. Can someone fill in the correct code to make it work?
Thanks.

DECLARE
recs number := 0;
BEGIN
SELECT count(*) INTO recs FROM WarehouseTable;
IF recs = 0 THEN
EXIT FAILURE;
END IF;
END;
/


I haven't tried this, but it should work:

WHENEVER SQLERROR EXIT FAILURE

DECLARE
recs number := 0;
BEGIN
SELECT COUNT(*) INTO recs FROM WarehouseTable WHERE ROWNUM=1;
IF recs = 0 THEN
RAISE_APPLICATION_ERROR(-20001,'Table empty');
END IF;
END;
/

Steve
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edwin Rozie | last post by:
Hey can U help me with the following? I would like to send basic data (like a set of integers & strings) from one php function to another php function. Sounds easy, However, the functions are...
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
16
by: Fox | last post by:
I merged and modified these script which work perfectly fine as long as I use server.execute to access the VBS part (which is itself in another ASP file). When these I use a session variable to...
5
by: mt | last post by:
In a nutshell, I'd like to have a list of items, each of which fills out a small table which displays some info about a particular item(the items being a trouble ticket for a tech support ASP-built...
1
by: Tom Rahav | last post by:
Hello all! I develop application in Visual Basic .NET and ORACLE database. My question is how do I "send" script file to the database using visual basic .net. Other words, is there any way to...
9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
28
by: Randy Reimers | last post by:
(Hope I'm posting this correctly, otherwise - sorry!, don't know what else to do) I wrote a set of programs "many" years ago, running in a type of basic, called "Thoroughbred Basic", a type of...
1
by: Jack Overhiser | last post by:
I have taken over management of a data warehouse running on Oracle/Windows. I would like to add some code to the daily load processing scripts that would check that a table has been loaded, that...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.