Pascal unhandles exception occured - pascal

When I run this procedure
procedure displaydir;
var count:integer;
directoryfile: file of tdir;
directory:array [1..100] of tdir;
begin
assignfile(directoryfile, 'directory.bin');
reset(directoryfile);
count:=0;
repeat
read(directoryfile,directory[count]);
writeln('Name: ',directory[count].name);
writeln('Telephone number: ',directory[count].tel);
writeln('Job title: ',directory[count].jobtitle);
writeln;
writeln;
count:=count+1;
until (directory[count-1].name = 'q');
end;
I get the error
An unhandled exception occurred at $00000000:
EAccessViolation: Access violation
$00000000
$2A005640
$B6F83F97
Unfortunately I couldn't find a solution on the internet, help is much appreciated!

You've declared an array directory as 1..100, but set count to 0 on first run through. directory[ 0] is out of range. You're probably trying to write to read only memory.

Related

how the 'tmpdata' and 'Get_Parameter_List' works in OracleForm?

I am new in OracleForms and Plsql, i found this code in a proyect:
PROCEDURE grabar IS
...
Pl_id paramlist;
...
BEGIN
pl_id := Get_Parameter_List ('tmpdata');
IF NOT Id_Null(pl_id) THEN
Destroy_Parameter_List( pl_id );
END IF;
pl_id := Create_Parameter_List('tmpdata');
i want to konw that if 'tmpdata' does not exist i will get an error?
whit the line:
pl_id := Get_Parameter_List ('tmpdata');
am i inserting the data of 'tmpdata' in 'PL_id'
it is the 'tmpdata' a default variable of Oracleforms or something?
it is not OracleForms but it is a tool based in it so is so similar
I proved to change to:
pl_id := Get_Parameter_List ('tmpdata_HELLO');
enter code hereand the program passed to of this
the console show me this:
may 25, 2018 4:46:30 PM org.apache.tomcat.util.http.Parameters processParameters
INFORMACIÓN: Character decoding failed. Parameter [value] with value [%null] has been ignored. Note that the name and value quoted here may be corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
Note: further occurrences of Parameter errors will be logged at DEBUG level.
In this example, "tmpdata" is the name of a parameter list that may or may not exist. The "ID_NULL" is checking for the existence of the parameter list by checking of the ID returned has a value or not. If it has a value (ie, ID_NULL returns FALSE), then the parameter list is destroyed so that the "Create_Parameter_List" command will not get an error.
"Get_Parameter_List" will not throw an error if there is no parameter list by the given name ("tmpdata", in this case); it just returns null.

Eiffel - Don't know why I have syntax error

I'm new to Eiffel and I'm trying to create a simple class called "Monomio", I have 3 features that are attributes and a feature that's a function. The problem is that I'm getting a syntax error, I compared it to other classes I found but can't find the error here. This is my code
class
MONOMIO
create
make
feature {NONE} -- Initialization
make
-- Initialization for `Current'.
do
end;
coeficiente: INTEGER;
-- El número que será el coeficiente del monomio
exponenteX: INTEGER;
-- El exponente de la variable X
exponenteY: INTEGER;
-- El exponente de la variable Y
evaluar(valX: INTEGER; valY: INTEGER): INTEGER is
do
Result := coeficiente*(valX^expX)*(valY^expY)
end;
end
And this is the error I'm getting:
Syntax error at line 28 in class MONOMIO
evaluar(valX: INTEGER; valY: INTEGER): INTEGER is
---------------------------------------------^
do
I hope anyone can help me with this. Thanks.
I think the problem is the keyword "is". This has been deprecated, and if you are compiling with standard syntax (as you will be by default), then it is an error.
Just remove "is".
The problem of "syntax error" as an uninformative error message is one I have long been complaining about. It is entirely fixable, and no compiler should use it.

How to show only error message oracle raise application error

I am writing oracle triggers and i have some error messages.
I use this code for handling error:
raise_application_error(-20001, 'error message, please do not this');
But this shows very lot info;
For example:
ora-20001: <<custom message>>.
ora-06512: at <<package.procedure_name>>, line 100
I want only show error message body: "error message, please do not this"
Is there a way to do this?
Since I found this question pretty high in my Google search, here is a simple method to just get the error message:
declare
procedure test is
begin
raise_application_error(-20222, 'This is an error');
end test;
begin
test;
exception
when others then
dbms_output.put_line(replace(sqlerrm, 'ORA' || sqlcode || ': ', ''));
end;
Will output:
This is an error
DBMS_OUTPUT.PUT_LINE(REGEXP_REPLACE(SQLERRM, '^ORA-[0-9]+: ', ''));
You can use the SQLERRM function, which will return the exception number and the message, without the lines. There's no function for returning only the text, but you can use SQLCODE function to do that like the second example in this article.
Just remember that this data is mainly intended to help you to cope with unexpected situations in debugging, logging, etc., so most of the time you should consider writing all of the exception info to your log.

BCB: from BDE to dbexpress, BCD exception

I'm having some problem about TSQLStoredProcedure. Here is the code:
storedproc->ParamByName("A")->AsInteger = adataset->FieldByName("AA")->AsInteger;
storedproc->ExecProc();
param "A" is declared integer in the form (and it's 29 in the program). Also the stored procedure has no errors. I'm sure of it. Database is Oracle 11g. By the way, as storedproc is executed an exception occurred:
...
EBcdException with message '<0000001:000000010000000:00000063612>' is not a valid BCD value
...
All was working fine with BDE but now, using dbexpress, there is this problem. I searched over the internet for some days and I did not find an answer.
I thank you in advance and beg a pardon for my English.
Francesco
Update
I searched over the web. I found something interesting at:
https://forums.codegear.com/thread.jspa?messageID=43223&tstart=0
http://www.delphigroups.info/2/8/750511.html
I decide to make some test:
SQLQuery->ParamByName("f1")->AsString = Edit1->Text;
SQLQuery->ExecSQL();
It works. Not the same for
SQLQuery->ParamByName("f1")->AsInteger = StrToInt(Edit1->Text); //ERROR DBX Error: Invalid Field Type.
SQLQuery->ParamByName("f1")->AsFloat = StrToFloat(Edit1->Text); //ERROR DBX Error: Invalid Field Type.
SQLQuery->ParamByName("f1")->AsBCD = StrToInt(Edit1->Text); //ERROR ORA-06502: PL/SQL: error: ... ORA-06512: at line 1.
SQLQuery->ParamByName("f1")->AsFMTBCD = StrToBcd(Edit2->Text); //ERROR ORA-06502: PL/SQL: error: ... ORA-06512: at line 1.
or by using TSQLStoredProc.
So now I call my pl/sql stored proc by TSQLQuery. I use "AsString" to pass values to parameters. Weird. How does dbexpress map types? Thanks in advance.

How to create a user defined function in sybase?

I trying to define a function in sybase. I write this script:
CREATE FUNCTION GetUserGroup (userId int)
RETURNS int
BEGIN
RETURN (10)
END
but when I run this, I get this error:
>[Error] Script lines: 1-6 --------------------------
Incorrect syntax near the keyword 'BEGIN'.
Msg: 156, Level: 15, State: 2
Server: NEWSERVER, Procedure: GetUserGroup, Line: 3
>[Error] Script lines: 1-6 --------------------------
A RETURN statement with a return status may only be used in a SQL stored procedure.
Msg: 178, Level: 15, State: 1
Server: NEWSERVER, Procedure: GetUserGroup, Line: 4
[Executed: 10/13/09 11:01:29 AM IRST ] [Execution: 0/ms]
What can I do?
Thanks
I searched very much in web and other documents, I find that user-defined functions in Adaptive Server Enterprise 12 (ASE) must be implemented in Java.
I decided to use a StordProcedure. It usage is a little hard but it supported in all version of Sybase.
see: http://www.sypron.nl/udf.html
I doesn't find any thing wrong with the code. you can re-try with the code below-
CREATE FUNCTION GetUserGroup (userId int)
RETURNS int
As
BEGIN
RETURN (10)
END
Try This ....it will work
CREATE FUNCTION GetUserGroup (#userId int)
RETURNS int
As
BEGIN
declare #Result int
select #Result=10
RETURN #Result
END
this worked for me.
CREATE FUNCTION GetUserGroup (#userId int)
RETURNS int
AS
BEGIN
select #userId = 10
RETURN #userId
END

Resources