Pick the last row returned from query
hii...
i have a query thats returns...
SQL> WITH tbl_zone AS (
2 SELECT to_date('02/03/2010', 'DD/MM/YYYY') close_date FROM dual UNION ALL
3 SELECT to_date('03/03/2010', 'DD/MM/YYYY') FROM dual UNION ALL
4 SELECT to_date('04/03/2010', 'DD/MM/YYYY') FROM dual UNION ALL
5 SELECT to_date('09/03/2010', 'DD/MM/YYYY') FROM dual UNION ALL
6 SELECT to_date('11/03/2010', 'DD/MM/YYYY') FROM dual)
7 SELECT TRUNC(close_date, 'IW') close_date
8 from tbl_zone t
9 ORDER BY 1 DESC;
CLOSE_DATE
08/03/2010
08/03/2010
01/03/2010
01/03/2010
01/03/2010i want the query to return just i row and that should be the greatest date
in the above example
the query should return single row out of the 2 greatest dates, 08/03/2010.
CLOSE_DATE
08/03/2010Please any one suggest...
How about row_number()
SQL> with tbl_zone as (
2 select to_date('02/03/2010', 'dd/mm/yyyy') close_date from dual union all
3 select to_date('03/03/2010', 'dd/mm/yyyy') from dual union all
4 select to_date('04/03/2010', 'dd/mm/yyyy') from dual union all
5 select to_date('09/03/2010', 'dd/mm/yyyy') from dual union all
6 select to_date('11/03/2010', 'dd/mm/yyyy') from dual
7 )
8 --
9 --
10 --
11 select close_date
12 from ( select trunc(close_date, 'iw') close_date
13 , row_number() over ( order by close_date desc) rn
14 from tbl_zone t
15 )
16 where rn=1;
CLOSE_DATE
08-03-2010 00:00:00
Similar Messages
-
How do you limit the number of rows return from query?
How do you limit the number of rows return from query? Do all databases support this kind of feature?
i think the standard is limit
to get the top 30
select * from mytable LIMIT 30;returns the first 30 rows
also if you want a range
select * from mytable LIMIT 10,30;returns 30 rows starting from 10
this last one is useful for displaying ranges... something similar happens in these forums when viewing topics and messages -
Wish to find out number of rows returned from query
hi,
is it possible to determine how many rows have been returned after a query has been executed?
thank you.It doesn't seem like there is a method to do it for you, [...]There can't be such a method that's guaranteed to work for all databases. Many databases just hand you a cursor with the query results, and you have to walk the cursor to find the complete set. It's even possible for the DB to continue computing the query in the background and just give you a cursor to walk and consume what it has already generated.
So no, you have to walk the result set (effectively pulling everything over to the client) to count the number of rows.. -
I have 10 rows in my table and I have to retrive last row using rownum.
For this I use
SELECT * from <table_name>
where rownum<=10
minus
SELECT * from <table_name>
where rownum<=9
The result is no rows selected
In the same case if I use
SELECT rownum from <table_name>
Where rownum <= 10
minus
SELECT rownum from <table_name>
where rownum <=9
The result is 10
Why this happend.
If the result is 10, then why the row whose rowid is 10 is not retrivedAll
Please bear in mind that ROWNUM is an attribute of the query NOT the table. The last row returned by an unORDERed SELECT statement may be the most recently inserted row but is not guaranteed to be so.
The only way of assuring yourself of returning the most recent row is either to timestamp all your tables with a date_created column or to use a primary key with an ascending value.
rgds, APC -
Is it possible to count the rows returned from a query?
Hello,
When using JDBC is there anyway of finding out the number of
rows returned from a query before actually getting each row?
In Forms 4.5 you can use the count_query function, does anyone
know of an equivalent function or work around in JDBC and/or
SQLJ?
Thanks.
nullPasi Hmlinen (guest) wrote:
: Try
: SELECT COUNT(*) FROM the_table WHERE <conditions>;
: Hope this helps,
: Pasi
Thanks for the advice, I'm currently using SELECT COUNT(*) but
I'm looking for a more efficient way of doing it. If I SELECT
COUNT each time then I have to prepare and execute a SQL
statement each time. What I want to do it execute a single SQL
statement to return my results and somehow find out the number
of rows in the resultset without having to go back to the
database.
Gethin.
null -
Needs help to retrive the last row in a select query without using rownum
Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
1 select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
2 from emp
3 connect by mgr = prior empno
4* start with mgr is null
SQL> /
EMPNO ENAME MGR
7839 KING
7566 JONES 7839
7788 SCOTT 7566
7876 ADAMS 7788
7902 FORD 7566
7369 SMITH 7902
7698 BLAKE 7839
7499 ALLEN 7698
7521 WARD 7698
7654 MARTIN 7698
7844 TURNER 7698
7900 JAMES 7698
7782 CLARK 7839
7934 MILLER 7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data) -
How to get the last row in a resultset or query
Hi All
Say If I have a complex query which returns a resultset say 15 rows. Now I want to limit the output showing only the last row.
How can we do thisKeep in mind Oracle does not keep "row" order as such. Unlike a graphical type db like Access, Oracle will not always give you back the results in order.
Even if you were to use a sequence, your query is never guaranteed to give back the results in the order you are expecting. You must then give an order by statement to all queries expecting the order.
Your definition of last row too is vague - if it is in fact the greatest amount, use the inline view suggestion. If you simply want to see the last inserted row, consider adding a last_update_date column inserting the sysdate (by a trigger perhaps). This would then allow you to see the last inserted row.
Enjoy! -
Getting the number of rows returned from ResultSet
Hi,
Does anyone know a method to get the number of rows returned with a query using the Resultset class?
Thanks.Hi 281080,
If your database and JDBC driver support it, in order to use the solution that da-alexj has suggested, you need to create a 'scrollable' "ResultSet" -- the javadoc for method "createStatement()" (in class "java.sql.Connection") has more details.
However, I have found with Oracle 8.1.7.4 database and Oracle (thin) JDBC driver, that part of their implementation of the "last()" method (in class "java.sql.ResultSet") is to actually iterate through the entire "ResultSet" in order to reach the last row. If your "ResultSet" is very large (I tested it with a 100,000 row "ResultSet"), this will take a long time.
Just wanted to make you aware of that.
Of-course, this may be irrelevant to you since I didn't see any mention in your post of what database and JDBC driver you are using.
Hope this has helped you, anyway.
Good Luck,
Avi. -
How to Customize the Message "No Row Returned" from a Report
Hi,
I've been trying to customize the Message "No Row Returned" from a Report.
First i followed the instructions in Note:183131.1 -
How to Customize the Message "No Row Returned" from a Report
But of course the OWA_UTIL.REDIRECT_URL in this solution did not work (in a portlet) and i found the metalink document 228620.1 which described how to fix it.
So i followed the "fix" in the document above and now my output is,..
"Portlet 38,70711 responded with content-type text/plain when the client was requesting content-type text/html"
So i search in Metalink for the above and come up with,...
Bug 3548276 PORTLET X,Y RESPONDED WITH CONTENT-TYPE TEXT/PLAIN INSTEAD OF TEXT/HTML
And i've read it and read it and read it and read it and can't make heads or tails of what it's saying.
Every "solution" seems to cause another problem that i have to fix. And all i want to do is customize the Message "No Row Returned" from a Report. Please,...does anyone know how to do this?My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.
-
HELP! How te retrieve the last row in MYSQL database using Servlet!
Hi ,
I am new servlets. I am trying to retireve the last row id inserted using the servlet.
Could someone show me a working sample code on how to retrieve the last record inserted?
Thanks
MY CODE
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class demo_gr extends HttpServlet {
//***** Servlet access to data base
public void doPost (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
String url = "jdbc:mysql://sql2.njit.edu/ki3_proj";
String param1 = req.getParameter("param1");
PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
String semail, sfname, slname, rfname, rlname, remail, message;
int cardType;
sfname = req.getParameter("sfname");
slname = req.getParameter("slname");
rfname = req.getParameter("rfname");
rlname = req.getParameter("rlname");
semail = req.getParameter("semail");
remail = req.getParameter("remail");
message = req.getParameter("message");
//cardType = req.getParameter("cardType");
cardType = Integer.parseInt(req.getParameter("cardType"));
out.println(" param1 " + param1 + "\n");
String query = "SELECT * FROM greeting_db "
+ "WHERE id =" + param1 + "";
String query2 ="INSERT INTO greeting_db (sfname, slname ,semail , rfname , rlname , remail , message , cardType ,sentdate ,vieweddate) values('";
query2 = query2 + sfname +"','"+ slname + "','"+ semail + "','"+ rfname + "','"+ rlname + "','"+ remail + "','"+ message + "','"+ cardType + "',NOW(),NOW())";
//out.println(" query2 " + query2 + "\n");
if (semail.equals("") || sfname.equals("") ||
slname.equals("") || rfname.equals("") ||
rlname.equals("") || remail.equals("") ||
message.equals(""))
out.println("<h3> Please Click the back button and fill in <b>all</b> fields</h3>");
out.close();
return;
String title = "Your Card Has Been Sent";
out.println("<BODY>\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" );
out.println("\n" +
"\n" +
" From " + sfname + ", " + slname + "\n <br> To "
+ rfname + ", " + rlname + "\n <br>Receiver Email " + remail + "\n<br> Your Message "
+ message + "\n<br> <br> :");
if (cardType ==1)
out.println("<IMG SRC=/WEB-INF/images/bentley.jpg>");
else if(cardType ==2) {
out.println("<IMG SRC=/WEB-INF/images/Bugatti.jpg>");
else if(cardType ==3) {
out.println(" <IMG SRC=/WEB-INF/images/castle.jpg>");
else if(cardType ==4) {
out.println(" <IMG SRC=/WEB-INF/images/motocross.jpg>");
else if(cardType ==5) {
out.println(" <IMG SRC=/WEB-INF/images/Mustang.jpg>");
else if(cardType ==6) {
out.println("<IMG SRC=/WEB-INF/images/Mustang.jpg>");
out.println("</BODY></HTML>");
try {
Class.forName ("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection
( url, "*****", "******" );
Statement stmt = con.createStatement ();
stmt.execute (query2);
//String query3 = "SELECT LAST_INSERT_ID()";
//ResultSet rs = stmt.executeQuery (query3);
//int questionID = rs.getInt(1);
System.out.println("Total rows:"+questionID);
stmt.close();
con.close();
} // end try
catch (SQLException ex) {
//PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
while (ex != null) {
out.println ("SQL Exception: " + ex.getMessage ());
ex = ex.getNextException ();
} // end while
} // end catch SQLException
catch (java.lang.Exception ex) {
//PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
out.println ("Exception: " + ex.getMessage ());
} // end doGet
private void printResultSet ( HttpServletResponse resp, ResultSet rs )
throws SQLException {
try {
PrintWriter out = resp.getWriter();
out.println("<html>");
out.println("<head><title>jbs jdbc/mysql servlet</title></head>");
out.println("<body>");
out.println("<center><font color=AA0000>");
out.println("<table border='1'>");
int numCols = rs.getMetaData().getColumnCount ();
while ( rs.next() ) {
out.println("<tr>");
for (int i=1; i<=numCols; i++) {
out.print("<td>" + rs.getString(i) + "</td>" );
} // end for
out.println("</tr>");
} // end while
out.println("</table>");
out.println("</font></center>");
out.println("</body>");
out.println("</html>");
out.close();
} // end try
catch ( IOException except) {
} // end catch
} // end returnHTML
} // end jbsJDBCServletI dont know what table names and fields you have but
say you have a table called XYZ which has a primary
key field called keyID.
So in order to get the last row inserted, you could
do something like
Select *
from XYZ
where keyID = (Select MAX(keyID) from XYZ);
Good Luckwhat gubloo said is correct ...But this is all in MS SQL Server I don't know the syntax and key words in MYSQL
This works fine if the emp_id is incremental and of type integer
Query:
select *
from employee e, (select max(emp_id) as emp_id from employee) z
where e.emp_id = z.emp_id
or
select top 1 * from employee order by emp_id descUday -
Import the last row written in a database
Hello!
I want know what i have to do to import the last row written in a table from a MySQL database.
I'm using labview database toolkit.
Thank you in advanced.
LarsonHi Larson
I total agree that my first suggestion isn't what you want but I wanted to put the idea across that you can retrieve records from table in the order they were written using a simple SQL command.
When dealing with databases I always design my queries using Design View in MS Access. Once you have the query designed you can then convert the query you have just designed in Design View to SQL by changing to SQL View.
So this example SQL statement would return the MAX Timestamp.
SELECT Max(tblTimeStampTest.Timestamp) AS MaxOfTimestamp
FROM tblTimeStampTest;
Say the timestamp was 12/14/2005 8:18:33
SELECT tblTimeStampTest.*
FROM tblTimeStampTest
WHERE (((tblTimeStampTest.Timestamp)=#12/14/2005 8:18:33#));
This will return your last record as long at the timestamps are unique and records are written in timestamp order. You can then use Build Text Express VI or Format into String to build your SQL strings that have variables like the timestamp above.
I have no experience with mySQL but I would assume MS Access could interface to it somehow either through ODBC or MS Access Projects so that can build you SQL commands.
David -
Get rows where the last row finish off
Hi, i have two tables AND would LIKE TO get data BY combining both.
here IS my data
WITH hist AS
SELECT To_Date('4/23/2010','mm/dd/yyyy') dt, 999 alias, 'PROC' dom FROM dual UNION ALL
SELECT To_Date('4/27/2010','mm/dd/yyyy') dt, 999 alias, 'LON' dom FROM dual UNION all
SELECT To_Date('4/1/2010','mm/dd/yyyy') dt, 111 alias, 'SOC' dom FROM dual UNION all
SELECT To_Date('4/10/2010','mm/dd/yyyy') dt, 111 alias, 'NAO' dom FROM dual UNION ALL
SELECT To_Date('3/23/2010','mm/dd/yyyy') dt, 222 alias, 'PSE' dom FROM dual
final AS
SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION all
SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
SELECT To_Date('4/30/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
SELECT To_Date('2/25/2010','mm/dd/yyyy') dt, 111 alias FROM dual UNION ALL
SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION ALL
SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION all
SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual
the output should be as follow(without the extra blank line of course)
DT ALIAS DOM
2/26/2010 999 PROC
4/22/2010 999 PROC
4/26/2010 999 LON
4/30/2010 999 LON
4/27/2010 999 LON
4/23/2010 999 PROC
2/25/2010 111 SOC
4/1/2010 222 SOC
4/10/2010 222 NAO
2/26/2010 222 PSE
4/22/2010 222 PSE
4/26/2010 222 PSEso what i am doing here is as follow, take one row in hist table (4/23) and join with final table and give me all rows in final table
where dt <= to the row in hist table and include the row from hist table.
this logic will give me rows 2/26/2010,4/22/10 4/23/2010
then the second row in hist table (4/27/2010) wiill get all rows
in final table that is <= to the current row and pick up the rows starting from the row > than the last row where the 4/23/2010 finished off
in this case the output will be 4/26/10, 4/27/2010(we need to include row from hist)
since there is no row in hist that is greater than 4/30/2010, this date will still be display and dom column value should be taking from the max date in hist
which is 4/27/2010. see output above
this sound a little confusing to explain but look at output of what to expect as output. the other ids should follow the same logic
can someone help write a query for this? thanksHi,
Devx wrote:
Frank, thanks again, i ran the query in oracle 11g and oracle 9i. 11g runs ok but 9i doesnt. it looks like the ignore null option is not supported in 9i. That's right: IGNORE NULLS was new in Oracle 10. You should always mention your Oracle version whenever you ask a quiestion, especially if it's as old as Oracle 9.
i will be running this query in 9i. is there any alternative to re-write this query without using last value since ignore null is not supported and the output is not as i expected when i take that keyword out.
i really appreciate your help. please let me know how would i re-write the query. thanksOne work-around is to use LEAD or LAG instead of LAST_VALUE. This means you have to know exactly where (how many rows away) the most recent non-NULL value is, which in turn requires other analytuic funtions, such as ROW_NUMBER, and more sub-queries:
WITH combined_tables AS
SELECT dt, alias, NVL (dom, '_?_') AS dom FROM hist
UNION
SELECT dt, alias, NULL AS dom FROM final
, got_r_num AS
SELECT dt, alias, dom
, ROW_NUMBER () OVER ( PARTITION BY alias
ORDER BY dt
) AS r_num
, COUNT (*) OVER ( PARTITION BY alias
) AS alias_cnt
FROM combined_tables
, got_skip_cnts AS
SELECT dt, alias, dom, r_num
, r_num - MAX (CASE WHEN dom IS NOT NULL THEN r_num END)
OVER ( PARTITION BY alias
ORDER BY r_num
) AS skip_before
, MIN (CASE WHEN dom IS NOT NULL THEN r_num END)
OVER ( PARTITION BY alias
ORDER BY r_num DESC
) - r_num AS skip_after
FROM got_r_num
, got_next_dom AS
SELECT dt, alias, dom, r_num, skip_before
, LEAD (dom, skip_after) OVER ( PARTITION BY alias
ORDER BY r_num
) AS next_dom
FROM got_skip_cnts
SELECT dt
, alias
, NULLIF ( COALESCE ( next_dom
, LAG (dom, skip_before) OVER ( PARTITION BY alias
ORDER BY r_num
) AS dom
FROM got_next_dom
ORDER BY alias
, dt
;You should be able to calculate bot LEAD and LAG in the same query, but there seems to be a bug that only calculates one of them correctly in this case. The sub-query got_next_dom gets around that, by doing the LEAD in a separate sub-query. -
Cant get the last row in jtable
Hello all.
I am trying to get the last row from the table but get "" from it.
my table has 6 rows and i can get all rows right but the last line I have a problem.
//creating the table
for (i=0;i<this.rows;i++)
model.insertRow(i,new Object[]{"input Y1:",""});
for ( i=i;i<this.Amount+this.rows;i++)
model.insertRow(i,new Object[]{"input Amount:",""});
//end of creatingthis code creats the table that i need and its works right.
for(i=0;i<rows;i++){
fObj.fullData[i] = Double.valueOf(GetData(table, 1, i).toString()).doubleValue();
int j=0;
String s=GetData(table, 1, 4).toString();
//the problem line
String s1=GetData(table, 1, 5).toString();
public Object GetData(JTable table, int col_index, int row_index){
return table.getModel().getValueAt(row_index, col_index);
}this line i get ""
String s1=GetData(table, 1, 5).toString();
Edited by: vitaly87 on 00:41 08/04/2011vitaly87 wrote:
Hello all.
I am trying to get the last row from the table but get "" from it.
my table has 6 rows and i can get all rows right but the last line I have a problem.
this line i get ""
String s1=GetData(table, 1, 5).toString();Looks right to me, given that your insert ismodel.insertRow(i,new Object[]{"input Amount:",""});(Hint: indexes start at *0* ).
If it hadn't found the row, I expect you would have got an Exception
Winston -
DB get step: managing multiple row returned from a table
Hi,
please can someone tell me if it is possible to manage multiple row when returned in a db get step?
For example, I execute a SELECT in db read step to read an SQL table which returns two rows. From each row I get two string variables, let's say: "Var1", "Var2".
Assigning them to local variables, I am able to assign just the 2 variables of the first row, not the variables of the second row.
I tried to use array as local variables with not success, how can I do?
Thanksmmaddalena,
You have two options, you can pre populate, or work row by row.
Prepopulate:
String[] Var1
int row
DBGet Loop:
DBGet
Successful:
save to Var1[row]
increment row
Goto DBGet Loop
No data:
/* this is the last row */
Goto After DB Get Loop
After DB Get Loop:
/* do whatever with the data */
Conversely:
Row by row:
String Var 1
int row
DBGet Loop:
DBGet
Successful:
/* do whatever with the data */
Increment row
Goto DBGet Loop
No data:
/* no more data (last row) */
Goto After DB Get Loop
After DB Get Loop:
/* do whatever after your done with the data */ -
How to get the last row of a database table.
HI ,
I want to get record exactly from the last row of a database table.
How is that possible?Hi,
To fetch last record from an internal table, just do find the number of records in it and read using index.
DESCRIBE TABLE ITAB LINES L_LINES.
READ TABLE ITAB INDEX L_LINES.
You can also use LOOP .. ENDLOOP but the above method is better (performance wise).
using LOOP .. ENDLOOP.
LOOP AT ITAB.
**do nothing
ENDLOOP.
**process ITAB (Header record of ITAB).
**after ENLOOP, ITAB will have the last record of the internal table.
[here ITAB is internal table as well as header record.]
But what is the requirement?
If you are looking for the current record of an employee then you can use ENDDA = HIGH_DATE.
My advice is to review your requirement again and try to fetch only that record which you need.
Mubeen
Maybe you are looking for
-
Multiple Senior Cluster Members?
Hi Guys, We've had a few nodes kicked out of one of our production clusters all with messages similar to this: ERROR 2008-04-21 18:17:05.753 Oracle Coherence GE 3.3.1/389p1 <Error> (thread=Cluster, member=29): Received cluster heartbeat from the seni
-
5800xm no longer sees my 16gb sandisk micro sdhc c...
Hi Booted my phone this morning & it didn't see the memory card ! Several reboots & card contact cleans - still no joy. I should have anticipated this a few weeks back, as access to card was playing up occasionally (long boot times, freezing when ope
-
Viewing Images in PDF.....
Dear All, Sometimes I can't view images in PDF that I created in Illustrator by making PS and PDF. But it get viewing when am selecting "OVERPRINT PREVIEW" in Advanced Tab in Adobe Acrobat. can anyone explain what is the reason? and what settings tha
-
Please help-PLSQL complex procedure writing
Hi all, I am back again and requesting your help on this.I want your help to properly write the below code because now i feel-that its very confusing and not easily readable and following the program is tough. I want to replace the same looping done
-
Problem when call store procedure over a database link
Hi all, I've create a database link in server "EAST" similar like: CREATE DATABASE LINK db_link CONNECT TO tiger IDENTIFIED BY scott USING 'abc'; and from server "EAST" i ran the procedure located in server "WEST" somethin like: exec testing_procedur