Home » Other » Client Tools » SP2-0552: Bind variable "V_D" not declared.
SP2-0552: Bind variable "V_D" not declared. [message #628509] Tue, 25 November 2014 22:34 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

SQL> var v_d date;
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
                    VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
                    NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
                    BINARY_FLOAT | BINARY_DOUBLE ] ]
SQL> begin
  2      select Ordered_Date(sysdate) into :v_d  from dual;
  3   end;
  4  /
SP2-0552: Bind variable "V_D" not declared.


How to execute this function in SQL*PLUS
Re: SP2-0552: Bind variable "V_D" not declared. [message #628510 is a reply to message #628509] Tue, 25 November 2014 22:40 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Do you realize that SQL, PL/SQL, & SQL*Plus are all different from each other?

What exactly are you trying to accomplish?
Re: SP2-0552: Bind variable "V_D" not declared. [message #628511 is a reply to message #628510] Tue, 25 November 2014 22:43 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
Do you realize that SQL, PL/SQL, & SQL*Plus are all different from each other?

What exactly are you trying to accomplish?

Thanks for reply BlackSwan, i got a solution while executing in the TOAD, but i need to know how to execute this one in the SQL*PLUS

can you please help me on this how to do this?

I am passing Date as IN Param
Re: SP2-0552: Bind variable "V_D" not declared. [message #628512 is a reply to message #628511] Tue, 25 November 2014 22:49 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>can you please help me on this how to do this?
I do not know or understand what you mean by "this".

>I am passing Date as IN Param
Are you bragging or complaining?

Do you realize that SYSDATE is a function itself?

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/
Re: SP2-0552: Bind variable "V_D" not declared. [message #628513 is a reply to message #628512] Tue, 25 November 2014 22:55 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
Do you realize that SYSDATE is a function itself?

Yes you are correct, is there any another possibilities to call function, func1(func2), Ordered_Date(sysdate)
Re: SP2-0552: Bind variable "V_D" not declared. [message #628514 is a reply to message #628512] Tue, 25 November 2014 22:58 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
SQL> DECLARE
  2     v_date date;
  3  BEGIN
  4     v_date := Ordered_Date(sysdate);
  5     dbms_output.put_line('Today Date is : ' || v_date);
  6  END;
  7  /
Today Date is : 23-DEC-10

PL/SQL procedure successfully completed.

SQL> exec DBMS_OUTPUT.PUT_LINE (Ordered_Date(sysdate))
23-DEC-10

PL/SQL procedure successfully completed.


It is fine when i calling like above code, but when i am calling using select statement i am getting Error SP2-0552: Bind variable "V_D" not declared.

[Updated on: Tue, 25 November 2014 22:58]

Report message to a moderator

Re: SP2-0552: Bind variable "V_D" not declared. [message #628515 is a reply to message #628513] Tue, 25 November 2014 22:59 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
DECLARE 
    sometime DATE; 
BEGIN 
    sometime := Ordered_date(SYSDATE); 
END; 

/
Re: SP2-0552: Bind variable "V_D" not declared. [message #628516 is a reply to message #628515] Tue, 25 November 2014 23:06 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Thanks BlackSwan got the point we can call like as it is in TOAD in the SQL*PLUS
select Ordered_date(SYSDATE) from dual

[Updated on: Tue, 25 November 2014 23:08]

Report message to a moderator

Re: SP2-0552: Bind variable "V_D" not declared. [message #628517 is a reply to message #628516] Tue, 25 November 2014 23:12 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
  1  DECLARE
  2      v_date DATE;
  3  BEGIN
  4      SELECT SYSDATE
  5      INTO   v_date
  6      FROM   dual;
  7      dbms_output.Put_line('Today Date is : '
  8                           || v_date);
  9* END;
 10  /
Today Date is : 25-NOV-14

PL/SQL procedure successfully completed.


Re: SP2-0552: Bind variable "V_D" not declared. [message #628518 is a reply to message #628517] Tue, 25 November 2014 23:20 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Thank you BlackSwan got the point.. Smile
Re: SP2-0552: Bind variable "V_D" not declared. [message #628519 is a reply to message #628518] Tue, 25 November 2014 23:22 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
mist598 wrote on Tue, 25 November 2014 21:20
Thank you BlackSwan got the point.. Smile



I don't believe you.
Re: SP2-0552: Bind variable "V_D" not declared. [message #628520 is a reply to message #628519] Tue, 25 November 2014 23:26 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
I don't believe you.

Why are you saying like this? Yes, i got the output , i tried with your code same as it is.. Smile
Re: SP2-0552: Bind variable "V_D" not declared. [message #628521 is a reply to message #628520] Tue, 25 November 2014 23:28 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
why does my code work & your original code throw error?
Re: SP2-0552: Bind variable "V_D" not declared. [message #628522 is a reply to message #628521] Tue, 25 November 2014 23:32 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
why does my code work & your original code throw error?

I used bind variable in the into clause (:v_d)

can you please explain me, i don't know why i am getting (with my code) error?
Re: SP2-0552: Bind variable "V_D" not declared. [message #628529 is a reply to message #628522] Wed, 26 November 2014 01:16 Go to previous message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Did you read what SQL*Plus told you?
SQL> var v_d date;
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
                    VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
                    NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |


If the declaration fails then the variable is not declared, is this not obvious?

Previous Topic: Claiming information about the DB with SQL
Next Topic: Only values a select-result
Goto Forum:
  


Current Time: Thu Mar 28 07:01:32 CDT 2024