Situation 1 :
p_start_date = 13.Apr.2012 13:00
p_end_date = 13.Apr.2012 15:00
working_hours = 0
// in this Situation working_hours should be 2
Situation 2 :
p_start_date = 13.Apr.2012 13:00
p_end_date = 14.Apr.2012 15:00
working_hours = 24
// in this Situation working_hours should be 26
When i run this on SQLDevelopper with Situation 1 and Situation 2, values for working_hours is return correctly. but i call this Procedure in Before Insert Update Trigger for use in my apex application. when i submit tabular form with Situation 1, value for working_hours is 0 and when i submit tabular form with Situation 2, value for working_hours is 24.
According to Situation 1 and Situation 2, difference between two dates assign to working_hours. but my need is get difference between two times.
How could i do that ?
My Procedure to calculate working_hours is,
PROCEDURE get_labour_cost_data(
p_employee_id IN NUMBER,
p_start_date IN VARCHAR2,
p_end_date IN VARCHAR2,
hours_normal_rate OUT NUMBER,
working_hours OUT NUMBER,
total_cost OUT NUMBER)
AS
v_employee_rate NUMBER;
BEGIN
if p_employee_id is null then
hours_normal_rate := 0;
working_hours := 0;
total_cost := 0;
elsif p_employee_id is not null then
-- Get hourse_noraml from employee
select HOURLY_SALARY into hours_normal_rate from Employee
where EMPLOYEE_ID = p_employee_id;
-- Get working hours
working_hours := 24 * (to_date(p_end_date, 'dd.mm.rr hh24:mi') - to_date(p_start_date, 'dd.mm.rr hh24:mi'));
-- Get Total cost
total_cost := nvl(hours_normal_rate,0) * nvl(working_hours,0);
end if;
END;
Trigger is,
create or replace
TRIGGER LABOUR_COST_BIU_TRI
BEFORE INSERT OR UPDATE ON LABOUR_COST
FOR EACH ROW
DECLARE
v_hours_normal NUMBER;
v_working_hours NUMBER;
v_total_cost NUMBER;
BEGIN
util.get_labour_cost_data(
p_employee_id => :NEW.EMPLOYEE_ID,
p_start_date => :NEW.START_DATE_TIME,
p_end_date => :NEW.END_DATE_TIME,
hours_normal_rate => v_hours_normal,
working_hours => v_working_hours,
total_cost => v_total_cost
);
select v_hours_normal, v_working_hours, v_total_cost into :NEW.HOURS_NOMAL, :NEW.HOURS_OT, :NEW.TOTAL_COST
from dual;
END;
When I create and run your procedure alone it works:
declare
hours_normal_rate NUMBER;
working_hours NUMBER;
total_cost NUMBER;
begin
get_labour_cost_data(
1,
'13.Apr.2012 13:00',
'13.Apr.2012 15:00',
hours_normal_rate,
working_hours,
total_cost);
dbms_output.put_Line(working_hours);
END;
Output:
2
And:
declare
hours_normal_rate NUMBER;
working_hours NUMBER;
total_cost NUMBER;
begin
get_labour_cost_data(
1,
'13.Apr.2012 13:00',
'14.Apr.2012 15:00',
hours_normal_rate,
working_hours,
total_cost);
dbms_output.put_Line(working_hours);
END;
Output:
25.99999999999999999999999999999999999992
(Close!)
I can't see any problem with the way you use it in the trigger, though that could be simplified to:
create or replace
TRIGGER LABOUR_COST_BIU_TRI
BEFORE INSERT OR UPDATE ON LABOUR_COST
FOR EACH ROW
BEGIN
util.get_labour_cost_data(
p_employee_id => :NEW.EMPLOYEE_ID,
p_start_date => :NEW.START_DATE_TIME,
p_end_date => :NEW.END_DATE_TIME,
hours_normal_rate => :NEW.HOURS_NOMAL,
working_hours => :NEW.HOURS_OT,
total_cost => :NEW.TOTAL_COST
);
END;
Related
We have a view which contains 2 columns: pattern_start_time, pattern_end_time.
The select query in the function will convert it to minutes and using that result we are processing to get the shift unused coverage.The function is getting created but the processing is not happening and getting the below error:
SQLError[IX000]:Routine (my_list) cant be resolved.
Also please enter image description heresuggest to loop till the length of the result.
CREATE function myshifttesting(orgid int) returning int;
DEFINE my_list LIST( INTEGER not null );
DEFINE my_list1 LIST( INTEGER not null );
define i, j, sub, sub1 int;
define total int;
TRACE ON;
TRACE 'my testing starts';
INSERT INTO TABLE( my_list )
select
((extend(current, year to second) + (dots.v_shift_coverage.pattern_start_time - datetime(00:00) hour to minute) - current)::interval minute(9) to minute)::char(10)::INTEGER
from
dots.v_shift_coverage
where
org_guid = orgid;
INSERT INTO TABLE( my_list1 )
select
((extend(current, year to second) + (dots.v_shift_coverage.pattern_end_time - datetime(00:00) hour to minute) - current)::interval minute(9) to minute)::char(10)::INTEGER
from
dots.v_shift_coverage
where
org_guid = orgid;
let sub = 0;
let sub1 = 0;
let total = 0;
for j = 0 to 4
if (my_list(j) < my_list1(j))
then
if (my_list(j + 1) > my_list1(j))
then
let sub = sub + my_list(j + 1) - my_list1(j);
end if;
end if;
end for
if (my_list(0) > my_list1(4))
then
let sub1 = my_list(0) - my_list1(4);
end if;
let total = sub + sub1;
return total;
end function;
The error that you are receiving is because my_list(j) is not valid Informix syntax to access a LIST element. Informix is interpreting my_list(j) as a call to a function named mylist.
You can use a temporary table to "emulate" an array with your logic, something like this:
CREATE TABLE somedata
(
letter1 CHAR( 2 ),
letter2 CHAR( 2 )
);
INSERT INTO somedata VALUES ( 'a1', 'a2' );
INSERT INTO somedata VALUES ( 'b1', 'b2' );
INSERT INTO somedata VALUES ( 'c1', 'c2' );
INSERT INTO somedata VALUES ( 'd1', 'd2' );
INSERT INTO somedata VALUES ( 'e1', 'e2' );
DROP FUNCTION IF EXISTS forloop;
CREATE FUNCTION forloop()
RETURNING CHAR( 2 ) AS letter1, CHAR( 2 ) AS letter2;
DEFINE number_of_rows INTEGER;
DEFINE iterator INTEGER;
DEFINE my_letter1 CHAR( 2 );
DEFINE my_letter2 CHAR( 2 );
-- Drop temp table if it already exists in the session
DROP TABLE IF EXISTS tmp_data;
CREATE TEMP TABLE tmp_data
(
tmp_id SERIAL,
tmp_letter1 CHAR( 2 ),
tmp_letter2 CHAR( 2 )
);
-- Insert rows into the temp table, serial column will be the access key
INSERT INTO tmp_data
SELECT 0,
d.letter1,
d.letter2
FROM somedata AS d
ORDER BY d.letter1;
-- Get total rows of temp table
SELECT COUNT( * )
INTO number_of_rows
FROM tmp_data;
FOR iterator = 1 TO number_of_rows
SELECT d.tmp_letter1
INTO my_letter1
FROM tmp_data AS d
WHERE d.tmp_id = iterator;
-- Check if not going "out of range"
IF iterator < number_of_rows THEN
SELECT d.tmp_letter2
INTO my_letter2
FROM tmp_data AS d
WHERE d.tmp_id = iterator + 1;
ELSE
-- iterator + 1 is "out of range", return to the beginning
SELECT d.tmp_letter2
INTO my_letter2
FROM tmp_data AS d
WHERE d.tmp_id = 1;
END IF;
RETURN my_letter1, my_letter2 WITH RESUME;
END FOR;
END FUNCTION;
-- Running the function
EXECUTE FUNCTION forloop();
-- Results
letter1 letter2
a1 b2
b1 c2
c1 d2
d1 e2
e1 a2
5 row(s) retrieved.
Good morning,
I'm having troubles to integrate a working query into a stored procedure.
My main issue, is that I'm using a WHILE loop with an integer, and that the stored procedure is having troubles with it.
My working query/code is the following:
CREATE TABLE #tempScaffStandingByTime
(
TotalStanding INT,
MonthsAgo INTEGER
)
DECLARE #StartDate DATETIME = null
DECLARE #months INTEGER = 12
use [Safetrak-BradyTechUK]
WHILE #months >= 0
BEGIN
SET #StartDate = DATEADD(mm, -12 + #months, DATEADD(mm, 0, DATEADD(mm,
DATEDIFF(mm,0,GETDATE()-1), 1)))
INSERT INTO #tempScaffStandingByTime
select TOP 1 COUNT(*) OVER () AS TotalRecords, #months
from asset a
join wshhistory h on h.assetid = a.uid
where a.deleted = 0 and h.assetstate <> 6
AND (dbo.getdecommissiondate(a.uid) > #StartDate)
group by a.uid
SET #months -= 3
END
SELECT * FROM #tempScaffStandingByTime
DROP TABLE #tempScaffStandingByTime
This results in the input which I want:
I then tried to import this code into my stored procedure
DECLARE #Query varchar (8000)
, #Account varchar (100) = 'BradyTechUK'
SET #Account = 'USE [Safetrak-' + #Account + ']'
/************************************************************************************/
/********** Create Table to hold data ***********************************************/
CREATE TABLE #tempScaffStandingByTime
(
TotalStanding INT,
MonthsAgo INTEGER
)
/************************************************************************************/
/********** Populate temp table with data *******************************************/
DECLARE #StartDate DATETIME = null
DECLARE #months INTEGER = 12
SET #Query= +#Account+ '
WHILE '+#months+' >= 0
BEGIN
SET '+#StartDate+' = DATEADD(mm, -12 + ('+#months+', DATEADD(mm, 0, DATEADD(mm, DATEDIFF(mm,0,GETDATE()-1), 1)))
INSERT INTO #tempScaffStandingByTime
select TOP 1 COUNT(*) OVER () AS TotalRecords, '+#months+'
from asset a
join wshhistory h on h.assetid = a.uid
where a.deleted = 0 and h.assetstate <> 6
AND (dbo.getdecommissiondate(a.uid) > '+#StartDate+')
group by a.uid
SET '+#months+' -= 3
END'
EXEC (#Query)
/************************************************************************************/
/********** Select Statement to return data to sp ***********************************/
Select TotalStanding
, MonthsAgo
FROM #tempScaffStandingByTime
/************************************************************************************/
DROP TABLE #tempScaffStandingByTime
But when loading the stored procedure in SSRS I get a conversion error.
I can convert my parameter to a string, but then it won't count anymore.
I searched far and wide on the internet, tried various things, but can't get it to work.
Any help is appreciated, thanks!
It looks like your problem original comes from the lack of conversion between the INT in #months and your VARCHAR in #Accounts and #Query.
You need to cast the months to a string to append it, otherwise the SQL Server thinks you're trying to do addition.
However you'll also have problems with the usage of your #StartDate variable as you try to set it via your dynamic SQL which is not going to work like that - and as with #months it'll have an incorrect datatype, but I'm also unsure why it's written as is, and what you're tying to achieve with it
I think - from what you're writing - that this might be what you're looking for?
SET #Query= #Account + '
DECLARE #StartDate DATETIME = null
DECLARE #months VARCHAR(2) = ''12''
WHILE #months >= 0
BEGIN
SET #StartDate = DATEADD(mm, -12 + #months, DATEADD(mm, 0, DATEADD(mm, DATEDIFF(mm,0,GETDATE()-1), 1)))
INSERT INTO #tempScaffStandingByTime
select TOP 1 COUNT(*) OVER () AS TotalRecords, #months, #StartDate
from asset a
join wshhistory h on h.assetid = a.uid
where a.deleted = 0 and h.assetstate <> 6
AND (dbo.getdecommissiondate(a.uid) > #StartDate)
group by a.uid
SET #months -= 3
END'
EXEC (#Query)
I am having a problem with the procedure below as whenever I pass a date of month and year, the IF condition loops on the number of records that exists in my table- only two rows existed- and also it shows the two possibilities. I also included the result to show what I mean!
PRODUCT_NUM ORDER_NUM QUANTITY PRICE MONTHLY_DATE
-------------- ----------- ------------- ------------ -------------
12345 106 3 19.99 21-DEC-15
67894 107 1 19.99 21-DEC-15
CREATE OR REPLACE PROCEDURE Proce_Name (Pram_Date DATE )
AS
BGIN
FOR Y IN
(SELECT SUM(PRICE) AS TOTAL_AMOUNT, SUM(NVL(QUANTITY,0) * NVL (
(PRICE,0)) AS TOTAL, MONTHLY_DATE
FROM PRODUCTS
GROUP BY MONTHLY_DATE
ORDER BY MONTHLY_DATE DESC) LOOP
IF TO_CHAR( Y.MONTHLY_DATE, 'mm-yyyy')= TO_CHAR(Pram_Date,'mm-yyyy') THEN
DBMS_OUTPUT.PUT_LINE('TOTAL AMOUNT: '|| ' '|| Y.TOTAL_AMOUNT);
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('TOTAL: '|| ' '|| Y.TOTAL);
ELSE
DBMS_OUTPUT.PUT_LINE('No Data for this month');
END IF;
END LOOP;
END Proce_name;
calling block:
DECLARE
MONTHLY_D DATE := TO_DATE('01-2012','mm-yyyy');
BEGIN
Proce_Name(MONTHLY_D);
END;
/
This is when the date I pass matches the records in the table:
No Data for this month
TOTAL AMOUNT: 4
TOTAL: 99.96
The result here when I pass a date that is not existed in the table:
No Data for this month
No Data for this month
How can I alter my procedure to examine the above date format accurately ?
Here is the code, you can consider exception handling as well:
Few observations, you an consider prem_date as char it self instead of passing date. Also if data set is huge and monthly_date is indexed, you should avoid applying to_char condition on monthly_date.
CREATE OR REPLACE PROCEDURE Proce_Name (Pram_Date DATE )
AS
l_total_amount float;
l_total float;
BEGIN
SELECT SUM(PRICE) AS TOTAL_AMOUNT,
SUM(NVL(QUANTITY,0) * NVL(PRICE,0)) AS TOTAL
INTO l_total_amount, l_total
FROM PRODUCTS
WHERE to_char(monthly_date, 'mm-yyyy') = to_char(pram_date, 'mm-yyyy');
if(l_total_amount is not null) then
DBMS_OUTPUT.PUT_LINE('TOTAL AMOUNT: '|| ' '|| L_TOTAL_AMOUNT);
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('TOTAL: '|| ' '|| L_TOTAL);
else
DBMS_OUTPUT.PUT_LINE('No Data for this month');
end if;
END Proce_name;
/
I have update procedure as following
CREATE OR REPLACE PROCEDURE get_sales_report(c_date date) AS
l_amount number(18, 2);
l_total number(18, 2);
BEGIN
begin
SELECT SUM(PRICE), SUM(NVL(QUANTITY, 0) * NVL(PRICE, 0))
into l_amount, l_total
FROM product
where TO_CHAR(MONTHLY_DATE, 'mm-yyyy') = to_char(c_date, 'mm-yyyy')
GROUP BY TO_CHAR(MONTHLY_DATE, 'mm-yyyy')
ORDER BY TO_CHAR(MONTHLY_DATE, 'mm-yyyy') DESC;
DBMS_OUTPUT.PUT_LINE('TOTAL AMOUNT: ' || ' ' || l_amount);
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('TOTAL: ' || ' ' || l_total);
exception
when no_data_found then
DBMS_OUTPUT.PUT_LINE('No Data for this month');
END; -- end of exception
-- add your code here
-- add your code here
-- add your code here
end;
Also call following command for dbms_output echoing text.
set serveroutput on size 30000;
Call your procedure as
declare
c_date2 DATE := TO_DATE('12-2015','mm-yyyy');
begin
get_sales_report(c_date2);
end;
Dates are fixed sized types. So, if you want to group by a whole month, you must query your date column as char. Meaning, you should use TO_CHAR instead of TO_DATE.
Here's (the simpler) way to do it (My changes are lowercase) -
CREATE OR REPLACE PROCEDURE Proce_Name (Pram_Date date) AS
l_month char(7);
l_total_amount number;
l_total number;
BEGIN
SELECT to_char(monthly_date,'mm-yyyy') as month,
SUM(PRICE) AS TOTAL_AMOUNT,
SUM(NVL(QUANTITY,0)*NVL(PRICE,0)) AS TOTAL
INTO l_month, l_total_amount, l_total
FROM PRODUCTS
where to_char(monthly_date,'mm-yyyy')=to_char(Pram_Date, 'mm-yyyy')
GROUP BY to_char(monthly_date,'mm-yyyy');
if l_month is not null then
DBMS_OUTPUT.PUT_LINE('TOTAL AMOUNT: '|| ' '|| Y.TOTAL_AMOUNT);
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('TOTAL: '|| ' '|| Y.TOTAL);
else
DBMS_OUTPUT.PUT_LINE('No Data for this month');
end if;
END Proce_name;
/
Here's some testing code - http://sqlfiddle.com/#!4/b1068/2
CREATE OR REPLACE PROCEDURE STATUS_MAIL(FROM_MAIL IN VARCHAR2, TO_MAIL IN VARCHAR2)
is
v_From VARCHAR2(80) := FROM_MAIL;
v_Recipient VARCHAR2(80) := TO_MAIL;
v_Subject VARCHAR2(80) := 'EMPLOYEE STATUS';
v_Mail_Host VARCHAR2(30) := 'xx.xx.xxx.xxx';
v_Mail_Conn utl_smtp.Connection;
v_msg_body VARCHAR2(5000);
v_output VARCHAR2(5000);
BEGIN
/*Result always returns 42 rows*/
v_output := 'select empid,ename,mobile,dept from employee';
EXECUTE IMMEDIATE v_output into v_msg_body;
v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, xx);
utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
utl_smtp.Mail(v_Mail_Conn, v_From);
utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || UTL_TCP.crlf ||
'From: ' || v_From || UTL_TCP.crlf ||
'Subject: '|| v_Subject || UTL_TCP.crlf ||
'To: ' || v_Recipient || UTL_TCP.crlf ||
UTL_TCP.crlf || v_msg_body );
utl_smtp.Quit(v_mail_conn);
EXCEPTION
WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;
Getting an error inconsistent datatypes
# EXECUTE IMMEDIATE v_output into v_msg_body
while executing the above procedure, please help me....
So in fact your real question is: "how do I aggregate multiple rows into a single string ?"
The answer is to use aggregate functions. Oracle has introduced listagg-function in 11gR2 that solves this problem nicely but in earlier releases one has to do a bit more work.
When you know the right keywords Google finds a plenty of great resources, e.g.
String Aggregation Techniques
listagg function in 11g release 2
the collect function in 10g
I have collected the following examples from the above mentioned resources. Hope this gives you a good starting point:
The table that will be queried:
create table foo (d1 number, d2 varchar2(10));
insert all
into foo values(1, 'a')
into foo values(2, 'b')
into foo values(3, 'c')
select 1 from dual;
commit;
Oracle 11gR2:
declare
v_str varchar2(32767);
begin
select listagg('key = ' || d1 || ' value = ' || d2, chr(10))
within group (order by d1)
into v_str
from foo;
dbms_output.put_line(v_str);
exception
when value_error then
dbms_output.put_line('Exception: trying to insert too many characters to a varchar2 variable.');
end;
/
Oracle 10g:
create or replace type str_list_t as table of varchar2(32676);
/
create function to_string (
nt_in in str_list_t,
delimiter_in in varchar2 default ','
) return varchar2 is
v_idx pls_integer;
v_str varchar2(32767);
v_dlm varchar2(10);
begin
v_idx := nt_in.first;
while v_idx is not null loop
v_str := v_str || v_dlm || nt_in(v_idx);
v_dlm := delimiter_in;
v_idx := nt_in.next(v_idx);
end loop;
return v_str;
end;
/
declare
v_str varchar2(32676);
begin
select to_string(cast(collect('key = ' || d1 || ' value = ' || d2) as str_list_t), chr(10))
into v_str
from foo;
dbms_output.put_line(v_str);
exception
when value_error then
dbms_output.put_line('Exception: trying to insert too many characters to a varchar2 variable.');
end;
/
Note how I'll catch value_error exception that will be raised if the aggregated string won't fit into the reserved varchar2 capacity.
Output of both examples:
key = 1 value = a
key = 2 value = b
key = 3 value = c
I am trying to split a string using an integer array as mask.
The task is simple but I am not accustomed to ADA (which is a constraint).
Here is my code. It works exept that I have an one character offset when testing against a file. Can someone help me remove this offset. it is drinving me nuts.
generic_functions.adb :
package body Generic_Functions is
-- | Sums up the elements of an array of Integers
function Sum_Arr_Int(Arr_To_Sum: Int_Array) return Integer is
Sum: Integer;
begin
Sum := 0;
for I in Arr_To_Sum'Range loop
Sum := Sum + Arr_To_Sum(I);
end loop;
return Sum;
end Sum_Arr_Int;
-- | Split up a String into a array of Unbounded_String following pattern from an Int_Array
function Take_Enregistrements(Decoup_Tab: Int_Array; Str_To_Read: String) return Str_Array is
Previous, Next : Integer;
Arr_To_Return : Str_Array(Decoup_Tab'Range);
begin
if Sum_Arr_Int(Decoup_Tab) > Str_To_Read'Length then
raise Constraint_Error;
else
Previous := Decoup_Tab'First;
Next := Decoup_Tab(Decoup_Tab'First);
for I in Decoup_Tab'Range loop
if I /= Decoup_Tab'First then
Previous := Next + 1;
Next := (Previous - 1) + Decoup_Tab(I);
end if;
Arr_To_Return(I) := To_Unbounded_String(Str_To_Read(Previous..Next));
end loop;
return Arr_To_Return;
end if;
end Take_Enregistrements;
end Generic_Functions;
generic_functions.ads :
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Generic_Functions is
-- | Types
type Int_Array is array(Positive range <>) of Integer;
type Str_Array is array(Positive range <>) of Unbounded_String;
-- | end of Types
-- | Functions
function Sum_Arr_Int(Arr_To_Sum: Int_Array) return Integer;
function Take_Enregistrements(Decoup_Tab: Int_Array; Str_To_Read: String) return Str_Array;
-- | end of Functions
end Generic_Functions;
generic_functions_tests.adb :
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Generic_Functions; use Generic_Functions;
procedure Generic_Functions_Tests is
-- | Variables
Decoup_Test : constant Int_Array(1..8) := (11, 19, 60, 24, 255, 10, 50, 255);
Test_Str_Arr : Str_Array(Decoup_Test'Range);
Test_Str_Arr2 : Str_Array(Decoup_Test'Range);
Test_Str_Arr3 : Str_Array(Decoup_Test'Range);
--Test_Int : Integer;
Test_Handle : File_Type;
-- | end of Variables
begin
Open(Test_Handle, In_File, "EXPORTFINAL.DAT");
Test_Str_Arr := Take_Enregistrements(Decoup_Test, Get_Line(Test_Handle));
Test_Str_Arr2 := Take_Enregistrements(Decoup_Test, Get_Line(Test_Handle));
Test_Str_Arr3 := Take_Enregistrements(Decoup_Test, Get_Line(Test_Handle));
for I in Test_Str_Arr'Range loop
Put_Line(To_String(Test_Str_Arr(I)));
end loop;
for I in Test_Str_Arr2'Range loop
Put_Line(To_String(Test_Str_Arr2(I)));
end loop;
for I in Test_Str_Arr3'Range loop
Put_Line(To_String(Test_Str_Arr3(I)));
end loop;
-- for I in Test_Str_Arr'Range loop
-- Test_Int := To_String(Test_Str_Arr(I))'Length;
-- Put_Line(Integer'Image(Test_Int));
-- end loop;
-- for I in Test_Str_Arr2'Range loop
-- Test_Int := To_String(Test_Str_Arr2(I))'Length;
-- Put_Line(Integer'Image(Test_Int));
-- end loop;
-- for I in Test_Str_Arr3'Range loop
-- Test_Int := To_String(Test_Str_Arr3(I))'Length;
-- Put_Line(Integer'Image(Test_Int));
-- end loop;
Close(Test_Handle);
end Generic_Functions_Tests;
and finaly the file:
000000000012012-01-01 10:00:00 IBM IBM COMPAGNIE IBM FRANCE 17 AVENUE DE l'EUROPE 92275 BOIS-COLOMBES CEDEX CONFIGURATION COMPLETE SERVEUR000000000000000000000019 .6000000000001000000000000000000001000.00000000000000000000000000000196.00000000000000000000000000001196.00000000
000000000022012-01-01 11:00:00 MICROSOFT MSC 39 QUAI DU PRESIDENT ROOSEVELT 92130 ISSY-LES-MOULINEAUX AMENAGEMENT SALLE INFORMATIQUE000000000000000000000019.6000000000001000000000000000000001000.00000000000000000000000000000196.00000000000000000000000000001196.00000000
000000000032012-01-01 12:00:00 MICROSOFT MSC 39 QUAI DU PRESIDENT ROOSEVELT 92130 ISSY-LES-MOULINEAUX TESTS SUR SITE000000000000000000000019.6000000000001000000000000000000003226.52000000000000000000000000000632.39792000000000000000000000003858.91792000 DELEGATION TECHNICIEN HARD000000000000000000000019.60000000000000000000000000000001.00000000000000000000000000001000.00000000000000000000000000000196.00000000000000000000000000001196.00000000
These lines:
if I = Decoup_Tab'Last then
Arr_To_Return(I) := To_Unbounded_String(Str_To_Read(Previous..Next));
end if;
will overwrite the last element in your array.
Also, are you sure that the line number (00000000001, 00000000002, etc) is one of the strings you want to split based on the integer mask? As your code is right now, you use '11' twice, once for the line number and once for the date-field. If you skip the line number, the other numbers seem to make more sense.