Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Simple SQL statement not working for me please help!

Options
  • 27-11-2008 6:20pm
    #1
    Registered Users Posts: 569 ✭✭✭


    Hi,

    So I prob have a silly mistake here but i'm just learning at the mo.
    I want this to print out in Oracle SQL*Plus and its not working

    set serveroutput on
    DECLARE
    VARIABLE basic_percent NUMBER
    VARIABLE pf_percent NUMBER
    today DATE:=SYSDATE;
    tomorrow today%TYPE;
    begin
    :basic_percent:=45;
    :pf_percent:=12;
    tomorrow:=today +1;
    dbms_output.put_line('hello');
    dbms_output.put_line('Today is :' || today);
    dbms_output.put_line('Tomorrow is :' || tomorrow);
    END;
    /
    PRINT basic_percent
    PRINT pf_percent

    These are the errors
    SP2-0552: Bind variable "PF_PERCENT" not declared.
    SQL> PRINT
    SP2-0568: No bind variables declared.

    I've tried messing around with it a bit but I don't know where to declare these variables!

    Its probably very easy but i just can't get my head around it.

    Thanks alot!


Comments

  • Registered Users Posts: 5,700 ✭✭✭jd


    Bubba wrote: »
    Hi,

    So I prob have a silly mistake here but i'm just learning at the mo.
    I want this to print out in Oracle SQL*Plus and its not working

    set serveroutput on
    DECLARE
    VARIABLE basic_percent NUMBER
    VARIABLE pf_percent NUMBER

    Semicolons?
    Is there a "variable" keyword?

    DECLARE
    basic_percent NUMBER;
    pf_percent NUMBER;


  • Registered Users Posts: 569 ✭✭✭Bubba


    jd wrote: »
    Semicolons?
    Is there a "variable" keyword?

    DECLARE
    basic_percent NUMBER;
    pf_percent NUMBER;

    Yeah i still get the same error with or without the semi colons!

    Really annoying me here!


  • Registered Users Posts: 5,700 ✭✭✭jd


    Bubba wrote: »
    Yeah i still get the same error with or without the semi colons!

    Really annoying me here!


    Sorry should have looked - are you trying to run pl/sql from sqlplus !?


  • Registered Users Posts: 569 ✭✭✭Bubba


    jd wrote: »
    Sorry should have looked - you are trying to run pl/sql from sqlplus !

    Its ok I got it :).

    If i put in the variables before the declare it works then!

    Thanks for your help.


  • Registered Users Posts: 523 ✭✭✭mwrf


    [PHP]
    declare
    basic_percent NUMBER;
    pf_percent NUMBER;
    today DATE:=SYSDATE;
    tomorrow today%TYPE;
    begin
    basic_percent:=45;
    pf_percent:=12;
    tomorrow:=today +1;
    dbms_output.put_line('hello');
    dbms_output.put_line('Today is :' || today);
    dbms_output.put_line('Tomorrow is :' || tomorrow);
    END;[/PHP]


  • Advertisement
Advertisement