Home > database >  Everyone a great god, genuflect is begged how to want to use the cursor in the ORACLE stored procedu
Everyone a great god, genuflect is begged how to want to use the cursor in the ORACLE stored procedu

Time:10-02


NAME code select no a.org, a.org, a.org, byxzhy "new members this month," syxzhy "new members last month," (byxzhy - NVL (syxzhy, 0)) "new members than
A,
"Syyxhy byyxhy "active member/this month", "active member/last month," byyxhy - NVL (syyxhy, 0) "active member/
Compare, "
Byhylks "member guest number/this month," syhylks "member guest number/last month," byhylks - NVL (syhylks, 0)
"Member guest number/comparison",
Syhykdj byhykdj "member guest unit price/this month", "member guest unit price/last month," byhykdj - NVL (syhykdj, 0)
"Member guest unit price/comparison,"
Byxshe "sales/this month," syxshe "sales/last month," byxshe - NVL (syxshe, 0) "sales total
The forehead/comparison, "
Byhyxshe membership sales/month, syhyxshe "membership sales/last month," byhyxshe - NVL
(syhyxshe, 0) "membership sales/comparison",
Byhyxszb membership sales proportion/month, syhyxszb "membership sales proportion/last month", byhyxszb - NVL
(syhyxszb, 0) "membership sales proportion/comparison",
Byprofit "member margin/this month," syprofit "member margin/last month," byprofit - NVL
(syprofit, 0) "member margin/comparison",
Byprofitrate "member's gross margin/this month," syprofitrate "member's gross margin/last month", a.e ntid

A, the from ORGDOC b_byhyjx b, c_syhyjx c
Where a.ORG ID=b. DBS and a.ORG ID=c.f DBS and a.E NTID=entid and Anderson sOrg<>
'Y'The order by a.ORG ID;

CodePudding user response:

 
- about such a syntax

The create or replace procedure sp_a (ot varchar2, p_out out sys_refcursor)
As
The begin
The open p_out
For
The select object_id, object_name
The from user_objects where object_type=ot;
The end;

CodePudding user response:

Here are two examples of cursor;
 DECLARE 
CURSOR TEST IS
SELECT *
The FROM (SELECT 1 A and 1 B
The FROM DUAL
UNION ALL
SELECT 2, 2
The FROM DUAL
UNION ALL
SELECT 3, 3
The FROM DUAL) BB;
C_TEST TEST % ROWTYPE;
The BEGIN
FOR C_TEST IN the TEST LOOP
DBMS_OUTPUT. PUT_LINE (C_TEST. A | | '_' | | C_TEST. B);
END LOOP;
The END;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
DECLARE
CURSOR TEST IS
SELECT *
The FROM (SELECT 1 A and 1 B
The FROM DUAL
UNION ALL
SELECT 2, 2
The FROM DUAL
UNION ALL
SELECT 3, 3
The FROM DUAL) BB;
C_TEST TEST % ROWTYPE;
The BEGIN
OPEN the TEST;
LOOP
FETCH the TEST
INTO C_TEST;
The EXIT WHEN the TEST % NOTFOUND;
DBMS_OUTPUT. PUT_LINE (C_TEST. A | | '_' | | C_TEST. B);
END LOOP;
The END;

CodePudding user response:

Use cursor wrote this select, and then, what is behind the demand

CodePudding user response:

Using a stored procedure call out the query results

CodePudding user response:

 
Declare
Cursor mycursor
Is
Your SQL statements;
C_row mycursor % rowtype;
The begin
For c_row mycursor in loop
Your business, circulation processing, such as
No dbms_output. Put_line (c_row.org);
End loop;
The end;
  • Related