Is this the proper syntax to stuff a value for testing?no
I get an error saying the Select statement needs an INTO statement when I do it this way.error message is correct.
declare v_ename emp.ename%type; begin select ename into v_ename from emp where rownum = 1; dbms_output.put_line(v_ename); end;
What you may want is something like this:
your code goes here \
You need to provide the signature of the procedure(what the parameters are , what datatypes they are, whether they are in , out, or in out parameters
DECLARE V_startdate date := TO_date('&startdate', 'MM/DD/YYYY') V_enddate date := TO_date('&enddate', 'MM/DD/YYYY') BEGIN myproc(v_startdate,v_enddate); END;
974992 wrote:As other have pointed out, you should be sure that you require a Varchar variable and not a Date.
I am clearly new to Oracle. Simple question though. I have a Procedure that runs a fairly involved query. The procedure is called and parameters are passed into it. While I am testing, I just want to DECLARE my variables so it will run properly. I am trying the following:
Var1 Varchar(2) := TO_CHAR('11/01/2012', 'MM/DD/YYYY')
Var2 Varchar(2) := TO_CHAR('11/30/2012', 'MM/DD/YYYY')
Width of VARCHAR should be specified in BYTES/CHAR(s); the above example is for width in Bytes assuming Single Byte Character set. Also as SB pointed out, you need to read the concepts guide for PL/SQL to understand it and then practice it.
DECLARE Var1 Varchar(10) := '11/01/2012'; Var2 Varchar(10) := '11/30/2012';
or you would need to have to do that assignment in PL/SQL, i.e.
SELECT some_column, some_other_column INTO some_variable, some_other_variable FROM some_table WHERE some_condition
If you are populating a local variable in a PL/SQL block, that would not be displayed in TOAD. You could enable DBMS_OUTPUT in TOAD and then use the DBMS_OUTPUT.PUT_LINE procedure to output whatever debugging data you want TOAD to read and display. But that is generally not a sensible way to test a query.
FOR x IN (some_query) LOOP some_variable := x.some_column; some_other_variable := x.some_other_column; ... END LOOP;