is the sql code .and it have error . CREATE or replace PROCEDURE CONVERT_VAL(&v1 varchar2(2), &v2 varchar2(2), &amt number) as val varchar(100); val1 varchar(2):= ':v1'; val2 varchar(2):=':v2';
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
this oracle code have some error , how to fix it ?
this is the sql code .and it have error .
CREATE or replace PROCEDURE CONVERT_VAL(&v1 varchar2(2), &v2 varchar2(2), &amt number)
as
val varchar(100);
val1 varchar(2):= ':v1';
val2 varchar(2):=':v2';
amount number:= :amt;
Begin
Select case when val1!=val2 then
case
when lower(val1)='km' and lower(val2) = 'cm'
then amount||lower(val1) ||amount*100000||' '||lower(val2)
when lower(val1)='km' and lower(val2) = 'mt'
then amount||lower(val1) ||amount*1000||' '||lower(val2)
when lower(val1)='km' and lower(val2) = 'mm'
then amount||lower(val1) ||amount*1000000||' '||lower(val2)
when lower(val1)='cm' and lower(val2) = 'km'
then amount||lower(val1) ||amount/100000||' '||lower(val2)
when lower(val1)='cm' and lower(val2) = 'mt'
then amount||lower(val1) ||amount*0.01||' '||lower(val2)
when lower(val1)='cm' and lower(val2) = 'mm'
then amount||lower(val1) ||amount*10||' '||lower(val2)
when lower(val1)='mt' and lower(val2) = 'km'
then amount||lower(val1) ||amount/1000||' '||lower(val2)
when lower(val1)='mt' and lower(val2) = 'cm'
then amount||lower(val1) ||amount*100||' '||lower(val2)
when lower(val1)='mt' and lower(val2) = 'mm'
then amount||lower(val1) ||amount*1000||' '||lower(val2)
when lower(val1)='mm' and lower(val2) = 'km'
then amount||lower(val1) ||amount/1000000||' '||lower(val2)
when lower(val1)='mm' and lower(val2) = 'mt'
then amount||lower(val1) ||amount*0.001||' '||lower(val2)
when lower(val1)='mm' and lower(val2) = 'cm'
then amount||lower(val1) ||amount*0.1||' '||lower(val2)
end
else
'same metric conversion is not possible'
end
as val into val
from dual;
dbms_output.Put_line(val);
END;
/
---
Procedure CONVERT_VAL compiled
LINE/COL ERROR
--------- -------------------------------------------------------------
1/35 PLS-00103: Encountered the symbol "(" when expecting one of the following: := . ) , @ % default character The symbol ":=" was substituted for "(" to continue.
1/50 PLS-00103: Encountered the symbol "(" when expecting one of the following: := . ) , @ % default character The symbol ":=" was substituted for "(" to continue.
1/55 PLS-00103: Encountered the symbol "1" when expecting one of the following: <an identifier> <a double-quoted delimited-identifier> current delete exists prior The symbol "<an identifier> was inserted before "1" to continue.
6/17 PLS-00049: bad bind variable 'AMT'
Errors: check compiler log
this is a unit conversion
1st: fromwhat unit
2nd : to what unit
3rd :is the amount .
like enter km ,cm ,1,will output 1km =1000000cm
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images