I am creating calculator on forms developer 11g
I want to show multiple values in one display item Like 1 + 1
I have multiple buttons like 1,2,3... and so on
As discussed earlier, use concatenation; every button would have its own WHEN-BUTTON-PRESSED trigger and do
-- WBP on digit '1' button
:block.item := :block.item || '1';
-- WBP on digit '2' button
:block.item := :block.item || '2';
--WBP on the "+" sign button
:block.item := :block.item ||'+';
and so on.
Related
I use the event OnCustomDrawCell of TcxGridDBDataController to change the font row color of a DevExpress TcxGrid to red if a certain Field of the displayed record (e.g 'Debit' has value 1)
if Sender.DataController.GetValue(AViewInfo.GridRecord.RecordIndex, 15) = 1 then
begin
ACanvas.Font.Color := clRed;
end;
The above code works if field 'Debit' has recordIndex 15. But if I change the order of fields it stops working (because recordindex is not 15 anymore).
Instead of Recordindex I would like to use the fieldname 'Debit' in order to check the value.
I would be grateful of someone could help change the above code so that it works regardless of the position of field 'Debit'.
Thank you
It's ok I found it out : Here's the code doing this
{
procedure TfrmAirReservs.grdReservsListDBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var Debit: TcxGridDBColumn;
begin
Debit := TcxGridDBTableView(Sender).GetColumnByFieldName('Debit');
if AViewInfo.GridRecord.Values[Debit.Index] = 1 then
begin
ACanvas.Font.Color := clRed;
end;
end;
}
Not use to use dbms_lob.compare, so the update works fine, but when it reach the IF statement look like only do the same thing when it suppost to alternate like u can see bellow
My PL/SQL code:
CREATE OR REPLACE PROCEDURE teste
IS
aux CLOB;
cnt NUMBER := 0;
cnt1 NUMBER := 0;
BEGIN
FOR rec IN (SELECT xxxx)
LOOP
aux := rec.VALUE;
UPDATE db
SET VALUE = TO_CLOB(deletexml(
xmltype(VALUE),
'//*:getPaymentDetailsResponse/*:Payment/*:childs[./*:status[text()="Failed"]]'
))
WHERE id=rec.gb_ID;
--Teste
IF DBMS_LOB.compare(rec.VALUE, aux) = 0 THEN
DBMS_OUTPUT.put_line('### ORDERS NOT CHANGED ###');
cnt1 := cnt1 + 1; --count orders without any change
DBMS_OUTPUT.put_line(cnt1 || '- ' || rec.ORDER_PUBLIC_ID);
ELSE
DBMS_OUTPUT.put_line('### ORDERS CHANGED ###');
cnt := cnt +1; --count changed orders
DBMS_OUTPUT.put_line(cnt || '- ' || rec.ORDER_PUBLIC_ID);
END IF;
END LOOP;
-- Print count results
DBMS_OUTPUT.put_line('Orders without changing: '|| cnt1 || ' orders.');
DBMS_OUTPUT.put_line('Orders updated: '|| cnt || ' orders.');
END;
/
This is what i am currently getting:
ORDERS NOT CHANGED
1- 160000
ORDERS NOT CHANGED
2- 160000
ORDERS NOT CHANGED
3- 160313
ORDERS NOT CHANGED
4- 160313
What I want to happen:
ORDERS CHANGED
1- 160000
ORDERS NOT CHANGED
2- 160000
ORDERS CHANGED
3- 160313
ORDERS NOT CHANGED
4- 160313
When you create a cursor it is a snapshot of the data as it exists at the time you run the select. Any table changes that are made during the execution of the cursor do not get reflected in the cursor. see Do database cursors pick up changes to the underlying data? for more details.
So you update the base table for your cursor (I assume as you don't show the actual select)
UPDATE db
SET VALUE = TO_CLOB(deletexml(
xmltype(VALUE),
'//*:getPaymentDetailsResponse/*:Payment/*:childs[./*:status[text()="Failed"]]'
))
WHERE id=rec.gb_ID;
Then you do a compare using the details in your cursor
IF DBMS_LOB.compare(rec.VALUE, aux) = 0 THEN
As the cursor is a snapshot this will always come back as Not Changed, you would have to re-select the value from your base table to or use SQL%ROWCOUNT to check if your update statment affected any rows (see https://community.oracle.com/thread/2370954?start=0&tstart=0) for details of how to use this.
i want to add edit button to some specific rows only in a oracle apex report.suppose i want an edit button only in those rows having job = manager.
after clicking that button i will be redirected to another page present in my application.please help regarding these.
You can do this by adding a column of type Display As Text, with Escape Special Characters set to No, defined in the report SQL something like:
...
case when e.job = 'MANAGER' then
q'[<input type="button" value="Edit" onclick="redirect(']'
|| apex_page.get_url
( p_page => 123
, p_items => 'P123_EMPNO'
, p_values => e.empno
)
|| q'[')" class="myButtonClass">]'
end as edit_button
In this example, when clicked the button will redirect to page 123 of the same application and pass this row's empno value into item `P123_EMPNO'.
You can use the class attribute to apply classes for styling - you may want to use Universal Theme class names like 't-Button' for consistency.
Applied to your SQL from comment below:
SELECT apex_item.checkbox(1,empno,'UNCHECKED') " ",
empno, ename, job, hiredate, sal, comm,
case when job = 'MANAGER' then
q'[<input type="button" value="Edit" onclick="redirect(']'
|| apex_page.get_url
( p_page => 123
, p_items => 'P123_EMPNO'
, p_values => empno
)
|| q'[')" class="myButtonClass">]'
end as edit_button
from emp;
I started with a text prompt where a user can enter a string representing days in a single week. For example, M = Monday, and MWF can be typed in to choose Monday, Wednesday, and Friday.
I've just changed the prompt to a multi-select value prompt, and modified my filters to work correctly. Now my prompt looks like this:
When the user selects the items Monday, Wednesday, Friday, the ParamValue list is M,W,F.
How can I display MWF as a data item?
Specifically, I want to combine the new day(s) with a time selected so I can get an output result of MWF 0800 - 1100 but the time values are already taken care of.
Can I somehow index the values inside the multi-select value?
Edit:
I should also mention that variations on
?p_NewDays? || ' ' || ?p_NewStartTime? || '-' || ?p_NewEndTime?
don't seem to work, it will only list the first item in the selection. And TO_CHAR only works for dates.
You can accomplish this with a vendor provided replace() function replacing each comma with an empty string. However, the implementation of such function varies from vendor to vendor. For a vendor-neutral solution you can use this expression to do the same thing:
CASE
WHEN 'M' in ?param? THEN 'M'
ELSE ''
END
||
CASE
WHEN 'T' in ?param? THEN 'T'
ELSE ''
END
||
CASE
WHEN 'W' in ?param? THEN 'W'
ELSE ''
END
||
CASE
WHEN 'Th' in ?param? THEN 'Th'
ELSE ''
END
||
CASE
WHEN 'F' in ?param? THEN 'F'
ELSE ''
END
||
CASE
WHEN 'S' in ?param? THEN 'S'
ELSE ''
END
||
CASE
WHEN 'Su' in ?param? THEN 'Su'
ELSE ''
END
I used the generic ?param? for the parameter name. You would have to change it to match your specific parameter.
You didn't indicate how you differentiate between Tuesday and Thursday as well as Saturday and Sunday. I simply used the first initial for the first day of the week to start with that letter and used a common two-letter abbreviation for the second instance.
I'm using Oracle apex and am trying to practice with automatic emails. Ideally, this is how the scenario would go: A user can 'recommend' games to friends through his wishlist. The user selects the game(s) they would like to recommend though a checkbox, then selects the friends and email content. The code I have in place for this is as follows:
DECLARE
content VARCHAR2(4000) := :P4_EMAIL || 'Here are the game(s):';
game VARCHAR2(100);
i NUMBER := 1;
/*Declare the cursor and it's query */
cursor CURSOR IS
SELECT name
from gs_games
where game_id = APEX_APPLICATION.G_F01(i)
FOR UPDATE;
BEGIN
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
OPEN cursor;
FETCH cursor INTO game;
CLOSE cursor;
END LOOP;
htmldb_mail.Send(p_to => :P4_FRIENDS,
p_from => 'gametracker#gametracker.com',
p_subj => 'Game recommendations from ' || :F56_USER_NAME,
p_body => content || ' ' || game);
END;
This only partially works. For a single selection, everyone works perfectly, but once the user selects multiple games, then the email only contains the name of the first game checked off, instead of every game as it should. I realize this is tied to the way I've got my cursor set up, but I'm not entirely sure how I can use it while keeping that for loop active. Does anyone have any ideas? Thank you.
The immediate problem is that every time you fetch the next row from the cursor into your local variable game, you are overwriting the prior value of that variable. Once you've fetched every row from the cursor, game will have the value of whatever the last row you processed was.
Assuming that you want your email to contain a comma-separated list of game names, you could do something like
-- You probably want to create this function inside of a package that provides other methods
-- for interacting with games
CREATE OR REPLACE FUNCTION get_game_name( p_game_id IN gs_games.game_id%type )
RETURN gs_games.name%type
IS
l_name gs_games.name%type;
BEGIN
SELECT name
INTO l_name
FROM gs_games
WHERE game_id = p_game_id;
RETURN l_name;
END get_game_name;
DECLARE
l_content VARCHAR2(4000) := :P4_EMAIL || 'Here are the game(s):';
l_game_list VARCHAR2(100);
BEGIN
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_game_list := l_game_list || ', ' || get_game_name( APEX_APPLICATION.G_F01(i) );
END LOOP;
l_game_list := LTRIM( ', ' );
apex_mail.send( p_to => :P4_FRIENDS,
p_from => 'gametracker#gametracker.com',
p_subj => 'Game recommendations from ' || :F56_USER_NAME,
p_body => l_content || ' ' || l_game_list);
END;
A few notes about style
Naming a cursor CURSOR is problematic and should be avoided at all costs. If you do need to declare a cursor, you really ought to give it a meaningful name.
Local variables generally ought to be named in such a way that differentiates them from the names of columns in tables (in my case, I use a l_ prefix for local variables and a p_ prefix for parameters though there are many different valid conventions. This is important in PL/SQL because identifiers in SQL statements are resolved first using the names of columns in the table and then using local variables. That makes it far too easy to inadvertently write code that uses a column when you meant for it to use a local variable if you don't have some convention to make it clear which you're using.
You don't want to use a cursor to select a single row of data. If you have a query that you know should return exactly 1 row, use a SELECT INTO.
I created a separate function to get the name for a particular game_id because that maximizes reuse-- there will likely be many other places that you need to do something similar so you want to write that code once and use it many times. It would be perfectly legal to put the SELECT INTO into the loop in your anonymous PL/SQL block, it would be preferable to factor that code out into a function.
Assuming you are using a vaguely recent version of APEX, you should be using the apex_mail package not the old htmldb_mail package. There shouldn't be any functional difference between the two but HTML DB was the old name for Oracle APEX many releases ago so it's a good idea to phase out the use of the old package names.