Apex Conditional Highlight with Data linked from another table - sql

I have two separate table that store data in Apex. The main table that feeds the report is current employees. The other table I have is essentially a list of terminated employees with other information on it.
I am trying to find a way that if a name stored in both tables, that row would show up red on the report.
I put this code as an SQL Query into the report query:
select ID,
PAINT_SHOP,
"LOCKER_#",
LOCKER_LOCATION,
DEPT,
ASSOCIATE_NUMBER,
NAME__CINTAS_,
AUDIT_NOTES_,
LOCKER_TRANSFER_REQUESTED
from LOCKER_AUDIT
where (LOCKER_LOCATION = :P12_LL or :P12_LL is null)
select
NAME__CINTAS_,
case when LOCKER_TERM_LIST.NAME = 'TERMINATED' then 'salmon' else 'black' end as event_color
from Locker_Audit, LOCKER_TERM_LIST where LOCKER_AUDIT.NAME_CINTAS_ = LOCKER_TERM_LIST.NAME
*LOCKER_AUDIT --> Table for data storage of report
*LOCKER_TERM_LIST --> Table storing termed employee data
I am receiving this error:

Here is an option. Say this is your report query:
select x.*
,case when y.employee_status = 'TERMINATED' then 'salmon'
else 'black' end as event_color
from current_employees x, old_employees y
where y.employee_id = x.employee_id
Then from the content body, expand COLUMNS and look for the column you want to see in different color and click on it.
On the right frame you will see a text area called HTML Formatting.
Use some HTML there, like:
<span style="color:#EVENT_COLOR#">#YOUR_COLOURED_COLUMN#</span>
I think this would work.

Related

SSRS display text when image column is null

I'm trying to build a SSRS report that shows player name and their photos (if there is any). How do I display a text e.g."No image" if image column return null value (or empty)?
I've tried to do this in SSRS report itself but no luck
:
=IIF(IsNothing(Fields!PlayerImage.Value), "no image", Fields!PlayerImage.Value)
Any help is appreciated.
Assuming you get the image from a database, add a "no image" image to your database and then return that in the dataset query.
For example, if you had two tables, One with a PlayerID and Names and another with PlayerID and Image. Then you could add an entry to the image table with an ID or, say -99 and an image that just contains some text or whatever you like. Then the query would be something like...
SELECT a.PlayerID, a.PlayerName
, ISNULL(i.PlayerImage, x.PlayerImage) AS PlayerImage
FROM myPlayerTable a
LEFT JOIN myImageTable i ON a.PlayerID = i.PlayerID
CROSS JOIN (SELECT * FROM myImageTable WHERE PlayerID = -99) x
Now the report always has all the info it needs and it means you can easily change what you want to display such as an anonymous profile image that is often used.

How validate two select list in oracle apex

I'm using Oracle apex, and i have 2 select list components that get the elements from the same table. i want build a currency converter, and the list of currency are "divisas"
My problem is: i want validate that when on one select component, one value is selected, the other component doesn't contain that element from select list 1. And vice verse
Also when on select 1 is null on the select 2 must show all result from the table, and vice verse.
I start with this query, but i can't do it works
select *
from divisas
where EN_APP = 'S'
and (
case when :P12_DIVISA is not null then (cod_divi <> :P12_DIVISA) else EN_APP = 'S' end
)
;
can somebody help me?
There's the Cascading List of Values property for Select List items. However, as you want to handle both items at the same time, you'll enter circular reference & dead loop so it won't just work.
Here's an option which does what you wanted; see if it helps:
create two items, e.g. P59_CURR_1 and P59_CURR_2 (for two currencies)
their type is Select List item
Page action on selection = "Redirect and set value"
SQL query looks like this (for P59_CURR_1)
select cod_divi d, cod_divi r
from divisas
where cod_divi <> nvl(:P59_CURR_2, 'X') -- would be `:P59_CURR_1` for another item
order by cod_divi
don't set cascading list of values parent item!
That's it; run the page and see how it behaves. Looks OK to me on apex.oracle.com's Apex 20.1 version.

How do I run a SQL query against 2 views that are linked by an ID but has different column names?

I currently have 2 views that house some data.
View1: includes patientsPID and their billing/invoice information (high-level)
View2: includes patientsCID and their respective line items for their billing invoice information (granularity of View1)
I am trying to run a query where I will be able to validate some data. E.g. -> I want to see patientsPID = 1 and see the total amount paid and join it to View2 to see in more details on the invoice.
expected results
Thank you.
You need to join View1 and View2:
select v1.patientspid, v1.invoiceheader, v2.invoiceline, v2.amount
from view1 v1 inner join view2 v2
on v1.patientspid = v2.patientscid
order by v1.patientspid
If you want to get the results for a patientspid use
where v1.patientspid = 1
and no order by
In this case both PatientsPID and PatientsCID act as your Key. The column names don't have to be the same as long as the data contained in them are linked (Same Data).
Select View1.PatientsPID, View1.AmountPaid, View2.[SomeColumnName]
From View1 inner join View2 on View1.PatientsPID = View2.PatientsCID
Where View1.PatientsPID = 1
Use Join in the From line and you have to set which columns are equal between the two tables. These columns have to contain the same data in order to be able to link. Whatever column names you want to select just place the table name in front of it as show above, this prevents errors in the event of an ambiguous column name

Multiple entries in crystal reportviewer after adding a SQL expression field

I am using Visual Studio 2017 and I installed the latest crystal reportviewer (22)
What I want is to click a button and create a report from the customer that is selected in the datagridview and the addresses that are shown in the second datagridview.
I managed to do all that but the problem is that a few fields contain numbers which need to be converted to text. An SQL query I would use to do this would be like:
SELECT c.customer_nr, c.status, s.rename FROM CUSTOMERS c INNER JOIN SETUP s on s.id = c.status WHERE s.afk = 'STA'
In my SETUP database I have the columns ID,AFK and RENAME so if the status would be 1 it would convert to text: "ACTIVE", if status = 2 it would convert to "INACTIVE" for example.
I could do something with a formula field like this:
IF ({c.status} = 1) THEN "ACTIVE" ELSE
IF ({c.status}) = 2 THEN "INACTIVE"
but that is not good because i could add another status or change the name in the database etc.
So then I tried with an SQL expression field and I put something like this:
(
SELECT "SETUP"."RENAME" FROM SETUP
WHERE "SETUP"."AFK" = 'STA' AND "SETUP"."ID" = "CUSTOMERS"."STATUS"
)
There must be something wrong because I get the correct conversion but there is only one address in the database but I get 7 pages all with the same address. There should only be one address like I get when I remove the SQL expression field. Where does it go wrong?
* EDIT *
I found the problem. When I create a new database that contains only unique id's then it works. In my original database I have multiple times the id's 1,2,3,4,5 but with different abbreviations in column AFK. Somehow the query looks for the id value and every time it finds this id no matter the AFK value it generates an entry for the address value.
Maybe in the future I will find out how this exactly works for now I have a workaround.
Create a new table for example CrRepSta and add the following entries:
ID,AFK,RENAME
1,STA,Active
2,STA,Inactive
etc
The new query:
(
SELECT "CrRepSta"."RENAME" FROM CrRepSta
WHERE "CrRepSta"."AFK" = 'STA' AND "CrRepSta"."ID" = "CUSTOMERS"."STATUS"
)
And by the way the statement "CrRepSta"."AFK" = 'STA' is not really needed.

How would I implement this query in an SSIS dataflow?

So I have something that I did in an execute SQL task but my project manager would rather see it in a data flow task.
INSERT INTO [dbo].[lookup_product]
([dim_global_data_source_id]
,[source_product]
,[source_product_type]
,[source_grade]
,[source_gauge]
,[source_width]
)
SELECT distinct
dim_global_data_source_id,
product_desc,
product_type,
grade,
gauge,
size1
FROM Staging_informix_Coil_is
where not exists
(select source_product
from lookup_product
where lookup_product.dim_global_data_source_id = Staging_informix_Coil_is.dim_global_data_source_id
and isnull(lookup_product.source_product,'') = isnull(Staging_informix_Coil_is.product_desc,'')
and lookup_product.source_product_type = Staging_informix_Coil_is.product_type
and isnull(lookup_product.source_grade,'') = isnull(Staging_informix_Coil_is.grade,'')
and isnull(lookup_product.source_gauge,0) = isnull(Staging_informix_Coil_is.gauge,0)
and isnull(lookup_product.source_width,0) = isnull(Staging_informix_Coil_is.size1,0)
)
`
That's the query. I need this in a workflow. Someone help me out or give me a sample
I'm with your project manager on this one. I would create a Data Flow Task. The first component would be an OLE DB Source, containing just your first SELECT (no WHERE clause).
The next component would be a Lookup, selecting the columns you need to match on from lookup_product. On the Columns tab I would match the columns as you have in your WHERE clause. On the General tab I would set it to Redirect Rows to No Match output.
The final component is an OLE DB Destination, pointing at the lookup_product table. I would connect this to the Lookup using the No Match output.