| |

VerySource

 Forgot password?
 Register
Search
View: 1123|Reply: 7

How to generate a new table during execution of a stored procedure

[Copy link]

2

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-22 22:30:02
| Show all posts |Read mode
A table is generated when the stored procedure exec sel-all is executed. How can I perform operations on this table?
My stored procedure is as follows:
CREATE proc sel_all as
select l_no, type = 'picking list', date, danhao, dept, glno, wlbh, ​​l_name, quality, sysdate from linliao
union
select t_id, type = 'Return bill', t_date, danhao, dept, orderno, wlbh, ​​t_name, store sysdate from tuiliao

I also need to operate on the table generated after execution, or let it generate a new table after execution
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-5-4 19:30:01
| Show all posts
insert into newtable select * from (
select l_no, type = 'Pickup list', date, danhao, dept, glno, wlbh, ​​l_name, quality, sysdate from linliao
union
select t_id, type = 'return form', t_date, danhao, dept, orderno, wlbh, ​​t_name, store sysdate from tuiliao) a
Reply

Use magic Report

0

Threads

66

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-5-4 20:45:01
| Show all posts
select * into table1 from (select l_no, type = 'picking list', date, danhao, dept, glno, wlbh, ​​l_name, quality, sysdate from linliao
union
select t_id, type = 'return form', t_date, danhao, dept, orderno, wlbh, ​​t_name, store sysdate from tuiliao) t
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-5-5 12:45:01
| Show all posts
insert newTbName exec sel_all
Reply

Use magic Report

0

Threads

40

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-5-18 20:00:01
| Show all posts
Correct,
select * into table name from
(.....................) alias
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-5-19 14:15:01
| Show all posts
alter proc sel_all
as

insert into tablename select * from (
select l_no, type = 'request list', date, danhao, dept, glno, wlbh, ​​l_name, quality, sysdate from linliao
union
select t_id, type = 'return form', t_date, danhao, dept, orderno, wlbh, ​​t_name, store, sysdate from tuiliao) T
Reply

Use magic Report

2

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-5 17:45:01
| Show all posts
I need to call this stored procedure repeatedly. Is it possible to generate a temporary table that will automatically disappear after being used up? A new one will be generated the next time it is called
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-6-6 10:45:01
| Show all posts
#Temporary table name

Before the table name +'#' will be automatically recovered after the connection is over
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list