DB Constraint for one record in a table
Hi I have some config tables where the rule is only one record should be in the table. How can I make a constraint in the database to enforce that only X number of records can be inserted? In this case x=1 :)
BR
Tim
Use the UNIQUE constraint on this field :
SQL> create table t (x number UNIQUE) ;
Table created.
SQL> insert into t values (1) ;
1 row created.
SQL> insert into t values (1) ;
insert into t values (1)
ERROR at line 1:
ORA-00001: unique constraint (SYSTEM.SYS_C001808) violated
U can add this constraint to a field with the ALTER TABLE ADD CONSTRAINT command.
Fred
Similar Messages
-
How to call webservice for each record in a table using ODI
Hi
I am new to ODI and Webservice. I want to invoke a scenario in ODI using web service. I hava a weblogic application server with axis 2 deployed.
But I want call webservice for each record in a table
For eg: "EMP" table have 50 records, for each record web service should invoke
Can any one help me on it.
Thanks,
phani
Edited by: user12774166 on Jun 6, 2010 11:16 PMIf your goal is "call" a web service, Jason's Straub's [flex-ws-api|https://flex-ws-api.samplecode.oracle.com/] is by far the best I've seen. You might want read more about it on [his blog|http://jastraub.blogspot.com/search?q=+flex_ws_api+].
Tyler Muth
http://tylermuth.wordpress.com
[Applied Oracle Security: Developing Secure Database and Middleware Environments|http://sn.im/aos.book] -
Multiple Errors for one record in RFC
Hi,
Iam creating RFC.In RFC i have defined output structure in tables.In that structure one field ZMSG and its length is 500.so want to display mutliple errors for one record in ZMSG field output.
Using concantenation...but How to do that?send me Example code...
Regards,
Raj.clear v_error.
loop on return where type = 'E'.
concatenate v_error return-ZMSG into v_error saperated by spaces respecting blanks.
endloop.
Edited by: Pranu Pranu on May 21, 2010 9:31 AM -
Total jobs getting more for one record
Hi Gurus,
In the report if I filtered for one record, the result should be TOTAL job scheduled(Key Figure-ZITSCKF) = 1 but since I modified the record for 3 times on different DATES(Character - ZIBFDCH) it is showing as TOTAL job scheduled = 3.
In update rules I mapped the DSO object (ZIBFDCH) to Info Cube object (ZITSCKF), I written a formulae that--- IF( IS_INITIAL( /BIC/ZIBFDCH ), 1, 0 ).
Please help me regarding this issue, points will be assigned.
Regards,
Kiran AHi Kiran,
sice you have multiple modifications dates, what i think is, create intenal table sort baced on dates and read only one value for the combination of key fields like..DATES(Character - ZIBFDCH), DSO object (ZIBFDCH). so that one records for key combination will be updated to data target.
Regards
Daya Sagar -
How to fire a query for every record in a table, pass values in a loop
Hi,
For each record in a table, I want to loop through each record and then fire a query by passing acct, product and date from this table to the where clause of the query. I would have to create a pl/sql block..The output of the query I want to spool from sql developer.
I need the exact syntax please for doing this.. since i am new to Oracle. Just the template will be enough. I will fill in the query.
Any help is appreciated as always..
Regards,
hena904385 wrote:
Hi,
For each record in a table, I want to loop through each record and then fire a query by passing acct, product and date from this table to the where clause of the query. I would have to create a pl/sql block..The output of the query I want to spool from sql developer.
I need the exact syntax please for doing this.. since i am new to Oracle. Just the template will be enough. I will fill in the query.
Any help is appreciated as always..
Regards,
henaHave you ever considered using a JOIN ? It does the same thing as looping through a table and applying that to the where clause of a select on a query, only much, much, much faster and without the need to write any code. SQL is a declarative language, so you specify what you want and not how to do it. It can be bit of a journey to change your thought process if you come from a procedural or object world, but once you get there it's a beautiful view. -
How find just one record on the table
Hi,
I've this table TAB_DV:
COD_ID.........DV_ID
001............A
002............A
002............B
002............C
002.............
003............
004............GG
004............DD
004............FF
004............MM
004............TT
008.............BB
0022..............
0033..............
0044............A
0044............
0055............FF
0066............
I'd like to find only the COD_ID that have one record (in the table TAB_DV) without dv_id:
In my case:
COD_ID.........DV_ID
003............
0022..............
0033..............
0066............
If I run:
SELECT COD_ID, DV_ID
FROM TAB_DV
WHERE DV_ID IS NULL
GROUP BY COD_ID, DV_ID;
I get also COD_ID with more records.
How can I write this query?
Thanks in advance.try this
select cod_id
from tab_dv
where dv_id is null
having count(cod_id) = 1
group by cod_id
or
select t1.cod_id, t1.dv_id
from tab_dv t1
where t1.cod1 in (select cod_id
from tab_dv t2
having count(t2.cod_id) = 1
group by t2.cod_id)
and t1.dv_id is null -
How to change a item property just for one record
Hi,
My Requirement is, when a new record is inserted i want item1 to be enabled(which is disabled by default) only for this new record. when I implement the following code, entire column is enabled intead of just for one record.
The code I have written in WHEN-NEW-RECORD-INSTANCE trigger is
app_item_property.set_property('block1.item1', ALTERABLE_PLUS, PROPERTY_ON);
app_item_property.set_property('block1.item1', ENTERABLE, PROPERTY_ON);
please help!
Thanks
SunnyThe code I have written in WHEN-NEW-RECORD-INSTANCE trigger is
app_item_property.set_property('block1.item1', ALTERABLE_PLUS, PROPERTY_ON);
app_item_property.set_property('block1.item1', ENTERABLE, PROPERTY_ON);What is APP_ITEM_PROPERTY? This is not a Valid Oracle Forms Built-in. I don't see how your When-New-Record-Instance (WNRI) trigger will compile.
To change the properties of a specific instance of an item you would use the Set_Item_Instance_Property built-in and then there are only a few properties you can change; which are: BORDER_BEVEL, INSERT_ALLOWED, NAVIGABLE, REQUIRED, UPDATE_ALLOWED and VISUAL_ATTRIBUTE. To make a specific instance of "ITEM1" Insertable and Updateable you would use the following:
Set_Item_Instance_Property('YOUR_BLOCK.ITEM1', CURRENT_RECORD, INSERT_ALLOWED, PROPERTY_TRUE);
Set_Item_Instance_Property('YOUR_BLOCK.ITEM1', CURRENT_RECORD, UPDATE_ALLOWED, PROPERTY_TRUE);However, if you have set the ENABLED property of ITEM1 to NO in the Forms Builder, you will not be able to "Enable" the item using Set_Item_Instance_Property. You will need to make the item Enabled and set the INSERT/UPDATE properties to NO.
Hope this helps,
Craig B-)
If someone's response is helpful or correct, please mark it accordingly. -
Apex report with details below for one record
Hi,
I'm looking for an answer to my problem:
We have a report with many columns ~60.
And is not very user friendly because it is so wide table.
If it is possible to display some less important columns like additional information below report,
for single record in report. E.g. user selects radio button from first column and details are refreshed for that record.
(if it is possible to group details in tabs)
Thank you for your answers.Hi,
Here is one example
https://apex.oracle.com/pls/apex/apex/f?p=39006:41
Create hidden item that is not protected. In my case item name is P41_DEPTNO
First report query
select
APEX_ITEM.RADIOGROUP(1,DEPTNO,:P41_DEPTNO) AS rg,
EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO
FROM EMP
Second report query
select LOC,
DNAME,
DEPTNO
from DEPT
WHERE DEPTNO = :P41_DEPTNO
In second report region set Page Items to Submit your hidden item name.
Create dynamic action
- event: Change
- Selection Type: jQuery Selector
- jQuery selector: input[name=f01]
- Action: Set Value
- Set Type: JavaScript Expression
- JavaScript Expression: this.triggeringElement.value;
- Selection Type: Item(s)
- Item(s): <Your hidden item name>
Then add another true event to dynamic action
- Action: Refresh
- Selection Type: Region
- Region: <select second report region>
Regards,
Jari -
How to apply data into 2 tables AND to more than one record in same table?
Hello,
I am trying to apply/insert data into 2 tables AND at the same time apply data to more than one record (in the same table). How would I do this in APEX?
I have updated using one table with no problem, however, when I try updating with the two tables/ multiple record sets, I get errors.
I appreciate the help.
Thanks.
LindaYou can achieve what you want using PL/SQL. Can you post ur code?
-
ReadOnly for one row in a table in Web Dynpro
Hallo,
is there a possibility to set rows in a table to readonly if there is a condition to do that.
The rest must be in normal lookout.
Kind regards
GunterHi,
Refer to the flwg thread,
Field in web dynpro table for one row to be read only
Hope it helps.
Regards
Srinivasan T -
Checking for every record in a table using PL/SQL
Hello Gurus,
I would need your help in finding the best approach to tackle the below analysis using PL/SQL.
I have a table which contains two columns
UserID and Month
I want to find out the users who made orders every month for the first half of 2012.That is the User ordered on Jan 2012, Feb2012 ... and June 2012.
The Table is huge and has more than a million records. How do I approach this in PL/SQL.
JoeHi Justin,
Thanks for the quick response. This is helpful.However my Intention is to do it using PL/SQL for learning purposes. I am new to PLSQL.
I wanted to do something like looping through each records in the table for every user ID and If I find orders for six consecutive months for a particular user, I will insert the user id to a temp table.
Any hints on how can I use this? I heard about cursor. Can I use it. If so how should I approach.
--Joe -
Can I plot 2 locations at the same time for each record in a table
I'm trying to plot 2 Locations (2 points on a Power View Map) at the same time for each record/project in a table
I can plot 1 location for each project of course with no problem
but I'm trying to show the Begin Point and the
End Point for each project at the same time
Is this even possible?First of all THANKS this worked!
But now I stumbled on another issue. So I actually have 3 tables (and I've adopted them to the file you sent)
Table 1 => TripData
Trip
LongLat
Location
Type
TypeCode
Size
NW Tour
47.568077, -122.320800
Seattle, WA
Begin
0
1
NW Tour
47.035608, -122.884812
Olympia, WA
End
1
1
Cali Trip
37.808848, -122.412580
San Francisco, CA
Begin
0
1
Cali Trip
32.682611, -117.178348
San Diego, CA
End
1
1
Table 2 =>
TripInfo
Trip
OneLongLat
NTP
NW Tour
47.568077, -122.320800
1/1/2015
Cali Trip
37.808848, -122.412580
1/5/2015
Table 3 =>
ALLTrips
Trip
Stop
Owner
NW Tour
1
Owner1
NW Tour
2
Owner2
NW Tour
3
Owner3
NW Tour
4
Owner4
NW Tour
5
Owner5
Cali Trip
1
Owner6
Cali Trip
2
Owner7
Cali Trip
3
Owner8
Cali Trip
4
Owner9
Cali Trip
5
Owner10
Cali Trip
6
Owner11
This is how the Diagram View looks like in PowerPivot
Trip Data => Trip Info <= ALLTrips
Since I don't know how to post pictures
The MAP FIELDS are as follows
SIZE - Count of Stop(s)
LOCATIONS - OneLongLat followed by
LongLat (drill down feature)
COLOR - Trip
The problem now happens with the drill down feature
You can either plot OneLongLat which is the general location for each trip
Or LongLat of each trip which shows the begin and end points
But you can't use the drill down feature???
If instead of OneLongLat you use a
State Column it actually works!!!
I wonder if it has to do with the fact that both locations used for the drill down are Long/Lat numbers???
Any suggestions???
And again Thanks for the response! -
Peoplesoft Panels for one record on two different level
There are two key fields on the record. I want to display only one key field as header and rest on the grid. Two key fields are
New item (K) search key, list box
Old item (K) search key, list box
other fields...
1. I have created a panel that is used for one new item that replaces bunch of old items(Item Supersedure) in which I used new item key in the header and old key item field in the grid. This works fine.
2. But, I also want another panel that needs old item field in the header and bunch of new items in the grid for the same record(one old item being replaced by few new items).
I made both old and new item field search key and list box, so that I can use them to create panel for these two situation.However, this second panel is not working right. Everytime I insert new items in the grid, it doesn't copy old item on the header that is associated with it on database after save.
Since, this was not working, I was thinking of creating a view, work record etc but that doesn't seem to work either.
Please share your expertise. Your help will be highly appreciated.
ThanksThere are two key fields on the record. I want to display only one key field as header and rest on the grid. Two key fields are
New item (K) search key, list box
Old item (K) search key, list box
other fields...
1. I have created a panel that is used for one new item that replaces bunch of old items(Item Supersedure) in which I used new item key in the header and old key item field in the grid. This works fine.
2. But, I also want another panel that needs old item field in the header and bunch of new items in the grid for the same record(one old item being replaced by few new items).
I made both old and new item field search key and list box, so that I can use them to create panel for these two situation.However, this second panel is not working right. Everytime I insert new items in the grid, it doesn't copy old item on the header that is associated with it on database after save.
Since, this was not working, I was thinking of creating a view, work record etc but that doesn't seem to work either.
Please share your expertise. Your help will be highly appreciated.
Thanks -
Need help with a SQL qurey that returns multiple rows for one record?
I have the following query where I use a CASE WHEN clause to determine the date of a shift that begins with "FRLO" on day1 - day14 of the pay period. It works great if a schedule record contains one day that begins "FRLO", but if more than one day is "FRLO" then it only returns the first day it finds and not the others. Is there some way to get the query to return a ron for every day 1 - 14 that begins "FRLO"? System if Oracle 11G
Order of the results is not important as this is part of a larger query that orders the results.
Thanks in advance for any help,
George
SELECT s.empid,
CASE
WHEN UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
THEN
pp.startpp
WHEN UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
THEN
pp.startpp + 1
WHEN UPPER (SUBSTR (s.Day3, 0, 4)) = 'FRLO'
THEN
pp.startpp + 2
WHEN UPPER (SUBSTR (s.Day4, 0, 4)) = 'FRLO'
THEN
pp.startpp + 3
WHEN UPPER (SUBSTR (s.Day5, 0, 4)) = 'FRLO'
THEN
pp.startpp + 4
WHEN UPPER (SUBSTR (s.Day6, 0, 4)) = 'FRLO'
THEN
pp.startpp + 5
WHEN UPPER (SUBSTR (s.Day7, 0, 4)) = 'FRLO'
THEN
pp.startpp + 6
WHEN UPPER (SUBSTR (s.Day8, 0, 4)) = 'FRLO'
THEN
pp.startpp + 7
WHEN UPPER (SUBSTR (s.Day9, 0, 4)) = 'FRLO'
THEN
pp.startpp + 8
WHEN UPPER (SUBSTR (s.Day10, 0, 4)) = 'FRLO'
THEN
pp.startpp + 9
WHEN UPPER (SUBSTR (s.Day11, 0, 4)) = 'FRLO'
THEN
pp.startpp + 10
WHEN UPPER (SUBSTR (s.Day12, 0, 4)) = 'FRLO'
THEN
pp.startpp + 11
WHEN UPPER (SUBSTR (s.Day13, 0, 4)) = 'FRLO'
THEN
pp.startpp + 12
WHEN UPPER (SUBSTR (s.Day14, 0, 4)) = 'FRLO'
THEN
pp.startpp + 13
END
startdate,
NULL starttime,
NULL endtime,
8 hours,
0 minutes
FROM schedules s
JOIN
payperiods pp
ON pp.periodid = s.periodid
WHERE UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day3, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day4, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day5, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day6, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day7, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day8, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day9, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day10, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day11, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day12, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day13, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day14, 0, 4)) = 'FRLO';
CURRENT OUTPUT
EMPID STARTDATE STARTTIME ENDTIME HOURS MINUTES
753738, 3/25/2013 , , ,8 ,0
753740, 3/25/2013 , , ,8 ,0
753748, 3/25/2013 , , ,8 ,0
DESIRED OUTPUT
EMPID STARTDATE STARTTIME ENDTIME HOURS MINUTES
753738, 3/25/2013 , , ,8 ,0
753740, 3/25/2013 , , ,8 ,0
753748, 3/25/2013 , , ,8 ,0
753738, 3/26/2013 , , ,8 ,0
753740, 3/26/2013 , , ,8 ,0
753740, 3/28/2013 , , ,8 ,0
753748, 1/1/2013 , , ,8 ,0
753738, 4/3/2013 , , ,8 ,0
753748, 4/3/2013 , , ,8 ,0
CREATE TABLE SCHEDULES
SCHEDULEID NUMBER(12) NOT NULL,
EMPID NUMBER(12) NOT NULL,
PERIODID VARCHAR2(6 BYTE) NOT NULL,
AREAID NUMBER(12) NOT NULL,
DAY1 VARCHAR2(50 BYTE),
DAY2 VARCHAR2(50 BYTE),
DAY3 VARCHAR2(50 BYTE),
DAY4 VARCHAR2(50 BYTE),
DAY5 VARCHAR2(50 BYTE),
DAY6 VARCHAR2(50 BYTE),
DAY7 VARCHAR2(50 BYTE),
DAY8 VARCHAR2(50 BYTE),
DAY9 VARCHAR2(50 BYTE),
DAY10 VARCHAR2(50 BYTE),
DAY11 VARCHAR2(50 BYTE),
DAY12 VARCHAR2(50 BYTE),
DAY13 VARCHAR2(50 BYTE),
DAY14 VARCHAR2(50 BYTE),
NOPTIND1 INTEGER DEFAULT 0,
NOPTIND2 INTEGER DEFAULT 0,
NOPTIND3 INTEGER DEFAULT 0,
NOPTIND4 INTEGER DEFAULT 0,
NOPTIND5 INTEGER DEFAULT 0,
NOPTIND6 INTEGER DEFAULT 0,
NOPTIND7 INTEGER DEFAULT 0,
NOPTIND8 INTEGER DEFAULT 0,
NOPTIND9 INTEGER DEFAULT 0,
NOPTIND10 INTEGER DEFAULT 0,
NOPTIND11 INTEGER DEFAULT 0,
NOPTIND12 INTEGER DEFAULT 0,
NOPTIND13 INTEGER DEFAULT 0,
NOPTIND14 INTEGER DEFAULT 0
CREATE TABLE PAYPERIODS
PERIODID VARCHAR2(6 BYTE) NOT NULL,
STARTPP DATE,
ENDPP DATE
Insert into SCHEDULES
(SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
DAY2, DAY3, DAY4, DAY5, DAY6,
DAY7, DAY8, DAY9, DAY10, DAY11,
DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693744, 753738, '082013', 2167, 'X',
'FRLO<1530>', 'FRLO<1530>', '1530', '1530', '1530',
'X', 'X', '1530', '1530', 'FRLO',
'1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0);
Insert into SCHEDULES
(SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
DAY2, DAY3, DAY4, DAY5, DAY6,
DAY7, DAY8, DAY9, DAY10, DAY11,
DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693745, 753740, '082013', 2167, 'X',
'FRLO<1530>', 'FRLO<1530>', '1530', 'FRLO', '1530',
'X', 'X', '1530', '1530', '1530',
'1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0);
Insert into SCHEDULES
(SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
DAY2, DAY3, DAY4, DAY5, DAY6,
DAY7, DAY8, DAY9, DAY10, DAY11,
DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693746, 753748, '082013', 2167, 'X',
'FRLO<1530>', '1530', '1530', '1530', '1530',
'X', 'X', 'FRLO<1530>', '1530', 'FRLO',
'1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0);
COMMIT;
Insert into PAYPERIODS
(PERIODID, STARTPP)
Values
('082013', TO_DATE('03/24/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;Do you have the opportunity to change the data model to have one day per row ? It would make this easier to get this result without the need for a 14-way CASE or UNION.
If not...
The case statement will return as soon as it matches one of the conditions. Since you want a match when any column in the row starts with FRLO you can use a UNION ALL treating each column as a separate result. There may be more efficient ways to do this, but here is one way:
Select S.Empid, Pp.Startpp Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day1, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+1 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day2, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+2 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day3, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+3 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day4, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+4 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day5, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+5 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day6, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+6 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day7, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+7 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day8, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+8 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day9, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+9 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day10, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+10 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day11, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+11 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day12, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+12 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day13, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+13 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day14, 0, 4)) = 'FRLO'
; -
Computation only works for FIRST record in detail table
Hi,
I am having a weird problem. I have a master/detail form with page computations that work only for the very first record inserted into the detail table. If i try to enter a second or a third record the fields DO NOT get updated with the return values.
This is driving me nuts and i am on a deadline with this project. HELP!!!!!
Here is the code for all the computations below. Interestingly enough, only the name computation works for every new detail record. The others work only for the first.
-- Calulate Social Security PL/SQL Function
DECLARE
p_is16to62ssrate NUMBER(6,2);
p_u16o62ssrate NUMBER(6,2);
p_dob DATE;
p_base_date DATE := SYSDATE;
p_age NUMBER(3);
p_totalss NUMBER(9,2);
BEGIN
SELECT is16to62ssrate, u16o62ssrate
INTO p_is16to62ssrate, p_u16o62ssrate
FROM SSC3_RATES
WHERE ratescheduleid = 1;
SELECT dob
INTO p_dob
FROM SSC3_EMPLOYEES
WHERE ssno = :P25_SSNO;
p_age := TRUNC(MONTHS_BETWEEN(p_base_date,p_dob)/12);
IF (p_age >= 16) OR (p_age <=62) THEN
p_totalss := (:P25_TOTALWAGES * (p_is16to62ssrate/100));
ELSIF (p_age < 16) OR (p_age > 62) THEN
p_totalss := (:P25_TOTALWAGES * (p_u16o62ssrate/100));
ELSE
p_totalss := 0.00;
END IF;
RETURN p_totalss;
END;
-- Calculate Levy PL/SQL Function
DECLARE
-- declare local variables to hold rates from rates table
p_hsdlarate NUMBER(6,2);
p_hsdlbrate NUMBER(6,2);
p_hsdlcrate NUMBER(6,2);
p_hsdldrate NUMBER(6,2);
p_hsdlaminearnings NUMBER(8,2);
p_hsdlamaxearnings NUMBER(8,2);
p_hsdlbminearnings NUMBER(8,2);
p_hsdlbmaxearnings NUMBER(8,2);
p_hsdlcminearnings NUMBER(8,2);
p_hsdlcmaxearnings NUMBER(8,2);
p_hsdldminearnings NUMBER(8,2);
p_hsdldmaxearnings NUMBER(8,2);
p_totalwages NUMBER(8,2);
p_totallevy NUMBER(8,2);
BEGIN
-- Load rate info from table into variables
SELECT hsdlarate, hsdlbrate, hsdlcrate, hsdldrate, hsdlaminearnings,
hsdlamaxearnings, hsdlbminearnings, hsdlbmaxearnings,
hsdlcminearnings, hsdlcmaxearnings, hsdldminearnings,
hsdldmaxearnings
INTO p_hsdlarate, p_hsdlbrate, p_hsdlcrate, p_hsdldrate,
p_hsdlaminearnings, p_hsdlamaxearnings, p_hsdlbminearnings,
p_hsdlbmaxearnings, p_hsdlcminearnings, p_hsdlcmaxearnings,
p_hsdldminearnings, p_hsdldmaxearnings
FROM SSC3_RATES
WHERE ratescheduleid = 1;
-- Assign total wages to variable
p_totalwages := :P25_TOTALWAGES;
-- Determine applicable levy payment and rate
IF (p_totalwages < p_hsdlamaxearnings) THEN
p_totallevy := (p_totalwages * (p_hsdlarate/100));
ELSIF (p_totalwages >= p_hsdlbminearnings) AND (p_totalwages <= p_hsdlbmaxearnings) THEN
p_totallevy := (p_totalwages * (p_hsdlbrate/100));
ELSIF (p_totalwages >= p_hsdlcminearnings) AND (p_totalwages <= p_hsdlcmaxearnings) THEN
p_totallevy := (p_totalwages * (p_hsdlcrate/100));
ELSIF (p_totalwages >= p_hsdldminearnings) THEN
p_totallevy := (p_totalwages * (p_hsdldrate/100));
END IF;
RETURN p_totallevy;
END;
-- Calculate Total Wages PL/SQL Function
DECLARE
t_wages NUMBER(8,2);
BEGIN
t_wages := (:P25_WEEK1_WAGE + :P25_WEEK2_WAGE + :P25_WEEK3_WAGE + :P25_WEEK4_WAGE + :P25_WEEK5_WAGE + :P25_BONUS + :P25_OTHER);
RETURN t_wages;
END;
-- Calculate Employee Name PL/SQL Function
DECLARE
p_firstname VARCHAR2(20);
p_lastname VARCHAR2(20);
p_name VARCHAR2(40);
p_join VARCHAR2(2) := ', ';
BEGIN
SELECT firstname, lastname
INTO p_firstname, p_lastname
FROM SSC3_EMPLOYEES
WHERE ssno = :P25_SSNO;
p_name := Initcap(p_lastname||p_join||p_firstname);
RETURN p_name;
END;
Regards
Glenroy SkeltonHi,
The first thing that strikes me is the following IF test:
IF (p_age >= 16) OR (p_age <=62) THEN
p_totalss := (:P25_TOTALWAGES * (p_is16to62ssrate/100));
ELSIF (p_age < 16) OR (p_age > 62) THEN
p_totalss := (:P25_TOTALWAGES * (p_u16o62ssrate/100));
ELSE
p_totalss := 0.00;
END IF;The first test will be true for every number as all numbers are greater than 16 or less than 62. I'd suggest changing the OR to an AND or use BETWEEN
Andy
Maybe you are looking for
-
Usb 6009....mx base....and other musings
I've recently received a few usb-6009 devices, and, like most of the other people here on the boards, have had my share of problems getting the things up and going. If I understand correctly.... I can create an empty task in LabView with a VI. This
-
OBIEE 11G with MySql Issue Hierarchy is not working..
Hi, i am using the OBIEE 11G with MySQL DB. i have sucessfully created the RPD. i created the Hierarchy in the RPD. this is the scerario i have created. i have only one data column created_at. by using this column i create 3 more logical logical colu
-
Greetings!!! I have maintained authorization group F_BKPF_BUP to restrict posting in previous period.. It works fine for all tcodes except CO11 Any solution plz Regards
-
I have just now set up my new HP Pavilion p7-1110 - the DVD drive will not open.
-
The "Help" in all my applications is not working.
Every time I use Help, in any application, I get a window with a message saying the topic is unavailable, suggesting I confirm I am connected to the internet, which I am. I called Apple support yesterday. They had me reinstall my OS (10.8.2) I'm new