I found a script that will allow you to End Date a Responsibility by providing the User Name and Responsibility name. I'm trying to figure out how to create this into a loop so that User Name doesn't have to be provided.
Something along the logic of:
if (responsibility exists for user)
end date
else
check next user
Here's the script I've been using to end date via user name:
DECLARE
v_user_name VARCHAR2 (100) := 'PRAJKUMAR';
v_responsibility_name VARCHAR2 (100) := 'Application Developer';
v_application_name VARCHAR2 (100) := NULL;
v_responsibility_key VARCHAR2 (100) := NULL;
v_security_group VARCHAR2 (100) := NULL;
BEGIN
SELECT fa.application_short_name,
fr.responsibility_key,
frg.security_group_key
INTO v_application_name,
v_responsibility_key,
v_security_group
FROM fnd_responsibility fr,
fnd_application fa,
fnd_security_groups frg,
fnd_responsibility_tl frt
WHERE fr.application_id = fa.application_id
AND fr.data_group_id = frg.security_group_id
AND fr.responsibility_id = frt.responsibility_id
AND frt.LANGUAGE = USERENV ('LANG')
AND frt.responsibility_name = v_responsibility_name;
fnd_user_pkg.delresp
( username => v_user_name,
resp_app => v_application_name,
resp_key => v_responsibility_key,
security_group => v_security_group
);
COMMIT;
DBMS_OUTPUT.put_line ( 'Responsiblity '
|| v_responsibility_name
|| ' is removed from the user '
|| v_user_name
|| ' Successfully'
);
END;
/
Reference: https://blogs.oracle.com/prajkumar/end-date-responsibility-for-oracle-fnd-user
Related
I have created this function and it works:
create or replace function log_in(
p_ssnr in customer.ssnr%type,
p_password in customer.password%type)
return number
as
v_number number(1);
begin
if
(p_ssnr is not null and p_password is not null) then
v_number:= 1;
else
v_number:= 0;
end if;
return v_number;
end;
If I then type: select log_in('social security number','the password') from dual; then I get a "1"
so it works. But you could basically type whatever you want and it will work so it is not a clean code. Since you can't include subquery in the if statement, how can you create the function so you only return 1 when you actually type a social security number (ssnr) and a password that matches the actual customer table? and otherwise you return 0?
NOt sure if you can have multiple rows for same customer. If yes, then use this:
create or replace function log_in(
p_ssnr in customer.ssnr%type,
p_password in customer.password%type)
return number
as
v_number number(1);
begin
select case when count(*) > 0 then 1 else 0 end
into v_number
from customer
where ssnr = p_ssnr and password = p_password;
return v_number;
end;
If not then this should be fine:
create or replace function log_in(
p_ssnr in customer.ssnr%type,
p_password in customer.password%type)
return number
as
v_number number(1);
begin
count(*)
into v_number
from customer
where ssnr = p_ssnr and password = p_password;
return v_number;
end;
I'm having issues to add some code to my package file which is laying on the database. The issue that is being displayed by SQLPlus is "The SQL statement is ignored" but i am not able to track the issue.
It would be nice, if somebody of you out there, would help me, trying to figure out what the issue is.
Thanks in advance.
Function getLetterheadAndLayoutConf(p_invoice_type_code IN Varchar2,
p_admission_type_code IN Varchar2,
p_accounting_type_code IN Varchar2,
p_costbearer_id IN Number,
p_institute_id IN Number,
p_clearing_center_id IN Number,
p_deduction_defined_jn IN Varchar2,
p_letterhead_code OUT Varchar2,
p_layout_code OUT Varchar2)
Return Integer IS
v_Return Integer;
CURSOR cRechnungLetterheadLayout(p_p_invoice_type_code Varchar2,
p_p_admission_type_code Varchar2,
p_p_accounting_type_code Varchar2,
p_p_costbearer_id Integer,
p_p_institute_id Integer,
p_p_clearing_center_id Integer,
p_p_deduction_defined_jn Varchar2) IS
SELECT allc_letterhead_code, allc_layout_code
FROM acc_letterhead_layout_conf
WHERE ( ( allc_invoice_type_code = p_p_invoice_type_code
OR allc_invoice_type_code IS NULL
)
AND ( allc_admission_type_code = p_p_admission_type_code
OR allc_admission_type_code IS NULL
)
AND ( allc_accounting_type_code = p_p_accounting_type_code
OR allc_accounting_type_code IS NULL
)
AND ( allc_costbearer_id = p_p_costbearer_id
OR allc_costbearer_id IS NULL
)
AND ( allc_clearing_center_id = p_p_clearing_center_id
OR allc_clearing_center_id IS NULL
)
AND ( allc_deduction_defined_jn = p_p_deduction_defined_jn
OR allc_deduction_defined_jn IS NULL
)
)
AND nvl(allc_institute_id, p_p_institute_id)
ORDER BY allc_institute_id DESC, allc_sort_no ASC;
Begin
if cRechnungLetterheadLayout%ISOPEN Then CLOSE cRechnungLetterheadLayout; End
If;
OPEN cRechnungLetterheadLayout(p_invoice_type_code, p_admission_type_code, p_accounting_type_code,
p_costbearer_id, p_institute_id, p_clearing_center_id,
p_deduction_defined_jn);
FETCH cRechnungLetterheadLayout
into p_layout_code,
p_letterhead_code;
CLOSE cRechnungLetterheadLayout;
dbg.i(1, 'Vorgabe Letterhead = ''' || p_letterhead_code || '''');
dbg.i(1, 'Vorgabe Layout = ''' || p_layout_code || '''');
v_Return := 1;
End getLetterheadAndLayoutConf;
I have below procedure in which i want to return the output of variable value brand_name.BRAND_NAME. I am getting the correct output. But i want to return it in proper format. For example right now i am getting the output as
BRAND_NAMES:FNC
BRAND_NAMES:LIDL
But i want to return the output as:
BRAND_NAME: FNC,LIDL
Here is my stored procedure:
FUNCTION BUILD_ALERT_EMAIL_BODY
(
IN_ALERT_LOGS_TIMESTAMP IN TIMESTAMP
, IN_ALERT_LOGS_LOG_DESC IN VARCHAR2
, IN_KPI_LOG_ID IN NUMBER
) RETURN VARCHAR2 AS
BODY VARCHAR2(4000) := '';
V_KPI_DEF_ID NUMBER := '';
V_BRAND_NAME VARCHAR2(100) := '';
V_KPI_TYPE_ID NUMBER := '';
CURSOR brand_names_cur
IS
Select BR.NAME AS BRAND_NAME INTO V_BRAND_NAME FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION KD JOIN RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION_BRAND KDB ON KD.KPI_DEF_ID = KDB.KPI_DEF_ID JOIN
RATOR_MONITORING_CONFIGURATION.BRAND BR ON KDB.BRAND_ID = BR.BRAND_ID WHERE KD.KPI_DEF_ID = V_KPI_DEF_ID;
BEGIN
Select KPI_DEF_ID INTO V_KPI_DEF_ID FROM KPI_LOGS WHERE KPI_LOG_ID = IN_KPI_LOG_ID;
Select KT.KPI_TYPE_ID INTO V_KPI_TYPE_ID FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION KD JOIN RATOR_MONITORING_CONFIGURATION.KPI_TYPE KT ON KD.KPI_TYPE = KT.KPI_TYPE_ID WHERE KD.KPI_DEF_ID = V_KPI_DEF_ID;
FOR brand_name IN brand_names_cur
LOOP
BODY := BODY || 'BRAND_NAME:' || brand_name.BRAND_NAME || Chr(10) || Chr(13);
END LOOP;
BODY := BODY || 'ALERT_DESCRIPTION:' || to_char(IN_ALERT_LOGS_LOG_DESC);
RETURN BODY;
END BUILD_ALERT_EMAIL_BODY;
Add V_FIRST_RECORD variable
V_FIRST_RECORD Boolean := true;
and use it in your loop like this
if v_first_record then
body := 'BRAND_NAME: '||brane_name.BRAND_NAME;
else
body := body ||','||brane_name.BRAND_NAME;
v_first_record := false;
end if;
I'm trying to create a record in a database using a SQL query in Delphi 7. I'm using an ADO Query and I've tried both with and without parameters, but to no avail. The error occurs between ShowMessage 1 and 2.
sName := ledName.Text;
sSurname := ledSurname.Text;
sSchool := ledSchool.Text;
sMotherName := ledMotherName.Text;
sMotherCell := ledMotherCell.Text;
sMotherEmail := ledMotherEmail.Text;
sFatherName := ledFatherName.Text;
sFatherCell := ledFatherCell.Text;
sFatherEmail := ledFatherEmail.Text;
sAddress := ledAddress.Text;
sBirthday := DateToStr(dpcBirthday.Date);
ShowMessage(sBirthday);
case rgpGender.ItemIndex of
0 : cGender := 'M';
1 : cGender := 'F';
end;
iGrade := rgpGrade.ItemIndex - 2;
if chkLeader.Checked = true then
bLeader := True
else
bLeader := False;
with dmData do begin
ShowMessage('1');
qryMain.Active := False;
qryMain.SQL.Text := 'SELECT * FROM Users Where Name = "'+sName+'", Surname = "'+sSurname+'", Birthday = "'+sBirthday+'" ';
qryMain.Open;
if qryMain.RecordCount = 0 then begin
qryMain.Close;
ShowMessage('2');
//qryMain.SQL.Text := 'INSERT INTO Users(Name, Surname, MotherName, FatherName, Gender, Grade, Birthday, School, Address, MotherCell, FatherCell, MotherEmail, FatherEmail, NameTag, Volunteer) VALUES("'+sName+'", "'+sSurname+'", "'+sMotherName+'", "'+sFatherName+'", "'+cGender+'", "'+IntToStr(iGrade)+'", "'+sBirthday+'", "'+sSchool+'", "'+sAddress+'", "'+sMotherCell+'", "'+sFatherCell+'", "'+sMotherEmail+'", "'+sFatherEmail+'", False, "'+BoolToStr(bLeader)+'") ';
qryMain.SQL.Text := 'INSERT INTO Users(Name, Surname, MotherName, FatherName, Gender, Grade, Birthday, School, Address, MotherCell, FatherCell, MotherEmail, FatherEmail, NameTag, Volunteer) ' + 'VALUES(:Name, :Surname, :MotherName, :FatherName, :Gender, :Grade, :Birthday, :School, :Address, :MotherCell, :FatherCell, :MotherEmail, :FatherEmail, False, :Leader) ';
qryMain.Parameters.ParamByName('Name').Value := sName;
qryMain.Parameters.ParamByName('Surname').Value := sSurname;
qryMain.Parameters.ParamByName('MotherName').Value := sMotherName;
qryMain.Parameters.ParamByName('FatherName').Value := sFatherName;
qryMain.Parameters.ParamByName('Gender').Value := cGender;
qryMain.Parameters.ParamByName('Grade').Value := iGrade;
qryMain.Parameters.ParamByName('Birthday').Value := sBirthday;
qryMain.Parameters.ParamByName('School').Value := sSchool;
qryMain.Parameters.ParamByName('Address').Value := sAddress;
qryMain.Parameters.ParamByName('MotherCell').Value := sMotherCell;
qryMain.Parameters.ParamByName('FatherCell').Value := sFatherCell;
qryMain.Parameters.ParamByName('MotherEmail').Value := sMotherEmail;
qryMain.Parameters.ParamByName('FatherEmail').Value := sFatherEmail;
qryMain.Parameters.ParamByName('Leader').Value := bLeader;
ShowMessage('3');
qryMain.ExecSQL;
qryMain.SQL.Text := 'SELECT * FROM Users';
qryMain.Open;
The commented out part was the one way I tried doing this, and it gave this error:
Syntax error (comma) in query expression 'Name="Derp",Surname="Foo",Birthday="1900-01-01"'
The code with parameters gives me this error:
Syntax error (comma) in query expression 'Name="Derp",Surname="Foo",Birthday="1900-01-01"'
Any help would be greatly appreciated!
Now that we can see your real code, your error is clear
'SELECT * FROM Users Where Name = "'+sName+
'", Surname = "'+sSurname+
'", Birthday = "'+sBirthday+'" ';
should use the AND operator to link those conditions :
'SELECT * FROM Users Where Name = "'+sName+
'" AND Surname = "'+sSurname+
'" AND Birthday = "'+sBirthday+'" ';
You should also, naturally, seriously consider parameterizing this query as well.
Using TADOCommand to update a record.
using TADOCommand to insert a new record.
Name of table is Board
Using MS Access database
I get an error
Syntax error in UPDATE/INSERT INTO statement
I can connect and retrieve data just fine. Just never added or updated data before.
My database columns looks like this
ID (auto number)
SN (text)
CardType (text)
Desc (memo)
dbDate (date)
Tech (text)
Code looks like this:
procedure TForm2.BSaveClick(Sender: TObject);
const
sqlStringNew = 'INSERT INTO Board (SN,CardType,Desc,dbDate,Tech) VALUES (:aSN,:aCardType,:aDesc,:aDate,:aTech);';
sqlStringUpdate = 'UPDATE Board SET SN=:aSN, CardType=:aCardType, Desc=:aDesc, dbDate=:aDate, Tech=:aTech WHERE ID = :aID;';
var
ADOCommand : TAdoCommand;
begin
ADOCommand := TADOCommand.Create(nil);
// updating a board
if NewBoard = false then
begin
try
ADOCommand.Connection := adoConnection1;
ADOCommand.Parameters.Clear;
ADOCommand.Commandtext := sqlStringUpdate;
ADOCommand.ParamCheck := false;
ADOCommand.Parameters.ParamByName('aSN').Value := ESerialNumber.Text;
ADOCommand.Parameters.ParamByName('aCardType').Value := ECardType.Text;
ADOCommand.Parameters.ParamByName('aDesc').Value := MDescription.Text;
ADOCommand.Parameters.ParamByName('aDate').Value := strtodate(EDate.Text);
ADOCommand.Parameters.ParamByName('aTech').Value := ETech.Text;
ADOCommand.Parameters.ParamByName('aID').Value := UpdateID;
ADOCommand.Execute;
finally
ADOCommand.Free;
end;
Showmessage('Update Complete');
end;
//if a new board
if NewBoard = True then
Begin
try
ADOCommand.Connection := adoConnection1;
ADOCommand.Parameters.Clear;
ADOCommand.Commandtext := sqlStringNew;
ADOCommand.ParamCheck := false;
ADOCommand.Parameters.ParamByName('aSN').Value := ESerialNumber.Text;
ADOCommand.Parameters.ParamByName('aCardType').Value := ECardType.Text;
ADOCommand.Parameters.ParamByName('aDesc').Value := MDescription.Text;
ADOCommand.Parameters.ParamByName('aDate').Value := strtodate(EDate.Text);
ADOCommand.Parameters.ParamByName('aTech').Value := ETech.Text;
ADOCommand.Execute;
finally
ADOCommand.Free;
end;
NewBoard := false;
BSave.Enabled := false;
NoEdit;
Showmessage('New Record Added');
End;
end;
It is advisable not to use SQL keywords for table and field names. DATE is a function in many SQL dialects. If you choose to use a reserved word/function name for a table/field name, you have to escape it in SQL statement: [Date] for SQL Server and MS Access, "Date" - for Oracle.