Validation based on conditions in another table
Hi All,
I'm trying to do a before update validation based on a condition. Basically, if the value of table1.columnA is changed to Yes only save when there are no rows in table2 columnX = Yes, otherwise online error.
I have tried expressions, boolean, etc. and can't quite get the right combination.
I am looking at something like select Y from dual where count of T2.CX = Yes is >1 otherwise N, and generate error only when Y is returned.
Any help is appreciated.
Thanks for the help. I did get it working, but in a way completely opposite than I was thinking it should work.
FYI -
The validation is expression 1 is contained in expression 2
expression one is the p15_task_closed
expression two is NO
add a condition Exists (Sql returns a row)
then do the select from the other table where it is true!
I guess it says look at the conditions first, if the condition is true check the validation. If the validation is TRUE then no error, if the validation is FALSE (in this case the p15_task_closed = YES) enforce the validation error.
Similar Messages
-
Update one table based on condition from another table using date ranges
Hello!
I have two tables:
DateRange (consists of ranges of dates):
StartDate FinishDate
Condition
2014-01-02
2014-01-03 true
2014-01-03
2014-01-13
false
2014-01-13
2014-01-14 true
Calendar (consists of three-year dates):
CalendarDate IsParental
2014-01-01
2014-01-02
2014-01-03
2014-01-04
2014-01-05
2014-01-06
2014-01-07
2014-01-08
2014-01-09
2014-01-10
I want to update table Calendar by setting IsParental=1
for those dates that are contained in table DateRange between
StartDate and FinishDate AND Condition IS TRUE.
The query without loop should look similar to this but it works wrong:
UPDATE
Calendar
SET IsParental = 1
WHERE
CalendarDate BETWEEN
(SELECT
StartDate
FROM DateRange
WHERE Calendar. CalendarDate = DateRange. StartDate
AND
(SELECT StartDate
FROM DateRange
WHERE Calendar. CalendarDate = DateRange. FinishDate
AND Condition
IS TRUE
Is it possible to do without loop? Thank you for help!
AnastasiaHi
Please post DDL+DML next time :-)
-- This is the DDL! create the database structure
create table DateRange(
StartDate DATE,
FinishDate DATE,
Condition BIT
GO
create table Calendar(
CalendarDate DATE,
IsParental BIT
GO
-- This is the DML (insert some sample data)
insert DateRange
values
('2014-01-02', '2014-01-03', 1),
('2014-01-03', '2014-01-13', 0),
('2014-01-13', '2014-01-14', 1)
GO
insert Calendar(CalendarDate)
values
('2014-01-01'),
('2014-01-02'),
('2014-01-03'),
('2014-01-04'),
('2014-01-05'),
('2014-01-06'),
('2014-01-07'),
('2014-01-08'),
('2014-01-09'),
('2014-01-10')
select * from DateRange
select * from Calendar
GO
-- This is the solution
select CalendarDate
from Calendar C
where EXISTS (
select C.CalendarDate
FROM DateRange D
where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
UPDATE Calendar
SET IsParental = 1
from Calendar C
where EXISTS (
select C.CalendarDate
FROM DateRange D
where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
[Personal Site] [Blog] [Facebook] -
Conditional Extract (based on changes in another table)
Hi guys,
I have a question for nightly (incremental) loads. I want to select from certain tables even if there are updates to another table.
For example, I nightly pull any changes (or new records) from table 1, 2, 3, 4, & 5.
But, if table 1 has no changes, I still want to pull matching records from it if there are changes to any of the others.
And similarly, I want to pull matching records from table 2 if there are changes to any of the others.
Assume that the Last_update field is available in the source tables. (This is necessary for pulling key columns to match for updates.)
Thanks.can you explain in details .?
-
Setting validation based on condition on custom list
Hi,
I have a custom Image library. I have two custom columns created as part of metadata.
One is a dropdown choice column, which contains 2 values - "Free", "Paid".
I also have a datepicker column (date only).
I would like to set a validation based on below condition:
If dropdown selected is "Paid", then date should be mandatory field.
Can this be achieved OOB or a JSLink is required.
How to achieve this?
ThanksHi Vankatzeus,
You can achieve this using Javascript. In New and edit forms of your list, add a content editor webpart with the script explained below -
There is a PreSaveAction() function that you can use to do a custom validation. Before submitting any item, sharepoint first do the validation in PreSaveAction().
function PreSaveAction() {
//Step 1 - Read the choice and date fields.
// Step 2 - If choice is 'PAID' and 'date' field is blank { alert('Date can't be blank'); return false;} else {return true;}
In Step 1, write a script that read values from choice and date fields. You can take the script from
here and modify it just to read choice and date fields.
Cheers,
Manvir -
Deleting Records based on status in another table
Dear All,
I am using oracle 11gR1 on Linux.
We have two tables one holding year starting and closing dates with year status as open/closed for multiple years and multiple entities. Any year may be open for an entity.
Relevant columns/Pk
PK: entity_id, fin_year_id
Cols: year_st_dt, year_end_dt, year_status
We have another table where monthly summarized information is stored via scheduled procedure. Currently the procedure deletes all records and inserts new records.
Relevant columns/Pk
Cols: entity_id, year_month
What we want is that the procedure should not delete records that related to financial years that are closed.
How would I write a delete statement to do that?
Regards, ImranHi,
957 posts, but still while posting a question, you have not
1) Posted the table structure of all the tables involved. (create statement)
2) Posted the sample input (insert statement)
3) Posted the sample output.
4) More importantanly posted on the correct forum.
Regards
Anurag Tibrewal. -
Help with inserting records conditionally in another table
I need some help on this task please. I have a table with some records like so
Table1
Column1 Column2 Column3 Colum4
1 Name1 Lastname1 1,2
2 Name2 Lastname2 3
3 Name3 Lastname3 NULL
4 Name4 Lastname4 1,3
So the last column, Column4 has the number of the column that the values got changed. So the values on the first row on the Columns 1 and 2 got changed. So I have to insert those values in another table and the same for the other records.
Table2
Column1 Column2 Column3
1 Name1 NULL
2 NULL Lastname2
4 NULL Lastname4
Any ideas on how to accomplish this? Any ideas would be much appreciated.Hi
Try below, Next time please POST DDL & DML
select 1 Column1, 'Name1' Column2, 'Lastname1'Column3, '1,2' Colum4 into #temp union all
select 2 , 'Name2', 'Lastname2', '3' union all
select 3 , 'Name3' , 'Lastname3', NULL union all
select 4, 'Name4', 'Lastname4', '1,3'union all
select 5, 'Name4', 'Lastname4', '1'
select 1 Column1 ,'Name1' Column2, NULL Column3 into #temp1 union all
select 2 ,NULL ,'Lastname2' union all
select 4, NULL, 'Lastname4'
select Column1, Column2, Column3, Colum4 ,C2,C1 from #temp a
--(select Column1, Column2, Column3, case when Colum4 like '%,%' OR Colum4 IS null then Colum4 else Colum4+',' end as Colum4 from #temp) a
outer apply (select COALESCE(Column2,Column3) From #temp1 where column1 = parsename(replace(a.colum4,',','.'),1)) a1(C1)
outer apply (select COALESCE(Column2,Column3) From #temp1 where column1 = parsename(replace(a.colum4,',','.'),2)) a2(C2)
You can also use split function
http://sqlperformance.com/2012/07/t-sql-queries/split-strings
select a.*,COALESCE(a2.Column2,a2.Column3) From #temp a
cross apply dbo.Split(Colum4,',') a1
left outer join #temp1 a2 on a1.item=a2.Column1
Thanks
Saravana Kumar C -
Inserting values in atable based on values in another table
Hi,
We receive data from our customers as follows AB784589456. This is the starting value for an serial number of a product. We also receive a quantity. I need to be able to populate rows in another table to start with AB784589456 and then add an additional
row to the value of the quantity. So the first row in the second table would be AB784589456, the second AB784589457, AB784589458, etc until the number has been incremented to the value of the quantity.
Order Number SerialNo
234 AB784589456
234 AB784589457
234 AB784589458
The datatype of the SerialNo is Varchar(14)
Any help would be appreciated
ThanksAssuming the serial value format is consistent ie alphabet followed by numeric you can use this
DECLARE @Serial varchar(14) = 'AB784589456', @Quantity int = 15
;With N1
AS
SELECT 1 N UNION ALL SELECT 1 UNION ALL SELECT 1
),N2
AS
SELECT 1 N FROM N1 t1 CROSS JOIN N1 t2
),N3
AS
SELECT 1 N FROM N2 t1 CROSS JOIN N2 t2 CROSS JOIN N2 t3
),N4
AS
(SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS Seq
FROM N3
INSERT INTO YourTable (OrderNumber,SerialNo)
SELECT OrderNumber,LEFT(@Serial,PATINDEX('%[0-9]%',@Serial)-1) + CAST(STUFF(@Serial,1,PATINDEX('%[0-9]%',@Serial)-1,'') + Seq -1 AS varchar(11))
FROM Table1 t
CROSS JOIN N4 n
WHERE n.Seq BETWEEN 1 AND @Quantity
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Set Default Value based on Field from another table for a custom object
I'm trying to set the default value on a custom object field to the value of an account field. I have tried the syntax 50 different ways, and just am getting no where. The account field label displays as DBA, the integration tag is ltDBA_ACCT, and it shows up in reporting fx area as Account.Text_22.
The custom object field I'm triying to update is also called DBA, which was originally the "NAME" required field. Does the table name, Account, have to be included? Do I need a function in front of the field?
I have been updating the external ID using the row ID with syntex <ID> (Less than ID greater than) so I know it is possible to set the Default Value, but <DBA>, <ltDBA_ACCT>, "Account"."DBA", and so on just don't not work.
If anyone knows how to enter this I'd really appreciate the help.Ok, so if you want to default a field to the value from another object, you have to use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure that you do.
Next, this will only work as a default if the record is created from the object that you wish to join on because a default works at record creation and the ID needs to be available for it to work properly. It will not work if you choose the related object record after the custom object record is created. You could set the value as a post-default, but that does not seem to meet your requirements.
The syntax for the Default Value would be as follows: JoinFieldValue(ref_record_type, foreign_key, field_name).
In your case, ref_record_type is '<Account>', foreign_key is [<AccountId>], and field_name is '<YourFieldName>'. The best way to determine what the field name is would be to create a new workflow for Account and use the Workflow Rule Condition expression builder to pick your field ("DBA") from the list. The value that is returned by the expression builder should be placed in the field_name variable in the JoinFieldValue function (minus the brackets and in single quotes).
Give this a shot and let me know how you do.
Thom -
Select LOV based on value in another table
Hi all,
I have an issue,
I have an item with Select list with dynamic query in the dropdown ListofValues.
but i want to use a condition like
select val1 display_value val2 return_value
from table2
where value_in_table1 = username AND table_id1=table_id2
in these two tables i have the id's common and table 1 is having the usernames.
Can somebody help me in solving this issue please.
Thanks in advanceAs far as I know, you can't dump PL/SQL into the list of values definition. Try just having select distinct PJT_NAME display_value, PROJECT_ID return_value from EZS_PROJECTS WHERE EMP_ID = :P1_XYZ ORDER BY 1
-
Convert numeric value to display as text based on record in another table? ASP/VB
I have an orders table:
orderID (PK)
pickupname
pickupaddress
pickupregion (numeric)
pickuppostcode
deliveryname
deliveryaddress
deliveryregion (numeric)
deliverypostcode
I also have a regions table:
regionID
regionname
On my ASP page, I would like to display the pickup and
delivery addresses as
follows, but also need this to be within a repeat region as I
am displaying
a number of orders on the page (I have wrapped what I want in
the repeat
region in dashes, below):
---------Repeat Region Start-----------
Pickup Address:
Name
Address
Region (pickupregion)
Postcode
Delivery Address:
Name
Address
Region (deliveryregion)
Postcode
--------Repeat Region End------------
As it displays at the moment, I get this (using sample data):
---------Repeat Region Start-----------
Pickup Address:
Joe Bloggs
High Street
12
HT12 5TY
Delivery Address:
Jane Bloggs
The Mall
33
DT6 5TG
--------Repeat Region End------------
Is there any way to convert these numeric values to the
actual region name
but to keep it within one recordset so that I can use the
repeat region? I
tried creating a recordset for regions (SELECT regionID,
regionname FROM
tblRegions WHERE regionID = pickupregion OR regionID =
deliveryregion), but,
because I'm not repeating this region, it just displays the
same regional
name for every order, albeit the first record returned does
contain the
correct values! :o)
I was thinking about some kind of inner join, but it's having
two numeric
region fields in the orders table that is causing me
headaches! PS. I need
to keep the two addresses within one orders table - I had
thought of that!
Got me a bit stumped, I have to say. Any help would be
greatly appreciated.
Thanks.
Regards
Nath.I've tried this one already.
I tried to leave it blank, & nbsp ; , text,... but the problem is that our lov is build by a function and it always returns a query, so the LOV is never null.
I figured something out: made a process after header that has some cursors to get the values from the database and changed the item to a simple display as text-field. There were only 4 that were wrong, so it wasn't to much work. -
Distinct records based on condition within a table
Hello PL/SQL Gurus/experts,
I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production version
I have following table -
Note - Table don't have any primary key on Order_ID -
DROP TABLE T;
create table T(Order_ID,Active_Flg) as select
'201002', 'Y' from dual union all select
'201002', '' from DUAL union all select
'201003', '' from dual union all select
'201004', 'Y' from DUAL union all select
'201004', '' from dual union all select
'201005', '' from DUAL ;I want to fetch those Order_ID which have Active-Flg as NULL and don't have the entry for Active_Flg=Y
If use the following then it returns the distinct Order_ID but not the expected one -
SELECT DISTINCT ORDER_ID FROM T WHERE ACTIVE_FLG IS NULL;Result -
ORDER_ID
201004
201002
201003
201005Kindly help.....try this
with t as
select
'201002' order_id, 'Y' active_flg from dual union all select
'201002', '' from DUAL union all select
'201003', '' from dual union all select
'201004', 'Y' from DUAL union all select
'201004', '' from dual union all select
'201005', '' from DUAL
select order_id
from (
select
order_id,
active_flg,
count(case when active_flg = 'Y' then 1 end) over(partition by order_id) cntY
from t
where cntY = 0 and active_flg is null -
Conditional inclusion of column cells based on value in another column?
I was wondering if something like the following is possible -- I've looked through the forums and Numbers user guide but can't figure it out:
Suppose I have a column A of sales figures, and columns B and C which basically have different attributes (say, color (yellow or green), size (small or large), and material (cotton or polyester)).
I want to run basic statistics on various combinations: e.g. all yellow items regardless of size, all green cotton items regardless of size, all large yellow items regardless of material, etc.
I want to be able to specify something like this:
'Compute the average of every cell in column A where column B=="green" and column C=="large"'
Is there a good way to go about doing this? Would I want to attack the problem using categories, sorting, and multiple tables? Or is there a way to conditionally include cell values from a range based on the value of that row's cell in another column?
Thanks for any help.All I can think of to solve the quartile and median functions is to have another table of the same size as your original table that gets populated with just the items that match. Then you can do the quartile and median (and average) on that table. It's a one-at-a-time affair; you can only do one selection of size, color, and/or material at a time but you can get the median, mean, and quartiles of it. Of course, you could have multiple copies of this second table if you want to do more than one comparison at a time.
In the attached file, unhide the hidden rows in Table 2 to see the formulas that do all the work.
[files.me.com/pwb3/6hobt0.numbers.zip]
Message was edited by: Badunit
Message was edited by: Badunit -
How to call or not call a Trigger in same table based on condition?
Hi
How to call or not call a Trigger in below situations..
If a table contains a record of same value i.e,
[i[u]]ID
1
1
3
In above ID 1 is repeated for two times.
In this situations i don't want to call a trigger..
But, the value ID is for 3, now i want to fire a trigger.
Based on this i want to delete in another table.
How can I check it?
ThanksThanks for ur reply..
The below is my scnario..
I am having two table
employee
Id empcol
101 111
101 222
102 444
Department
id deptcol
101 457
101 678
102 543
The above is my table structure no one column is PK, so i m not able create FK.
When I am deleting from employee where id =101 and empcol=111,
the above record is deleted.
At present I am using After Update Trigger..
So trigger is called and delete the id 101 in Department table.
In my scenario i can't delete a record in Department table
bcoz i am having id morethan 101 in employee table.
If employee table contains one ID like 102 the Trigger should works.
How can I check the condition After delete on employee table it contains morethan same employee id?
The below is my Trigger..
CREATE OR REPLACE TRIGGER CALL_TRIGGER
AFTER DELETE ON Employee
FOR EACH ROW
DECLARE
count_id pls_integer;
BEGIN
SELECT COUNT(*) INTO count_id from Employee WHERE ID <>:new.ID;
IF( count_id >1) THEN
DELETE FROM Depratment where ID=:old.ID;
END IF;
END;
I am geting an error ORA-04091 table is mutuating, trigger cannot seen it.
I had tried with package and package body also.. But no luck.
Thanks -
Need to Create Search Help Based on Condtions from one table to another tab
Hi All,
I have a table like ZGROUP Which contains the data below
Filed name Filed Name Filed Name
ZGROUP ZTYPE ZTEXT
Entries
ABC P TEXT FOR
C P SDFNSDFKLN
DDDD PSG TEPRTPERERTWERT
DEF P TEST
FFFFF PSG
SEF PS SDFSDFLASLDFNASDLFN
XYZ PS TESTING
Whree P is Product , PS- Point of Sales, PSG-Sales Group
Now i am going to crate another ZPROUDCT TABLE
FIELDNAME FIELDDESCRITPON
PRODUCT PROD_DESC
Entry
abc pRELATED ENTRY
My Questions
1) ZGROUPS table has 3 kinds of data P, PSG, PS type records,
1) In Table ZPROUDCT , I want to create search help only P records for Table Zproduct of the field Product FROM zGROUPS table
2) In Table Zsales , I want to create search help only PS records from ZGROUPS table
3) In Table ZPSG, I want to create search help only PSG records from table ZGROUPS
is it possible to create search help from One Master Table(ZGROUPS) table to other tables based on conditions.
Please help me.
very urgent
Regards,
Rajuif <condition>
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>
SELECT <field>
FROM <table>
INTO TABLE i_tab
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' "function module to provide f4 help to sold-to-party
EXPORTING
retfield = "XXXX"
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = '<field name>'
value_org = 'S'
TABLES
value_tab = i_tab
endif.
lkike this u can check the condition and selec the data from table and assign it into one internal table and then call the FM it will give the f4 help to particular field
reward if helpful
regards,
Khan. -
Range based Flex field validation based on a Lookup table
Hi all,
I am trying to create a validation in one of the flex field under HRMS Application. Table: PAY_ELEMENT_ENTRIES_F
Validation is pretty simple - but i am struggling to implement.
Assume there exists two flex fields;
Field1 contains State Information
Field2 contains Percentage Information
The above two values would be entered by the user.
the validation should be like this.
Field1 - State code entered by User
Field2 - We have a seperate Lookup where we have setup lots of State specific information. Assume ATTRIBUTE3 and ATTRIBUTE4 defines the Min and Max range which would be configured during the Setup. User should be entering any percentage value between the ATTRIBUTE3 and ATTRIBUTE4.
I have created a Table Validaiton with select 1 from dual with the following where clause.
exists ( select null from fnd_common_lookups l, fnd_sessions sess
where
l.lookup_type like 'CUSTOM_US_STATE_RULES'
and sess.session_id= userenv('sessionid')
and sess.effective_date between l.start_date_active
and NVL(l.end_date_active, sess.effective_date)
*and l.attribute1 ='01' -- consider 01 state alone for the time being*
and :$FLEX$.ENTRY_INFORMATION4 between to_number(l.attribute4) and to_number(l.attribute5)
When i compile the flexfileld, it errors out stating invalid reference to ENTRY_INFORMATION4.
ENTRY_INFORMATION4 is the field where i am going to attach this validation
How do i validate a value of the flexfield against the range of values available in another table(in this case a lookup table) ?
Any ideas on how to implement this.
Edited by: vaibhav468 on Sep 29, 2008 3:05 PMThanks so much for the reply. apparently the solution which you have suggested may not work 100% as the data entry also happens via API. Its mentioned in the doc that the special validations happen only via Forms.
But I implemented it in a crude way. But it works though !!!!
Based on the value which i enter in the first Field1, the value set which i am using it in second Field2(its a table based value set)
I generated all possible percentages and displaying it.
My table is: (select trim(to_char(rownum/100,'990D99')) pct from fnd_columns a where rownum<=10000) a, fnd_common_lookups l
My Where clause:
where l.lookup_type='CUSTOM_US_STATE_RULES'
and l.attribute1=substr(:ENTRY.USER_ENTRY4,1,2)
and a.pct between l.attribute4 and l.attribute5
I generated the set of sequence numbers with the help of rownum from a table which definitely contains more than 10000 rows.
I was so glad that FND allowed me to use a INLINE view in the Validation Table not restricting the tables available for that application alone.
thanks again.
Maybe you are looking for
-
I can't import my Camera Archive to final cut pro x
In Final Cut Pro X, when I select Import Media I can navigate to a folder where I have my camera archives on an external drive. But all archives are greyed out and when I try to double click them from the finder, Final Cut Pro X opens but it says it
-
ABAP Client Proxy error code: 401, error text: Unauthorized
Hi, I have Client proxy in ECC for oubound interface in PI 7.0, when i look into SXMB_MONI of ECC i can see my message with Error "HTTP response contains status code 401 with the description Unauthorized Authorization error while sending by HTTP (err
-
I have imported several hundred photos from my iPhoen 5C into iPhoto library. I selected yes to delete them from my iPhone but the photos remain on the phone. Am i doing something wrong. I don't want to pay apple a fee to get this answered via the
-
Hello world, i have a problem, i created a form and inside it in program unit i created code with decode, the probem i want to add more option inside decode for filtering but you know my decode very long and complex for example , sum(decode(classnum,
-
Raid 1 - currenly booted OS drive
Hello, I saw Camelot's posts on this and wanted to undergo the process of adding a second drive to my xserves here to create a Raid 1 to protect myself from downtime. I did the following 2 things and got the following errors for each: 1. diskutil ena