Using the MAx function in PL/SQL
From: <newopt_at_my-deja.com>
Date: 2000/05/04
Message-ID: <8erst8$qp7$1_at_nnrp1.deja.com>#1/1
Date: 2000/05/04
Message-ID: <8erst8$qp7$1_at_nnrp1.deja.com>#1/1
[Quoted] I am using the MAX function to retrieve the latest date/timestamp value [Quoted] from a column in an Oracle dbase table.
When I try to include an "INTO" statement it fails??
Here's the error statement:
SELECT MAX(TDM_TS_DT) INTO v_tgttstmp FROM SINCR.WIPMASTER (the sqlstr
value)
*
ERROR at line 1:
ORA-00905: missing keyword
Here's the code sniplet:
procedure calc_elapsed_time (v_regionschema Varchar2) IS
BEGIN
[Quoted] -- Open new cursor and return cursor ID.
cid := DBMS_SQL.OPEN_CURSOR;
- Build the "Select MAX" SQL statement sqlstr := 'SELECT MAX(TDM_TS_DT) FROM '||v_regionschema||'.WIPMASTER'; (this format works) sqlstr := 'SELECT MAX(TDM_TS_DT) INTO v_tmpdate FROM '||v_regionschema||'.WIPMASTER'; (this format errors)
dbms_output.put_line(sqlstr);
- Execute the dynamic SQL statement built by concatenating the
- ICOMS table name to the SELECT MAX command. DBMS_SQL.PARSE(cid, sqlstr, dbms_sql.native);
- Close cursor. DBMS_SQL.CLOSE_CURSOR(cid); EXCEPTION [Quoted]
- If an exception is raised, close cursor before exiting. WHEN OTHERS THEN DBMS_SQL.CLOSE_CURSOR(cid); RAISE; -- reraise the exception END calc_elapsed_time;
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu May 04 2000 - 00:00:00 CEST