For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Can I connect Oracle Forms 12c via Rest web services with shopify database.
Seeing as your create table doesn't work, that's hardly surprising.
You can't have a column called number.
Your code refers to a variable called number that doesn't exist - and couldn't exist if you actually declared it due to the name. You probably want to use p_od instead.
Fix your naming and try again. If you're still having problems post the revised code, along with the details of any errors you get and we'll help you out.
This can be done in single SQL like
INSERT INTO numbers
select lvl from
(select level lvl from dual
connect by level <=100
)
where mod(lvl,2)=0 ;
By the way DO NOT name a column as NUMBER, this is bad practice as that is a Oracle key word.
Assuming this is homework and you need to do like what teacher suggested then you can do something like
CREATE OR REPLACE PROCEDURE insert_even IS
BEGIN
for i in 1..100 loop
IF mod(i,2)=0
then
INSERT INTO numbers values(i);
end if;
end loop;
end;
p_od NUMBER:=1;
p_do NUMBER:=100;
loop
IF mod(p_od,2)=0
INSERT INTO numbers values(p_od);
p_od := p_po+1;
exit when p_od>p_do;
NOTE: I haven't tested any of the above, So you need to write, debug and test.
Saubhik wrote:This can be done in single SQL likeINSERT INTO numbersselect lvl from(select level lvl from dual connect by level <=100)where mod(lvl,2)=0 ;
Saubhik wrote:
Without subquery:------------------------SELECT LEVEL * 2 lvl FROM DUALCONNECT BY LEVEL <= 50;Another way using sequence :create sequence seq_even start with 2 increment by 2;
Without subquery:
------------------------
SELECT LEVEL * 2 lvl
FROM DUAL
CONNECT BY LEVEL <= 50;
Another way using sequence :
create sequence seq_even start with 2 increment by 2;
Cheers,
Manik.
I changed names and still doesn't work
Of course it doesn't.
IF mod(another,2) =0
That refers to a PL/SQL variable/parameter called 'another'.
There's no such variable declared.
There's a column of that name but you have no use for it at that point.
Likewise
INSERT INTO excercise values(another)
Trying to insert the column into itself doesn't really make sense does it?
Meanwhile you've got a variable called p_od which you are incrementing in the loop. Don't you think it would make more sense to use that instead?
Hello,
you have already seen previous answers, I won't repeat the same; but apart form using a simple statement (INSERT ... LEVEL ... -I would insert " 2 * LEVEL"-), two additional remarks:
-A- writing code like "p_od := 1; LOOP p_od := p_od + 1: IF mod( p_od, 2 ) = 0 THEN ... EXIT WHEN p_od = p_do ..." looks really sad...
To give simply one example: you might jump the odd numbers: FOR i IN 1..50 LOOP INSERT ... 2 * i ... END LOOP;
-B- and please take the 2 minutes necessary to modify your "display name" to something more human-friendly, currently you look like a "bot"... Please have a look at
Best regards,
Bruno Vroman.
P.S. better late than never: Season's greetings, Oracle-mathematical way
Saubhik napisał(-a):
Yeah, its work, but I need to use procedure
I used your second option
No errors, but still 'no data found'
And third example:
You need to RUN the procedure you have created. Creating procedure is different from EXECUTING the procedure.
your_procedure_name;
END;
Using a while loop, here's an example anonymous PL/SQL block demonstrating, well, a while loop:
declare p_od NUMBER := 2; p_do NUMBER := 100;begin while true loop -- INSERT INTO numbers (p_od) VALUES (p_od); dbms_output.put_line(p_od); p_od := p_od + 2; exit when p_od > p_do; end loop;end;/
declare
p_od NUMBER := 2;
p_do NUMBER := 100;
begin
while true loop
-- INSERT INTO numbers (p_od) VALUES (p_od);
dbms_output.put_line(p_od);
p_od := p_od + 2;
exit when p_od > p_do;
/
...your variable naming is not good. Naming variables the same as the columns in a table you are trying to manipulate will result in maintenance issues because the code looks ambiguous.
Gaz in Oz wrote:Using a while loop, here's an example anonymous PL/SQL block demonstrating, well, a while loop:
Gaz in Oz wrote:
declare p_od NUMBER := 2; p_do NUMBER := 100; begin while true loop -- INSERT INTO numbers (p_od) VALUES (p_od); dbms_output.put_line(p_od); p_od := p_od + 2; exit when p_od > p_do; end loop; end; /
Even if you remove 'while true' it would work
If you're going to demo a while loop, wouldn't it be an idea to have one that actually acts like a while loop? (where the WHILE check actually evaluates to false at some point and exits that way)
e.g.
declare p_od NUMBER := 2; p_do NUMBER := 100; begin while p_od <= p_do loop -- INSERT INTO numbers (p_od) VALUES (p_od); dbms_output.put_line(p_od); p_od := p_od + 2; end loop; end; /
while p_od <= p_do loop
Ok, now I have results. Thank you
Please then take 15 seconds to mark correct and useful answers, and remember to set your user name to something more meaningful than "9910aa55-1382-4bbb-8a9b-338b89308abe"
I changed user name 1 minute after register but still doesnt work:
Most of us can't read Polish, and we can't copy and paste the text from that image into google translate.
Nothing important:
"Thanks for joining to community Oracle, you will find here answers on your questions. You can contact with others people...
Display name: xiobijaph"
Nevermind, maybe after some time my name will update