473,385 Members | 1,814 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,385 software developers and data experts.

Procedure with update

create or replace
PROCEDURE login IS theuser VARCHAR2(30) := portal.wwctx_api.get_user;
v_forebranch VARCHAR2(10);
v_forecategory VARCHAR2(10);
v_foregroup VARCHAR2(50);
v_count NUMBER(6);

CURSOR c_branch IS
SELECT branch
FROM nyp_libportal.library_user
WHERE UPPER(user_id) = UPPER(theuser);

CURSOR c_category IS
SELECT category
FROM nyp_libportal.library_user
WHERE UPPER(user_id) = UPPER(theuser);

CURSOR c_group IS
SELECT user_grp
FROM nyp_libportal.library_user
WHERE UPPER(user_id) = UPPER(theuser);

BEGIN
IF theuser <> 'PUBLIC' THEN

OPEN c_branch;
LOOP
FETCH c_branch
INTO v_forebranch;
EXIT
WHEN c_branch % NOTFOUND;
END LOOP;

CLOSE c_branch;

OPEN c_category;
LOOP
FETCH c_category
INTO v_forecategory;
EXIT
WHEN c_category % NOTFOUND;
END LOOP;

CLOSE c_category;

OPEN c_group;
LOOP
FETCH c_group
INTO v_foregroup;
EXIT
WHEN c_group % NOTFOUND;

END LOOP;

CLOSE c_group;

htp.p('<B>' || v_forecategory || v_forebranch || v_foregroup || '</B>');

INSERT
INTO portal_home_login_log(logdatetime, category, branch, user_group, counter)
VALUES(sysdate, v_forecategory, v_forebranch, v_foregroup, 35);

END IF;

END;



I have done a procedure which when user login, the procedure will fetch the user's branch, category and user_group and then this procedure will then insert the user's branch, category and also the branch into the portal_home_login_log.

Now I need some help on the UPDATE part which IF another same user who has the same user's branch, category and user_group login, the counter will actually increase 2.


Example Result
[PHP]
DATE CAT BRANCH COUNTER
01-AUG-07 PTA SDN 6
01-AUG-07 ACS SIT 9[/PHP]
Aug 1 '07 #1
0 1184

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Philip Mette | last post by:
I am begginner at best so I hope someone that is better can help. I have a stored procedure that updates a view that I wrote using 2 cursors.(Kind of a Inner Loop) I wrote it this way Because I...
7
by: Roger | last post by:
I am trying to create a stored procedure with following functionality. I need to select a table where status = 'G' and return the row to the application and then update all those rows that I just...
1
by: ILCSP | last post by:
Hello, I'm trying to accomplish 3 things with one stored procedure. I'm trying to search for a record in table X, use the outcome of that search to insert another record in table Y and then exec...
5
by: wpellett | last post by:
I can not get the SQL compiler to rewrite my SQL UPDATE statement to include columns being SET in a Stored Procedure being called from a BEFORE UPDATE trigger. Example: create table...
5
by: mk | last post by:
Hi all, The requirement is like this.. I have to update the table with the parameters from front end like at some times i need to update one parameters and some times i have to update more...
1
by: bjethwan | last post by:
Hi, I have a small doubt in SQL Procedures in DB2. It is the first time that I am using DB2 UDB, so please bear me. Following, is a very small example to put across my doubt. In...
0
by: Johan Neidenmark | last post by:
When i try to run this SQL statements in iSeries Access for windows (against my customers db2) i get: SQL State: 42904 Vendor Code: -7032 Message: SQL procedure, function, or trigger...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
0
by: svgeorge | last post by:
I want to update several tables using one stored procedure. How can i do this I mean the syntax.etc. declaration etc. I know the basic syntax as below CREATE PROCEDURE <Procedure_Name, sysname,...
0
by: a573851 | last post by:
I have a very lengthy stored procedure that I just inherited. Apparently this stored proc performs poorly. I am reviewing it to see where I can add some efficiencies. I would like to know if there...
1
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: 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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.