Access violation at address 04FD6CC2 in module 'dbxora.dll'. Read of address 00000004 - access-violation

I have created DELPHI database application which will use DBX TSQLConnection component to connect to Oracle database (19c version).
I'm getting access violation error , When i call oracle listagg function (SQLQuery1.open --in this line).
When i debugged , i got the error in below object file,
FileName : Data.DBXDynalink.pas
Function : function TDBXDynalinkReader.DerivedNext: Boolean;
Error Line : DBXResult := FMethodTable.FDBXReader_Next(FReaderHandle);
Actual Error : Access violation at address 04FD6CC2 in module 'dbxora.dll'. Read of address 00000004
Below is my code ,
...SQLQuery1 initialization....
SQLQuery1.CommandText := Trim(memoSQLText.Lines.Text); // Assigning query
SQLQuery1.Open; // Exactly on this line i'm getting error
if SQLQuery1.RecordCount > 0 then
....Do something here....
Note : Same query is executing in other versions which are all below to Oracle version 19C (19.3)
IDE version used for application development : DELPHI XE3 (i have checked with DELPHI 10.1 Berlin also)
DB version : Oracle 19C (19.3)
Steps to reproduce :
// 1.Execute below queries in order to create testing data ,
create table myuserlist(myuser varchar2(10));
Insert into myuserlist(myuser) values('karthik');
Insert into myuserlist(myuser) values('aarush');
Insert into myuserlist(myuser) values('yuvan');
// 2.Try to open the below mentioned query using TSQLConnection and TSQLQuery
select listagg(a.myuser, ', ') within group (order by a.myuser) as myusernames from myuserlist a
Sample project is available in the GitHub,
https://github.com/yuvankarthik/DELPHI-DemoOracleConnect.git
Help me to resolve this issue.

Related

How to use the ENCRYPT function on Firebird?

I'm new to using the Firebird Database Management System and I need to use the ENCRYPT function in my project.
In my project I have been trying to use the following statement for testing:
INSERT INTO state (name)
values (ENCRYPT('MG' using aes mode cbc key 'password' iv '01234567'));
But I have been getting the following Firebird error:
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 43
-(
I accessed the documentation and the only example I found there was:
select encrypt('897897' using sober128 key 'AbcdAbcdAbcdAbcd' iv '01234567')
from rdb$database;
The structure of the function is:
ENCRYPT (input
USING <algorithm> [MODE <mode>]
KEY key
[IV iv] [<ctr_type>] [CTR_LENGTH ctr_length]
[COUNTER initial_counter] )
I already tried several modifications in the instruction, but I didn't succeed. Could anyone help me with fixing this problem?

SQL Error -4903 when trying to connect to DB2 database

I am getting an SQL error code of -4903 when trying to connect to a DB2 database using SQC code (this is an ANSI C application so I need to use SQC for SQL queries). When I look at IBM's website to see what a -4903 means, all it says is "The length of parameter n of function name is not valid". However I have no idea which parameter or function it is referring to. I have tried looking at the SQLCA objects members, but I am unable to see them in Visual Studio 2015.
This is an ANSI C application debugging in Visual Studio 2015. I am able to connect to the same database using a DB2 command prompt (i.e, by running "db2 connect to dbname user username using password". However when I try to do this in code I get the -4903 error. I have also tried this on two different OS's, Windows 7 and Windows 10. I have colleagues who have had no trouble doing this on a Windows 7 machine.
while ((retry++ < 3)
|| (sqlca.sqlcode == -30080)
|| (sqlca.sqlcode == -900 ) )
{
EXEC SQL CONNECT TO :DBName USER :userid USING :pword;
if ((SQLCODE == 0 ) || (SQLCODE == (-1026)))
{
return(1);
}
else
{
dbLogAudit(KLCB, PLCB, KLLOGSEV(T),
"Retry DBInit/sqlca.sqlcode : %i", sqlca.sqlcode);
}
}
I expect the SQLCODE to be 0, which indicates a successful connection, and for the function to return 1 to it's caller. But instead the sqlca.sqlcode variable is -4903 (which I described above).
EDIT: I found the parameters being passed into the error message. The full error text is "The length of parameter runtime_pid of function sqlastrt_trusted is not valid".
I solved my own issue. Thanks to Mao for the help on debugging this one.
My development environment for DB2 was running version 8.1.0, which uses 162 bytes for the struct called "sqla_program_id". However, the runtime environment, which uses 292 bytes for that same struct, was version 10.5. Once I upgraded my development DB2 instance to v10.5 it worked like a charm.

When trying to connect to Microsoft Azure from an external source I get the following error:

When trying to connect to Microsoft Azure from an external application source (SNAPPII) I get the following error:
I am using an XML template as supplied by SNAPPII tech support but they are unable to pinpoint the issue.
Can anyone help pinpoint the issue?
Error during query execution. Try to check the Data Source Configuartion.
Error : ERROR [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]Reference to database and/or server name in ‘ODBC.dbo.TableName’ is not supported in this version of SQL Server
I have enclosed a code for xml file below.
I believe this type of connection should work with Microsoft Azure databases but to be honest I am a complete newbie in this environment.
<ext_db_settings>
<connection_strings>
<connection_string name="foreland"><![CDATA[Driver={SQL Server Native Client 10.0}; Server=tcp:ianm.database.windows.net; Database=foreland; Uid=ian.marks#ianm; Pwd=xxxxx; Encrypt=yes;]]></connection_string>
</connection_strings>
<query command="select" connection_string_name="foreland" type="sql" cache_timeout="0" max_size="5">
<body><![CDATA[
SELECT *
FROM [ODBC].[dbo].[TableName]
]]></body>
</query>
<query command="add" connection_string_name="foreland" type="sql">
<body><![CDATA[
INSERT INTO [TableName]
(
Id,
Name,
Age,
Residence
)
VALUES
(
'[set.Id]',
'[set.Name]',
'[set.Age]',
'[set.Residence]'
)
]]></body>
</query>

Oracle PL/SQL debug procedure - using $$plsql_line

I'm looking to create a procedure that helps with debugging specific variables, and for the sake of re-usability I'd like to store it in it's own procedure and pass in the specific variable when needed such as
debugz(var_x);
and the debug procedure would do the following -
PROCEDURE debugz (var_x VARCHAR2(1000))
AS
BEGIN
DBMS_OUTPUT.put_line ('Variable value: '|| var_x || ' | Line number: ' || $$plsql_line ||' | Unit: '|| $$plsql_unit);
END;
The problem is, I want the PL/SQL line number and PL/SQL unit to be based off of where the procedure call originates, i.e. the line/unit of "debugz(var_x);". Is there anyway for debugz to output that line number without passing in additional information?
Check out DBMS_UTILITY.FORMAT_CALL_STACK
You may need/want to parse the output depending on your exact requirements, but may be a good place to start.
Oracle 10g onwards.
Also note DBMS_UTILITY.FORMAT_ERROR_BACKTRACE and DBMS_UTILITY.FORMAT_ERROR_STACK for error handling.
There is a very good debugging package unit called debugf which provides good functionality
The debug file contains information such as session id,date and time,packages being called and the line number of each debug message and the debug message itself
Example usage is given below
This is used to intialize the debug, the first parameter 'ALL' meaning all modules(can be function,procedure or package etc) and SYSTEM meaning the schema i want to debug
debug.init(p_modules => 'ALL',p_file =>'C:\debugf123\temp\test.txt',p_user =>'SYSTEM',p_show_date => 'YES',p_date_format =>'DD/MM/YYYY HH24:MI:SS',p_name_len => 30,p_show_sesid => 'YES');
This one works like printf in C and the maximum you can give is 10 parameters where v_word1 is a parameter
debug.f('the first is %s',v_word1);
This is same as debug.f but here you can give more than 10 parameters
debug.fa('the third is %s and %s',debug.argv(v_word1,v_amount));
The source code for this package is available at
http://gerardnico.com/wiki/database/oracle/debugf
OWA_UTIL.WHO_CALLED_ME(
owner OUT VARCHAR2,
name OUT VARCHAR2,
lineno OUT NUMBER,
caller_t OUT VARCHAR2);
Have you tried remote debugging? Here's how you can do it in SQL Developer:
1) Reference:
http://sueharper.blogspot.ca/2006/07/remote-debugging-with-sql-developer_13.html
2) User privileges:
grant EXECUTE on DBMS_DEBUG_JDWP to USERXX;
grant DEBUG CONNECT SESSION to USERXX;
grant DEBUG ANY PROCEDURE to USERXX;
3) Set Remote Debug on USERXX connection in SQL Developer:
Port: 80 (use 4000 if not blocked by firewall)
Local Address: IP address of your local machine
4) Compile code (package, procedure or function) in USERXX in SQL Developer for debug
5) Set breakpoints in code
6) On the remote (this could be your application invoking the PLSQL code):
before invoking the PLSQL code run/include the following:
DBMS_DEBUG_JDWP.CONNECT_TCP( 'IP address in 3', port in 3 ) when this is run SQL developer will switch to debug mode.
7) Run application or invoke procedure from remote as USERXX
8) SQL developer stops at first breakpoint, step into, view/change values and etc.

Firebird UDF creation failure

I have a firebird database that I need to recreate. It contains an external UDF function. I made an SQL dump of the DB structure using IB Expert:
DECLARE EXTERNAL FUNCTION LPAD
CSTRING(255),
INTEGER,
CSTRING(1)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_udf'
However, I get an error when I run the query:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 27.
'LPAD'.
I'm using Firebird 2.1.1 on Windows. Does anyone know what might be the problem?
try this
DECLARE EXTERNAL FUNCTION "LPAD"
CSTRING(255),
INTEGER,
CSTRING(1)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_udf'