Asterisk start dialpan many times at the same times - asterisk

Please help understand out what's going on.
Asterisk starts dialpan many times for one input call. I use Asterisk 15.4.0 (FreePBX 14.0.5.25), My extensions_custom.conf:
[bpms_input]
exten => _[A-Za-z0-9]!,1,NoOp(>>>>>>>>>>>>>>>>>>>>>>Exten = ${EXTEN} CONTEXT = ${CONTEXT} DATE = ${DATETIME} STATUS = ${DIALSTATUS})
same => n,Wait(10)
Asterisk log:
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000000", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000000", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000001", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000001", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000002", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000002", "10") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000003", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000003", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000004", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000004", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000005", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000005", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000006", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000006", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000007", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
== Setting global variable 'SIPDOMAIN' to '192.168.2.11'
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000007", "10") in new stack
-- Executing [MyTrunk#bpms_input:1] NoOp("PJSIP/MyTrunk-00000008", ">>>>>>>>>>>>>>>>>>>>>>Exten = MyTrunk CONTEXT = bpms_input DATE = STATUS = ") in new stack
-- Executing [MyTrunk#bpms_input:2] Wait("PJSIP/MyTrunk-00000008", "10") in new stack
Edited:
My provider answered to my request. He says "3 Invitations were created by the 3 available active registrations. Each of the invitations to the line". Screenshoot:
Additional info:
On the old FreePBX(10.13.66-8) the problem not was repeated. But I need a fresh version of FreePBX
Additional info 2:
I compare registration request from old and new FreePBX version.
New version additional include parameter "line" to request's contact.
The parameter value is automatically generated each time.
While I can not disable sending this parameter.
I create a trunk in the pjsip.registration_custom.conf file.
But when specifying the parameter "line = no" asterisk full stops registration attempts

Acordinly to your log thoose calls are DIFFERENT(PJSIP/MyTrunk-00000008 is not same as PJSIP/MyTrunk-00000001)
Use tcpdump or sip debug to see packet.
Likly your provider have setup - if no valid response from server - do recall.
P.S Try not use such providers. It is bad sign.

I needed to change the section
[MyTrunk]
type = registration
I deleted the parameter
line = yes
Then the asterisk stopped seeing my trunk by
pjsip show registrations
I have removed the parameter from the same section.
endpoint = MyTrunk
Now all works.
PS: This changes impossible create from UI FrePBX. I have to disable trunk from UI. Then i recreate sections (type=registration, type=identify, type=auth, type=endpoint, type=aor) in pjsip.registration_custom.conf
PS2: Syntax
[MyTrunk] (+)
no work here.

Related

Stored Procedures in EF Core 3.0

How to use stored procedures in EF Core 3.0 ?
I have tried the following
var user = await _context.Query<User>().FromSql("EXECUTE dbo.spGeneral_Authenticate").FirstOrDefaultAsync();
var user = await _context.Query<User>().FromSqlRaw("EXECUTE dbo.spGeneral_Authenticate").FirstOrDefaultAsync();
var user = await _context.Set<User>().FromSql("EXECUTE dbo.spGeneral_Authenticate").FirstOrDefaultAsync();
var user = await _context.Set<User>().FromSqlRaw("EXECUTE dbo.spGeneral_Authenticate").FirstOrDefaultAsync();
EF core translating the SQL in wrong way. I got the translated SQL from log file.
2019-09-27 11:21:36.086 +05:30 [Error] Failed executing DbCommand
("30"ms) [Parameters=[""], CommandType='Text', CommandTimeout='30']"
""SELECT TOP(1) [u].[FullName], [u].[Password], [u].[UserName] FROM (
EXECUTE dbo.spGeneral_Authenticate ) AS [u]" 2019-09-27 11:21:36.154 +05:30 [Error] An exception occurred while iterating over
the results of a query for context type '"__________Context"'."
""Microsoft.Data.SqlClient.SqlException (0x80131904): Incorrect syntax
near the keyword 'EXECUTE'. Incorrect syntax near ')'.
Translated SQL:
SELECT TOP(1) [u].[FullName], [u].[Password], [u].[UserName]
FROM (
EXECUTE dbo.spGeneral_Authenticate
) AS [u]
Microsoft.Data.SqlClient.SqlException (0x80131904): Incorrect syntax
near the keyword 'EXECUTE'. Incorrect syntax near ')'.
For the above error, we should use .ToList() or .ToListAsync() not .FirstOrDefault() or .FirstOrDefaultAsync()
It will work
var user = await _context.Set<User>().FromSql("EXECUTE dbo.spTest").ToListAsync();
It won't work
var user = await _context.Set<User>().FromSql("EXECUTE dbo.spTest").FirstOrDefaultAsync();
/*
Transalated SQL:
SELECT TOP(1) [u].[FullName], [u].[Password], [u].[UserName]
FROM (
EXECUTE dbo.spTest
) AS [u]
*/
The accepted answer nails it. Here are my two cents however:
Also, if you want to get only one result and still want to make the server call asynchronously:
var user = (await _context.Set<User>().FromSql("EXECUTE dbo.spTest").ToListAsync()).FirstOrDefault();

Oracle APEX gives error 'NO DATA FOUND' when trying to fetch value of disabled field of tabular form

I am trying to update a table using update query from oracle apex process. For that I needed a value to be fetch from a tabular form. But that feild is currently disabled (Not editable, value still exist), and here I'm getting error 'ORA-01403: no data found'. If I enabled that field then problem goes (But field will be editable, I don't want to make that field editable).
That data (data of disabled) is already being saved on table(before that field getting disabled). Now I've written a condition for bypassing that error (like. IF APEX_APPLICATION.G_F03(i) IS NOT NULL THEN). But still I'm getting this same error (mentioned above).
So as per shown in below code 'coz of apex_application.g_f03(i) is disabled it gives me error 'ORA-01403: no data found', whereas apex_application.g_f04(i) is not giving me any error. and if I enabled apex_application.g_f03(i) field, then error will be gone.
FOR i IN 1 ..apex_application.g_f01.count LOOP
if ((:P2_M1= 'f03') AND (apex_application.g_f03(i) IS NOT NULL)) then
------------------------------------------------------------------------------------
select count(*) into v_count from SCHEMA1.TABLE1
where ATTRIBUTE_CODE = apex_application.g_f02(i)
and header_id = :P2_X_HEADER_ID
and rating_001 is not null ;
------------------------------------------------------------------------------------
update SCHEMA1.TABLE1
set LAST_UPDATE_DATE = sysdate,
LAST_UPDATED_BY = :F2221_USER_ID,
RATING_001 = apex_application.g_f03(i),
STATUS = 'NEW'
where ATTRIBUTE_CODE = apex_application.g_f02(i)
and header_id = :P2_X_HEADER_ID;
--------------------------------------------------------------
END IF;
if ((:P2_M2 = 'f04') AND (apex_application.g_f04(i) IS NOT NULL)) then
------------------------------------------------------------------------------------
select count(*) into v_count from SCHEMA1.TABLE1
where ATTRIBUTE_CODE = apex_application.g_f02(i)
and header_id = :P2_X_HEADER_ID
and rating_002 is not null ;
------------------------------------------------------------------------------------
update SCHEMA1.TABLE1
set LAST_UPDATE_DATE= sysdate,
LAST_UPDATED_BY = :F2221_USER_ID,
RATING_002 = apex_application.g_f04(i),
STATUS = 'NEW'
where ATTRIBUTE_CODE = apex_application.g_f02(i)
and header_id = :P2_X_HEADER_ID;
------------------------------------------------------------------------------------
END IF;
end loop;
I expected either to get the value of this apex_application.g_f03(i) field (even if it is disabled) or bypass it.
This is standard behaviour of any HTML form, not just APEX. If any input is set to disabled then its value is not posted when the form is submitted. If you can set it to readonly instead then the user will still be unable to edit it, but its value will be posted on submit.

delete query in ssis package with 2 or more parameters in execute SQl Task

I am new to SSIS I want to execute delete query in my SSIS package thorough Execute Sql Task having 2 or more parameters. If I use 1 parameter it's working fine but if more than 1 than error. I don't want to use SP's and please help me as I am stuck from a long time.
General
TimeOut = 0
Typeconversionmode - Allowed
Result Set - None
ConnectonType - OLE DB
Connection = MyConnection
SqlSource = DirectInput
SqlStatment="delete from tblStgPaymentProcessingACH where id=? and paymentid=?"
BypassPrepare = True
Variables
Name = ID , Scope = MyJOB, DataType=int64, Value=2
Name = PMTID , Scope = MyJOB, DataType=int64, Value=101161419602
Parameter Mapping
User::ID, Direction = input, datatype = LONG, ParameterName = 0, ParamtereSize = 0
User::PMTID, Direction = input, datatype = LONG, ParameterName = 1, ParamtereSize = 0
Database DataTypes
Column
ID - INT
Paymentid - Bigint
Getting Error
[Execute SQL Task] Error: Executing the query "delete from mytable
where id=..." failed with the following error: "An error occurred while extracting the result into a variable of type (DBTYPE_I4)". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Highest record in PL/SQL

I have created a query that displays highest returned items from a table. My query it works perfectly with no errors! However, I want an efficient way of converting the query to PL/SQL block. The purpose of conversion is to handle errors.
SELECT ITEM_NO, MAX(QUANTITY) AS MAXIMUM
FROM ITEMS
WHERE CAT_NO >= (
SELECT MAX(ITEM_NUM) FROM ORDER
WHERE STATUS IN('ONE ITEM RETURNED','ALL ITEMS RETURNED')
)
GROUP BY ITEM_NO
ORDER BY ITEM_NO ASC;
Here's a way we do some exception handling in packages. I altered it to use your code as an example. Maybe you can use some ideas from it.
At the top, set a CONSTANT to the name of the procedure, and some variables to catch Oracle SQL error number and message in. Then in the body of the procedure, there is an anonymous block containing the select. First we set a variable to indicate where we are (err_loc) in case there are multiple locations where an error could be caught in one block. Then the select is issued. If an error occurs, it's caught by the EXCEPTION clause. Error info from Oracle is caught in the err* variables, the err_string is built and then emailed via the UTL_MAIL package. RAISE raises the error so the program halts. It's set up like this to be generic as possible, we can drop in the template, change the MBR_NAME, SQL, err_loc and that's it.
PROCEDURE TEST_PROC AS
MBR_NAME CONSTANT VARCHAR2(100) := 'TEST_PROC'; -- For use in error handling. Package member name.
err_nbr NUMBER; -- Holds a SQL error number if an exception occurs.
err_msg VARCHAR2(1000); -- Holds a SQL error message if an exception occurs.
err_string VARCHAR2(2000);
BEGIN
BEGIN
err_loc := 'Selecting max quantity'; -- Email subject
SELECT ITEM_NO, MAX(QUANTITY) AS MAXIMUM
FROM ITEMS
WHERE CAT_NO >= (SELECT MAX(ITEM_NUM)
FROM ORDER
WHERE STATUS IN('ONE ITEM RETURNED','ALL ITEMS RETURNED')
)
GROUP BY ITEM_NO
ORDER BY ITEM_NO ASC;
EXCEPTION
WHEN OTHERS THEN
err_nbr := SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 1000);
err_string := 'ERROR: ' || err_nbr || ' occurred: ' || err_msg;
-- PKG_NAME and err_email_recip set in the body.
UTL_MAIL.send(sender => PKG_NAME||'.'||MBR_NAME||'#yourcompany.com',
recipients => err_email_recip,
subject => 'ERROR '|| err_loc,
message => CHR(13))||err_string);
RAISE;
END;
END TEST_PROC;
Have a look at cursors and records.
That way you have fetch data from the query and process the line if needed.
I don't have a database by hand to test my code, but this might give you an idea how a cursor and record work.
In order to capture a EXCEPTION you could add an exception handler and let it log the record you where busy with when the exception occured.
DECLARE
CURSOR CursorName IS
SELECT ColumnOne
FROM TableA
WHERE Name = 'Me';
RecordNumber CursorName%ROWTYPE;
BEGIN
-- Fetch the records from the cursor.
OPEN CursorName;
LOOP
FETCH CursorName INTO RecordNumber;
-- Do something with the record.
EXIT WHEN CursorName %NOTFOUND;
END LOOP;
CLOSE CursorName;
END;
/
Adding a error handeling would be done right above END:
EXCEPTION
WHEN OTHERS THEN
-- Log error message.
END;
/
Link: Error handeling
Does that answer you question a bit?

Oracle AFTER INSERT Trigger

The following trigger will not fire. The trigger worked before adding the 'SELECT c.deposit_id … piece of code. Any help will be greatly appreciated. The trigger is meant to fire after an insert is made on CASH_OR_CREDIT table if the foreign key in this table is found to be linked to another table (TRANSACTION_TABLE).
`
CREATE OR REPLACE TRIGGER SEND_MONEY
AFTER INSERT
ON cash_or_credit
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
system_header_info NUMBER := 0;
l_dep_key NUMBER := 0;
CURSOR cur (cover_id NUMBER)
IS
SELECT header_id
FROM headers
WHERE party_site_id = cover_id;
system_header_info VARCHAR2 (10)
:= schema.necessay_functions.get_system_id ('DEPOSITS');
BEGIN
fnd_profile.put ('company_debugger', 'Y');
schema.necessay_functions.debugger ('old.deposit_id =' || :OLD.deposit_id);
schema.necessay_functions.debugger ('new.deposit_id =' || :NEW.deposit_id);
OPEN cur (system_header_info);
system_header_info := 0;
FETCH cur1 INTO system_header_info;
CLOSE cur1;
schema.necessay_functions.debugger (
'super_user.user_id =' || super_user.user_id);
schema.necessay_functions.debugger (
schema.necessay_functions.obtain_user_id (
schema.necessay_functions.get_system_id ('DEPOSITS')));
SELECT c.deposit_id
INTO l_dep_key
FROM schema.transaction_table o,
schema.linker_table r,
schema.cash_or_credit c
WHERE o.primary_key = r.primary_key
AND o.table_name = 'INDIVIDUAL_REC'
AND o.system_id = '265226'
AND o.status = 'A'
AND r.status = 'A'
AND c.foreign_key = r.primary_key
AND c.deposit_id = :NEW.deposit_id
AND r.relationship_code IN ('EMPLOYER_OF');
IF super_user.user_id =
schema.necessay_functions.obtain_user_id (
schema.necessay_functions.get_system_id ('DEPOSITS'))
AND l_dep_key = :NEW.deposit_id
THEN
schema.necessay_functions.debugger ('Inside If Condition');
FOR sys_comp
IN (SELECT *
FROM schema.transaction_table
WHERE status = 'A'
AND table_name = 'DEPOSITS'
AND primary_key = :NEW.deposit_id
AND system_id =
schema.necessay_functions.get_system_id (
'DEPOSITS'))
LOOP
schema.necessay_functions.debugger ('Inside Loop');
schema.necessay_functions.send_xml_message ('SEND_SYSTEM_MSG',
'SEND.UPDATE',
system_header_info,
sys_comp.system_id,
sys_comp.system_key);
END LOOP;
ELSE
schema.necessay_functions.send_xml_message ('SEND_SYSTEM_MSG',
'SEND.CREATE',
system_header_info,
system_header_id,
:NEW.deposit_id);
END IF;
EXCEPTION
WHEN OTHERS
THEN
schema.necessay_functions.debugger ('Sqlerrm:' || SQLERRM);
END SEND_MONEY;
/`
If it works without the SELECT c.deposit_id … piece then, presumably, that is what is causing an exception which is then being swallowed by the WHEN OTHERS exception handler being used and causing the trigger to look like it is not firing. You should be able to confirm that by checking whatever table/log schema.necessay_functions.debugger( is logging to.
What are the business rules around the l_dep_key value? Specifically, is it expected that the SELECT statement used to populate l_dep_key will always return a result (and only 1 result at that)? If so, at the very least wrap that statement with an anonymous block and explicitly handle any exceptions that conflict with those business rules.
BEGIN
SELECT c.deposit_id
INTO l_dep_key
FROM schema.transaction_table o,
schema.linker_table r,
schema.cash_or_credit c
WHERE o.primary_key = r.primary_key
AND o.table_name = 'INDIVIDUAL_REC'
AND o.system_id = '265226'
AND o.status = 'A'
AND r.status = 'A'
AND c.foreign_key = r.primary_key
AND c.deposit_id = :NEW.deposit_id
AND r.relationship_code IN ('EMPLOYER_OF');
EXCEPTION
WHEN NO_DATA_FOUND THEN
...TAKE APPROPRIATE ACTION HERE...
...POSSIBLY LOG AND RAISE...
WHEN TOO_MANY_ROWS THEN
...TAKE APPROPRIATE ACTION HERE...
...POSSIBLY LOG AND RAISE...
END;
As OldProgrammer stated in a comment, the exception handling in your provided code has much room for improvement. Should you really be swallowing any and all exceptions that may be thrown by the code in this trigger?
Also, as a general tip, when logging exceptions instead of just logging SQLERRM use DBMS_UTILITY.FORMAT_ERROR_BACKTRACE() instead, as it gives you more context around the exception. Future you and/or future debuggers of this will thank you for it.
Thank you for all of your advice and input. I solved the problem. The exception text revealed that the table mutates when you attempt to query it leading to the trigger failure. The trick to checking the validity of the child table to the parent table after an INSERT and allowing the trigger to fire is to remove the reference to the child (trigger) table and to perform the join using :NEW.foreign_key to join to the parent table. I learned a lot while trying to debug this :)
BEGIN
SELECT COUNT(1)
INTO l_dep_key
FROM schema.transaction_table o,
schema.linker_table r
WHERE o.primary_key = r.primary_key
AND o.table_name = 'INDIVIDUAL_REC'
AND o.system_id = '265226'
AND o.status = 'A'
AND r.status = 'A'
AND o.foreign_key = r.primary_key
AND r.primary_key = :NEW.foreign_key
AND r.relationship_code IN ('EMPLOYER_OF');

Resources