im very new at plsql and try to implement my procedure.
My procedure signature looks like
PROCEDURE signal_merge(s1 IN SIGNAL_STRUCT, s2 IN SIGNAL_STRUCT, rs OUT SIGNAL_STRUCT)
SIGNAL_STRUCT has an (I call it field?) "updated" that is of a type UPDATED_STRUCT
Now I want to do something like
if s2.updated exists
do something
Even with Google I cant find a solution, can somebody explain me how I can achieve this?
Thank you all
I need to know its null or not
Then test for that:
if s2.updated is not null then
-- do something
end if;
Read more.
You want to know whether s2.updated is filled:
IF s2.updated IS NOT NULL THEN
do something
END IF;
I would rather use a non-nullable boolean variable, however, that would either be true or false. Then you'd ask
IF s2.updated THEN
do something
END IF;
which I consider more readable.
The struct declaration would then look like
TYPE signal_struct IS RECORD
(
updated BOOLEAN NOT NULL,
...
);
Related
I have a requirement wherein I have to execute this query (SUBSTR(sct.state_customer_type,INSTR(sct.state_customer_type,'(')+1,INSTR(sct.state_customer_type,')')-INSTR(sct.state_customer_type,'(')-1)) when user selects English language and if the language is selected as Spanish then execute this query (SUBSTR(sct.state_customer_type,1,INSTR(sct.state_customer_type,'(')-1)).
The language id would also come dynamically.
How can I write decode inside another decode function.
Thank you for your replies in advance.
I don't see any decode functions in your code, but if your language id variable is v_lang, you could write:
select decode(v_lang,
'English',
(SUBSTR(sct.state_customer_type,INSTR(sct.state_customer_type,'(')+1,INSTR(sct.state_customer_type,')')-INSTR(sct.state_customer_type,'(')-1)),
'Spanish',
(SUBSTR(sct.state_customer_type,1,INSTR(sct.state_customer_type,'(')-1)),
null -- if v_lang is something else
)
from ....
where ....
However, these days we recommend using ANSI CASE statements instead of decode. It's similar but easier to read and more portable.
select CASE v_lang
WHEN 'English'
THEN (SUBSTR(sct.state_customer_type,INSTR(sct.state_customer_type,'(')+1,INSTR(sct.state_customer_type,')')-INSTR(sct.state_customer_type,'(')-1))
WHEN 'Spanish'
THEN (SUBSTR(sct.state_customer_type,1,INSTR(sct.state_customer_type,'(')-1))
ELSE null -- if v_lang is something else
END
from ....
where ....
How to prompt a message if field is empty in oracle forms i'm not sure if it works and the trigger i'm using is when-validate-item
begin
if date = NULL then
message('please enter issue date')
else
null;
end if;
end;
From my point of view:
you should edit field's properties and set the required property to yes and let Forms worry about it
if you insist on reinventing the wheel, then don't just display a message as it is pretty much useless - user can ignore it. Raise an error, instead
if :block_name.item_name is null then
message('Please, enter issue date');
raise_form_trigger_failure;
end if;
Put that piece of code into the WHEN-VALIDATE-ITEM trigger.
Just modify the code a little bit as
converting date = NULL to :date IS NULL, since : prepended to
the field's name within the code
add an extra message(''); (exactly this with blank padded
argument) if a pop-up message box needed
don't forget the semicolon at the end of the line of the current
message(....)
as invoking from one of the WHEN-VALIDATE-ITEM or WHEN-NEW-ITEM-INSTANCE triggers
I need the "elabora prenotazione" button to be shown only when the column "stato prenotazione" is "IN SOSPESO"
I tried to set a condition but I don't know how to pick the column value
If I understand your question, this could help:
For the source of your report:
SELECT
CASE
WHEN stato_prenotazione = 'in sospeso' THEN 'elabora prenotazione'
ELSE ''
END name_of_column,
prenotazione,
username,
nome,
cognome,
viaggio,
stato_viaggio,
data_prenota,
stato_prenotazione,
numero_ospiti
FROM your_table
Then set the column "name_of_column" to type: link, and fill the target.
Wrap a condition around a call to apex_page.get_url within your SQL, so it will only produce a link when relevant
Example of function in use, sans condition:
https://azureoutput.wordpress.com/2017/10/18/custom-hyperlink-in-interactive-report/
Use this to make the button look prettier, and maybe get some other ideas
https://www.grassroots-oracle.com/2015/12/tutorial-include-action-button-in-report.html
See this in regard to escaping special characters, otherwise you'll just see HTML in your report
https://www.grassroots-oracle.com/2017/01/escape-special-characters-apex-demo.html
This could be resolved by a simple case statement as #sara mentioned.
something like:
select (case stato_prenotazione when 'in sospeso' then 'elabora prenotazione' end) as your_column
I would not keep else condition so that the column will simply contain null value if the condition is not met.
This is my query
begin
select ceq_specimens.numero as NUMERO,
analyseEffectuee.DESCRIPTION as analyseEffectuee
into out_rec.NUMERO_SPECIMEN3, out_rec.SPEC3_ANALYSE_EFFECTUE
from CEQ_FORMULAIRES_ANALYSES
inner join ceq_liste_choix analyseEffectuee on analyseEffectuee.ID_LISTE_CHOIX=CEQ_FORMULAIRES_ANALYSES.ID_ANALYSE_EFFECTUE
inner join ceq_specimens on ceq_specimens.ID_SPECIMEN=CEQ_FORMULAIRES_ANALYSES.ID_SPECIMEN and ceq_specimens.ID_SPECIMEN=vintIdSpecimen3
where CEQ_FORMULAIRES_ANALYSES.ID_FORMULAIRE=out_rec.ID_FORMULAIRE;
EXCEPTION
WHEN NO_DATA_FOUND THEN
out_rec.NUMERO_SPECIMEN3 := ' ';
out_rec.SPEC3_ANALYSE_EFFECTUE := ' ';
END;
...
IF analyseEffectuee.DESCRIPTION as analyseEffectuee = Spécimen impossible à analyser: Préciser en commentaire(s)
I get error ''string buffer too small”
IF analyseEffectuee.DESCRIPTION as analyseEffectuee= Non
No problem in this case
Thanks for helping me!
I get Error ''string buffer too small” "
What that means is your variable out_rec.SPEC3_ANALYSE_EFFECTUE is not big enough to hold teh value Spécimen impossible à analyser: Préciser en commentaire(s).
The best way to define PL/SQL variables is to use the %TYPE keyword. This creates a variable which matches the column's definition.
Your code uses something called OUTREC. You haven't given us the definition of this, which makes it harder to correct your specfic problem but perhaps you should be doing something like this. Declare a PL/SQL record type which matches you're desired output, then declare a variable of that type:
type my_rec_t is record (
NUMERO_SPECIMEN1 ceq_specimens.numer%type,
SPEC1_ANALYSE_EFFECTUE analyseEffectuee.DESCRIPTION%type,
NUMERO_SPECIMEN2 ceq_specimens.numer%type,
SPEC2_ANALYSE_EFFECTUE analyseEffectuee.DESCRIPTION%type,
NUMERO_SPECIMEN3 ceq_specimens.numer%type,
SPEC3_ANALYSE_EFFECTUE analyseEffectuee.DESCRIPTION%type
);
out_rec my_rec_t;
ORA-02303: cannot drop or replace a type with type or table dependents
So this means you're using SQL Types, with inheritance. Sorting this out is a bit of a problem. There is some syntax which we can use with the ALTER TYPE command which allows us to handle dependent types. Find out more.
I have a cursor which is returning certain value. I would like to assign this value to a text field. When I compile trigger it returns error: "bad bind variable" for new_dr.textitem43. Any help greatly appreciated.
declare
EMP_ID_VALUE number :='NEW_EMP.ID_FIELD';
pcv_no pcv%TYPE;
cursor cursor_dr IS
select pcv FROM drivers
where drivers.eno = EMP_ID_VALUE;
begin
IF EMP_ID_VALUE < 1000 THEN
open cursor_dr;
fetch cursor_dr into pcv_no;
:new_dr.textitem43 := 'pcv_no';
exit when cursor_dr%NOTFOUND;
CLOSE cursor_dr;
ELSIF
...
END IF;
end;
That would indicate to me that either there is no block named new_dr or there is no field named textitem43 in that block. Are you sure you don't really mean :new_emp.textitem43?