Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Creation of oracle package

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The composition of a packet

1) package: the header part declares data types, constants, variables, cursors, subroutines and exception error handling in the package

These elements are public elements of the package.

2) package body (package body): the package body is the concrete implementation of the package definition part, which is responsible for the declared subroutine in the package header.

Provide a specific implementation, and you can declare the private elements of the package in the package body

3) the header and the package body are compiled separately and stored in the database dictionary as two separate objects

-- Delete package

-- drop package pkg_lxg_test

-- 1) first create the package header (do not write the header and the sql of body in the same file)

-multiple procedure can be declared here (only if external calls are made)

Create or replace package pkg_lxg_test as

Procedure deleteTask (taskTypeCode in varchar2,-- Task type code

BusinessKey in varchar2,-- Business number

ResultCode out varchar2,-- result code

ResultMessage out varchar2-result information

);

End pkg_lxg_test

--) 2 create the package body again (the above header cannot be executed with the body, and the transfer should be written as two sql files for transfer)

-) 3 after the creation is completed, it will be compiled automatically if the creation is successful

--) 4 if the creation of the package is not successful, you can see the error in the view and description

-) 5 after the package is created,-- > right-click, view-> then select the proc in the package you want to test and right-click-- "Test"

CREATE OR REPLACE PACKAGE BODY NBADATA.pkg_lxg_test AS

Function function2 (taskTypeCode in varchar2,businessKey in varchar2) return varchar2

Is

V_preview_environment varchar2 (4)

V_voucher_no varchar2 (50)

V_count number default 0

Begin

Vested previewpoints of psychology ='1'

-- dbms_output.put_line ('method function2' was executed)

Return v_preview_environment

End function2

-- procedure is defined here, and multiple points can be specified.

Procedure deleteTask (taskTypeCode in varchar2,-- Task type code

BusinessKey in varchar2,-- Business number

ResultCode out varchar2,-- result code

ResultMessage out varchar2-result information

) IS

Begin

Begin

ResultCode: ='0'

ResultMessage: = 'delete asynchrouns task sucess'

-- dbms_output.put_line ('stored procedure executed successfully')

Exception

When others then

ResultCode: ='1'

ResultMessage: = 'fail in deleting asynchrouns task sucess'

End

End deleteTask

End pkg_lxg_test

/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report