Oracle Applications - Next Step Attribute - oracle

When using the Oracle database frontend application, under the Shipping Transactions Screen, there is an attribute called "Next Step". This attribute sits next to the "Line Status" attribute. My question is, where does this attribute, "Next Step" stay within the standard Oracle backend tables/views, such that I can query for this value?
The contents of this attribute are commonly things like:
Ship Confirm/Close Trip Stop
Transact Move Order
Pick Release
If the answerer could provide a table name or view name, i.e. WSH_DELIVERY_DETAILS, that would be great.
Thanks!

The "Next Step" item is generated by function function get_next_step() in one of the shipping transaction form's program units, see code further below.
To use it in SQL, this function logic can be transformed into a case statement, for which you find a code example in the ONT Order Headers and Lines Blitz Report, which shows the 'Next Step' in column CB of the generated Excel file.
function get_next_step(p_detail_id in number,
p_current_released_status in varchar2,
p_source_code in varchar2,
p_oe_interfaced_flag in varchar2,
p_inv_interfaced_flag in varchar2,
p_container_flag in varchar2
) return varchar2 is
begin
--
--bug#3264295 : next step for lpns should be 'not applicable'
--
if p_container_flag in ('Y', 'C') then
return(:parameter.not_applicable_next);
else
if p_current_released_status = 'C' then
--bug 9671087 - standalone and lsp project changes to populate
-- - "next step" as "not applicable" after interfacing with inv.
if p_source_code = 'OE' and p_inv_interfaced_flag in ('X', 'Y') and
(
p_oe_interfaced_flag = 'Y' or
p_oe_interfaced_flag = 'X' and (:parameter.p_wms_deployment_mode = 'D' or :parameter.p_wms_deployment_mode = 'L' and name_in(:parameter.p_dlvb_mode||'.CLIENT_ID') is not null)
)
or
--bug11680443::for shipped oke lines if inv flag is 'x',
-- 'next status' should be 'not applicable '
p_source_code <> 'OE' and p_inv_interfaced_flag in ('X','Y') then
return(:parameter.not_applicable_next);
else
return(:parameter.interface_trip_stop_next);
end if;
elsif p_current_released_status in ('B','R') then
-- bug # 6689448 (replenishment project):
if name_in(:parameter.p_dlvb_mode||'.replenishment_status') = 'R' then
-- replenishment requested dd line.
return(:parameter.replenishment_complete_next);
else
return(:parameter.pick_release_next);
end if;
-- bug # 6689448 (replenishment project):
elsif p_current_released_status = 'S' then
--anxsharm, x-dock
if name_in(:parameter.p_dlvb_mode||'.move_order_line_id') is null then
-- displayed value is planned x-dock
return(:parameter.receive_xdock_next);
else -- mol is not null
return(:parameter.pick_confirm_move_order_next);
end if;
--anxsharm, end of x-dock
elsif p_current_released_status in ('X','Y') then
return(:parameter.ship_confirm_next);
elsif p_current_released_status = 'D' then
return(:parameter.not_applicable_next);
elsif p_current_released_status = 'N' then
return(:parameter.progress_order_next);
end if;
end if;
end get_next_step;

Related

23/3 PLS-00201: identifier 'DBMS_OUPUT.PUT_LINE' must be declared

I am not sure how to resolve the above error I am getting. How should I declare it? I created the procedure below to allow a passenger to buy a metro card and add it to an existing account. Input includes account id, initial balance
SET SERVEROUTPUT ON
-- procedure to buy new metro, output error if account already exists.
CREATE OR REPLACE PROCEDURE NewCard (
input_Account_ID IN varchar,
input_Balance IN varchar,
input_age IN varchar
)
IS
acct varchar(255);
-- compare the input account id to see if it exists in the table
CURSOR S1 is SELECT Account_id from Rider_Account where ACCOUNT_ID = input_Account_ID;
BEGIN
--THIS MEANS THE RECORD EXISTS
open S1;
LOOP
FETCH S1 into acct;
EXIT WHEN S1%notfound;
END LOOP;
-- go through the records
IF (acct = input_Account_ID) THEN
Dbms_ouput.Put_line('Account exists');
ELSE
BEGIN
INSERT into Metro_Card(Card_ID, Account_ID, Balance) VALUES(Card_Sequence.NEXTVAL,input_Account_ID, input_Balance);
INSERT into rider_account(Age) VALUES (input_age);
END;
END IF;
IF (input_age <= 12) THEN
UPDATE Metro_Card
SET Discount_type = 2
Where Metro_Card.Account_ID = input_Account_ID;
ELSIF (input_age >= 65) THEN
UPDATE Metro_Card
SET Discount_type = 3
Where Metro_Card.Account_ID = input_Account_ID;
ELSE
UPDATE Metro_Card
SET Discount_type = 1
Where Metro_Card.Account_ID = input_Account_ID;
END IF;
END;
It is not
Dbms_ouput.Put_line('Account exists');
but
Dbms_ouTput.Put_line('Account exists');
-
^
missing "T"

Need to know if I am using IF statements in stored procedures correctly in PL/SQL

I am pretty amateur to PL/SQL, and I do not know if I am using the IF statements correctly. I am using Oracle Live SQL. This is all trying to insert a new row into a table called 'employees'. And the only NOT NULL values are employeeid, employeename, and jobid
CREATE OR REPLACE PROCEDURE employees.insert_employee
(
p_employeeid employees.employeeid%TYPE,
p_employeename employees.employeename%TYPE,
p_phone employees.phone%TYPE,
p_jobid employees.jobid%TYPE,
p_salary employees.salary%TYPE,
p_managerid employees.managerid%TYPE,
p_departmentid employees.departmentid%TYPE
)
AS
BEGIN
IF p_employeeid IS NULL THEN /* If one of the mandatory values are null */
RAISE VALUE_ERROR;
END IF;
IF p_employeename IS NULL THEN
RAISE VALUE_ERROR;
END IF;
IF p_jobid IS NULL THEN
RAISE VALUE_ERROR;
END IF;
IF p_jobid != employees.jobid THEN /* if jobid entered is not in the table */
RAISE VALUE_ERROR;
END IF;
IF p_salary < 0 THEN /* if the entered salary is negative */
RAISE VALUE_ERROR;
END IF;
IF p_departmentid != employees.departmentid THEN /* if the departmentid entered is not in the table */
RAISE VALUE_ERROR;
END IF;
IF p.employeeid = employees.employeeid THEN /* if the employeeid already exists */
RAISE RAISE_APPLICATION_ERROR(-2000);
END IF;
INSERT INTO employees (employeeid, employeename, phone, jobid, salary, managerid, departmentid)
VALUES(p_employeeid, p_employeename, p_phone, p_jobid, p_salary, p_managerid, p_departmentid);
END;
I don't think that it would even compile. Besides, you shouldn't do it that way (as you were already told). A few more objections, if I may (regarding the original question: whether you use IF correctly).
Bunch of first IFs can be shortened with OR:
IF p_employeeid IS NULL OR
p_employeename IS NULL OR
p_jobid IS NULL OR
p_salary < 0
THEN
RAISE VALUE_ERROR;
END IF;
You can't reference table values that way, e.g.
IF p_jobid != employees.jobid THEN /* if jobid entered is not in the table */
RAISE VALUE_ERROR;
END IF;
There's no employees.jobid - you have to select it first. For example:
declare
l_cnt;
begin
select count(*)
into l_cnt
from employees e
where e.jobid = p_jobid;
if l_cnt = 0 then -- there's no such job in the table
raise value_error;
end if;
end;
Finally, the final condition you checked and tried to raise something
RAISE RAISE_APPLICATION_ERROR(-2000);
is wrong for 3 reasons:
you don't RAISE RAISE_...
User defined exception's range is from -20001 to -20999 (five digits, not 4)
RAISE_APPLICATION_ERROR requires yet another argument
so - correctly - you'd
raise_application_error(-20001, 'That does not exist');
Even if the syntax is right, I don't think you are using them correctly.
1) If things should not be allowed to be null then mark them as NOT NULL on the tables.
2) If the departmentID must exist then that's a foreign key constraint.
3) If the employeeID exists that should be a unique constraint (even if your syntax works, which it does not)
Properly declared, the DB engine will ensure all this for you.

Not getting the desired results

enter code hereI have a Problem. Below pl/sql used to be working before and now i dont know whats happening... I want to insert records into a table called incoming from an interactive report using a check box
my sql is
SELECT apex_item.checkbox2(1,filenumber)
|| apex_item.hidden(2,filename)
|| APEX_ITEM.hidden(3,'&APP_USER. ')
|| APEX_ITEM.hidden(4,volume)
|| APEX_ITEM.hidden(6,filename)
as "SELECT",
FILENUMBER,
FILENAME,
LOCATION,
OPENDATE,
CLOSEDDATE,
VOLUME,
SUB,
temporary,
registryid,
STATUS
from REGISTRY
my pl/sql is
begin
for idx in 1 .. apex_application.g_f01.count
loop
if apex_application.g_f01(idx) is not null then
insert into incoming
(filenumber,
filename
)
values
(apex_application.g_f01(idx),
apex_application.g_f02(idx)
);
end if;
end loop;
end;
and all this happens after process..this was working fine.. However from recent the problem i am having is the pl/sql gives me the correct filenumber but the incorrect filename.
e.g
lets say the ir report has
filenumber filename
1 aaron
2 kerron
3 Joshua
when i select number 2 (second record) the result in the incoming table will be
filenumber filename
2 aaron
its always selecting the first record once it falls in the apex_item.hidden.
if i reverse it and put
SELECT apex_item.checkbox2(1,filename)
|| apex_item.hidden(2,filenumber)
the filename is correct and the file number will do what i explained above which is if i choose the second record i will get
filenumber filename
1 kerron
when i add
begin
for idx in 1 .. apex_application.g_f01.count loop
for i in 1..apex_application.g_f02.count loop
if apex_application.g_f01(idx) is not null then
insert into INCOMINGREQUESTNOTIFICATION
(requestedfile,filenumber
)
values
(apex_application.g_f01(idx),
apex_application.g_f02(i)
);
end if;
end loop;
end loop;
end;
#romeuBraga i am getting all 3 rows not the selected one can you tell me what am doing wrong
You need a hidden item to store the ID.
*1 and 2 store the same information
select column1,
column2,
column3,
apex_item.hidden(p_idx => 1,
p_value => code) ||
apex_item.checkbox2(p_idx => 2,
p_value => code) CheckBox,
other items
from x
in this case, you need this pl/sql to get the correct row values.
begin
for i in 1..apex_application.g_f01.count loop
for j in 1..apex_application.g_f02.count loop
if apex_application.g_f01(i) = apex_application.g_f02(j) then
--insert something here
end if;
end loop;
end loop;
end;

Check ID Exist and delete record in PL SQL

What I have to do is, whenever a STORE_CODE is entered it will check in the db and delete the store code. SO for that, I have written a procedure which is as below
PROCEDURE DELETE_STORE_INFO
(
P_STORE_CODE IN NVARCHAR2
)
AS
BEGIN
UPDATE TBL_RRSOC_STORE_INFO set ISACTIVE = 'N' where STORE_CODE = P_STORE_CODE;
END DELETE_STORE_INFO;
But here what missing is
what if the user enter the wrong store_code and does the operation so what it will do. how to check with that part ?
I guess something for COUNT wont work at this stage. Kindly suggest
You want to use SQL%ROWCOUNT to find out how many rows were affected by the previous SQL statement:
PROCEDURE DELETE_STORE_INFO
(
P_STORE_CODE IN NVARCHAR2
)
AS
BEGIN
UPDATE TBL_RRSOC_STORE_INFO
SET ISACTIVE = 'N'
WHERE STORE_CODE = P_STORE_CODE;
IF SQL%ROWCOUNT = 0 THEN
-- DBMS_OUTPUT.PUT_LINE( 'Store code does not exist.' );
RAISE_APPLICATION_ERROR( -20000, 'Store code does not exist.' );
END IF;
END DELETE_STORE_INFO;
/
You can use DBMS_OUTPUT.PUT_LINE( string ) to output to the SQL console (if you are calling this from an external language like PHP or Java then you will not see the output and you may not see it in the console if you have SET SERVEROUTPUT OFF).
You could also use RAISE_APPLICATION_ERROR( error_code, error_message ) to raise an exception if something invalid happens.
Alternatively you could return a status in an OUT parameter:
PROCEDURE DELETE_STORE_INFO
(
P_STORE_CODE IN NVARCHAR2,
O_STATUS OUT NUMBER
)
AS
BEGIN
UPDATE TBL_RRSOC_STORE_INFO
SET ISACTIVE = 'N'
WHERE STORE_CODE = P_STORE_CODE;
IF SQL%ROWCOUNT = 0 THEN
o_status := 0;
ELSE
o_status := 1;
END IF;
END DELETE_STORE_INFO;
/
Generally contract for your procedure is: caller gives some store_code and procedure guarantee that there is no active store with such code. What if caller gives the wrong store_code? It means there is no such store, so contract is accomplished. You should do nothing, no more :)
But if you wish to check whether update found the record or not, you can add something like
if sql%notfound then
dbms_output.put_line('There is no such store!');
end if;
immediately after update statement.
Especially for MT: just check simple script
create table t$(id integer);
insert into t$ values(1);
set serveroutput on
begin
update t$ set id = 2 where id = 1;
if sql%notfound
then dbms_output.put_line('#1: not found');
else dbms_output.put_line('#1: found');
end if;
update t$ set id = 4 where id = 3;
if sql%found then
dbms_output.put_line('#2: found');
else dbms_output.put_line('#2: not found');
end if;
end;
/
drop table t$;
My results are
Connected to Oracle Database 12c Enterprise Edition Release 12.1.0.2.0
#1: found
#2: not found
PL/SQL procedure successfully completed
There are something missunderstand in your request: you said you want to delete it but in the code, you just updated the store as incative.
Here is the proceure with both situation. You choose the right one:
CREATE OR REPLACE PROCEDURE DELETE_STORE_INFO (P_STORE_CODE IN NVARCHAR2) AS
n_count number;
BEGIN
select count(1) INTO n_count from TBL_RRSOC_STORE_INFO where STORE_CODE = p_store_code;
if n_count > 0 then
UPDATE TBL_RRSOC_STORE_INFO set ISACTIVE = 'N' where STORE_CODE = P_STORE_CODE;
-- or for deletion
-- DELETE TBL_RRSOC_STORE_INFO set ISACTIVE = 'N' where STORE_CODE = P_STORE_CODE;
else
DBMS_OUTPUT.PUT_LINE('the required store was not found');
end if;
END DELETE_STORE_INFO;

How to retain block position after a query -oracle forms

I have an oracle form with a data_block which displays 25 items.
On the form I have a scrollbar and a 'delete' button. When an item in the data block is selected, and the 'delete' button is pressed, it deletes the selected item from the database and then executes the data_block query.
By default, this returns the user to the top of the list.
I am trying to navigate to the record just before the one that is deleted from the list.
This can be done using the GO_RECORD(number) Built in Function(BIF) (assuming number is the saved value of :System.cursor_record).
And this is where I run into a problem. The GO_RECORD BIF will bring the record to the top or bottom of the displayed list of items. This can cause the list to shift up 20 items without warning.
i.e.
For example Records 23 - 47 from the data_block are being displayed, and record 33 is selected.
If record 33 is deleted and we use the function GO_RECORD(32), then the records diplayed will be 32-56 (effectively shifting the list down 9 records).
I'm assuming that in order to avoid this shift I will need to have some way of detemining the position of the record in the display (as opposed to the data_block).
Does anyone know if this functionality exists?
Or does anyone have another approach that might get me the same result?
first create this procedure as a program unit
PROCEDURE SYNC_BLOCK
-----------------------------------------------------------------------*
-- Synchronizes the display of any scrollable block.
-- After running an edit that loops through all records, this will
-- restore the block's display so that the same top record is again
-- at the top of the block's display.
-- Blk is the name of the block.
-- Rec_Num is the desired target current record.
-- Top_Rec is the original Top Record of the block captured
-- before the looping process began.
(BLK VARCHAR2,
REC_NUM NUMBER,
TOP_REC NUMBER) IS
BLK_ID BLOCK;
TOP_NEW PLS_INTEGER;
REC_N PLS_INTEGER;
--
Procedure Check_success is begin
If not form_success then
Raise form_trigger_failure;
End if;
End Check_success;
Procedure Go_Rec(rec_num number) is begin
Go_Record(Rec_num);
Check_Success;
End Go_Rec;
BEGIN
BLK_ID := FIND_BLOCK(BLK);
IF ID_NULL(BLK_ID) THEN
Message(' U72_GO_REC_SYNC_BLOCK: CANNOT FIND BLOCK '''||BLK||'''');
Raise Form_trigger_failure;
END IF;
IF BLK <> :SYSTEM.CURSOR_BLOCK THEN
GO_BLOCK(BLK);
Check_Success;
END IF;
IF :SYSTEM.CURSOR_RECORD <> REC_NUM THEN
GO_REC(REC_NUM);
END IF;
-- may need to re-set the display to the rows originally shown
TOP_NEW := GET_BLOCK_PROPERTY(BLK_ID, TOP_RECORD);
IF TOP_REC <> TOP_NEW THEN
IF TOP_REC < TOP_NEW THEN
IF :SYSTEM.CURSOR_RECORD <> TOP_REC THEN
GO_REC(TOP_REC);
END IF;
ELSE
REC_N := GET_BLOCK_PROPERTY(BLK_ID, RECORDS_DISPLAYED)
+ TOP_REC - 1;
IF :SYSTEM.CURSOR_RECORD <> REC_N THEN
GO_REC(REC_N);
END IF;
END IF;
SYNCHRONIZE;
-- Found that Sync caused focus change to different block. Fix here.
IF BLK <> :SYSTEM.CURSOR_BLOCK THEN
GO_BLOCK(BLK);
Check_Success;
END IF;
IF :SYSTEM.CURSOR_RECORD <> REC_NUM THEN
GO_REC(REC_NUM);
END IF;
END IF;
-- can't go_rec to NEW record, so need to test here
IF :SYSTEM.LAST_RECORD = 'TRUE'
AND REC_NUM = 1 + :SYSTEM.CURSOR_RECORD THEN
NEXT_RECORD;
Check_Success;
END IF;
--
END SYNC_BLOCK;
second this below five lines of code do exact what you want
xx:=GET_BLOCK_PROPERTY('blk',TOP_RECORD);
xxx:=GET_BLOCK_PROPERTY('blk',CURRENT_RECORD );
go_block('blk');
execute_query();
SYNC_BLOCK('blk',xxx,xx);
please do not hesitate to contact me if you require further information
-- save top record
l_top_rec:= GET_BLOCK_PROPERTY('EXP_DETAIL_BLK', TOP_RECORD);
l_cur_rec:= :SYSTEM.CURSOR_RECORD;
-- your actions
execute_query; // or othres actions...
-- set top record
go_block(block_name);
--
first_record;
loop
exit when GET_BLOCK_PROPERTY(block_name, TOP_RECORD) = l_top_rec;
next_record;
end loop;
go_record(l_top_rec);
--
loop
exit when :SYSTEM.CURSOR_RECORD = l_cur_rec or :SYSTEM.LAST_RECORD = 'TRUE';
next_record;
end loop;

Resources