- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about insert statemnet in a while true lo...
Operating System - HP-UX
1748089
Members
4830
Online
108758
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2002 12:12 PM
тАО06-12-2002 12:12 PM
this is the script that I used to fillup the tablespace....and my question is the following..
I created a table with 3 field :
empid number, employee_name and salary number.
a. base on the script, the only value that will be changing is the numcount...but if i also want the system to generate the random data for the second value in term of varchar, how do i do that?
do i just add more insert state like
insert into employee value (numcount,'ddgdg')...?
b. if the table has 3 field, can i just insert 1 field instead of 3?
c. in addition, i want to perform update as well, within the while loop...as welll
declare
my_empid employee.empid%TYPE:=234;
my_salary salary.employee%TYPE:=10,000;
numcount number;
begin
numcount:=0;
while true loop
numcount:=numcount+1;
insert into employee value (numcount,'dfadf', 789.90);
update employee set salary = my_salary + 10,000
where empid = my_empid;
end loop;
end;
thank you for your help...
I created a table with 3 field :
empid number, employee_name and salary number.
a. base on the script, the only value that will be changing is the numcount...but if i also want the system to generate the random data for the second value in term of varchar, how do i do that?
do i just add more insert state like
insert into employee value (numcount,'ddgdg')...?
b. if the table has 3 field, can i just insert 1 field instead of 3?
c. in addition, i want to perform update as well, within the while loop...as welll
declare
my_empid employee.empid%TYPE:=234;
my_salary salary.employee%TYPE:=10,000;
numcount number;
begin
numcount:=0;
while true loop
numcount:=numcount+1;
insert into employee value (numcount,'dfadf', 789.90);
update employee set salary = my_salary + 10,000
where empid = my_empid;
end loop;
end;
thank you for your help...
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2002 12:42 PM
тАО06-12-2002 12:42 PM
Solution
a) I'll have to think about a good way to do that one.
b) Yes, as long as the other columns do not have not null constraints. If your are not inserting into all of the fields in the order that they exist in the table than you specify which fields you are inserting as part of the insert statement. Your statement would look like "insert into employee (empid) values (numcount);"
c) for the update, I would do "update empolyee set salary = salary + 10000 where empid = numcount;" This would update the row that you just inserted.
b) Yes, as long as the other columns do not have not null constraints. If your are not inserting into all of the fields in the order that they exist in the table than you specify which fields you are inserting as part of the insert statement. Your statement would look like "insert into employee (empid) values (numcount);"
c) for the update, I would do "update empolyee set salary = salary + 10000 where empid = numcount;" This would update the row that you just inserted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2002 02:39 PM
тАО06-12-2002 02:39 PM
Re: Question about insert statemnet in a while true loop
hi jeanine,
I thought of an idea, I learn on how to write
a cursor for loops, and in this i do the update
a. can a for loop to be in a while true loop..
i don't see any problem..as i write it, do you?
b. i can also create a procedure to do this?
c. please let me know if you have any idea on
how to generate a bunch of character.
create procedure tester0 IS
declare
high_pctinc constant number(10,5) :=1.50;
med_pctinc constant number (10,5) :=1.20;
low_pctinc constant number (10,5) :=1.10;
my_salary employee1.salary%TYPE;
my_empid employee1.empid%TYPE;
cursor employee1_crsr (low_end in VARCHAR2, high_end in VARCHAR2)
IS select empid, salary, from employee1
WHERE UPPER(substr(lastname,1,1))
BETWEEN UPPER(low_end) and UPPER(high_end);
numcount number;
begin
numcount:=0;
while true loop
numcount:=numcount+1;
insert into employee values (numcount,'dfadf', 789.90);
insert into employee (salary) values (800.00);
insert into employee (emp_name) values ('dlkjgl');
for my_employeerec IN employee1_crsr('B','X') loop
if my_emprec.empid < 100000 then
UPDATE employee1 set salary = my_employeerec.salary*high_pctinc;
where empid = numcount;
elsif my_emprec.empid < 3000000 then
update employee1 set salary = my_employeerec.salary*low_pctinc;
where empid = numcount;
else
update employee1 set salary = myemployeerec.salary*med_pctinc;
where empid = numcount;
end if;
end loop;
end loop;
end;
I thought of an idea, I learn on how to write
a cursor for loops, and in this i do the update
a. can a for loop to be in a while true loop..
i don't see any problem..as i write it, do you?
b. i can also create a procedure to do this?
c. please let me know if you have any idea on
how to generate a bunch of character.
create procedure tester0 IS
declare
high_pctinc constant number(10,5) :=1.50;
med_pctinc constant number (10,5) :=1.20;
low_pctinc constant number (10,5) :=1.10;
my_salary employee1.salary%TYPE;
my_empid employee1.empid%TYPE;
cursor employee1_crsr (low_end in VARCHAR2, high_end in VARCHAR2)
IS select empid, salary, from employee1
WHERE UPPER(substr(lastname,1,1))
BETWEEN UPPER(low_end) and UPPER(high_end);
numcount number;
begin
numcount:=0;
while true loop
numcount:=numcount+1;
insert into employee values (numcount,'dfadf', 789.90);
insert into employee (salary) values (800.00);
insert into employee (emp_name) values ('dlkjgl');
for my_employeerec IN employee1_crsr('B','X') loop
if my_emprec.empid < 100000 then
UPDATE employee1 set salary = my_employeerec.salary*high_pctinc;
where empid = numcount;
elsif my_emprec.empid < 3000000 then
update employee1 set salary = my_employeerec.salary*low_pctinc;
where empid = numcount;
else
update employee1 set salary = myemployeerec.salary*med_pctinc;
where empid = numcount;
end if;
end loop;
end loop;
end;
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP