Alibabacloud.com offers a wide variety of articles about sample stored procedure in oracle, easily find your sample stored procedure in oracle information here online.
Unlike SQL Server, Oracle uses Select to return the result set in the stored procedure, but returns the result set through Out parameters. It is actually using REF CURSORCopy codeThe Code is as follows:-- Procedure:-------------------- Declare a Package --------------Create or replace package pkg_testASTYPEmyrctypeIS r
Stored Procedure:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Create or replace procedure sp_test(Indthm in varchar,Outfzr out varchar,Outsjhm out varchar)Is
Begin/* Obtain the first record of the returned result */Select fzr, sjhm into outfzr, outsjhm from police where DTHM = indthm and rownum = 1;End;
Unlike SQL Server, Oracle uses Select to return the result set in the stored procedure, but returns the result set through Out parameters. It is actually using REF CURSOR
Copy codeThe Code is as follows: -- procedure returns the record set:
-------------------- Declare a Package --------------
Create or replace package
Tags: style blog http color io strong for ARThere are a number of different Oracle and SQL Server locations.Personal deepest experience is that the stored procedure returns the result set, and the direct select query in SQL Server is OK, Oracle is not.Here, we use the simplest example to illustrate the example of a
Nonsense written in front
Since the work needs to be frequently used in Oracle stored procedures, arrays are an inevitable element, so let's take a look at how Oracle stored procedures use arrays to a low level ....
The array is a data type. You need to create and declare the following statements.
Create Or Repla
oracle| Stored Procedures | Data Environment: WIN2000 + Oracle92
First, build a package in Oracle
CREATE OR REPLACE PACKAGE pkg_test
As
TYPE Myrctype is REF CURSOR;
PROCEDURE get (i_test integer,p_rc out myrctype);
End Pkg_test;
CREATE OR REPLACE PACKAGE body pkg_test
As
PROCEDU
3 ways to declare and assign an Oracle stored procedure variable creationtime--2018 August 31 16:00 author:marydon1.3 Ways to declare variablesDifferentiate by the way data types are declaredWay one: declaring data types directlyFormat: Variable name data type (size)V_start_date VARCHAR2 (+); V_num number;Description When set to string type, you need to specify
-- Oracle paging statements-- Id of each recordSelect t1. *, rownum rn from (select * from emp) t1;-- Retrieve the first 10 recordsSelect t1. *, rownum rn from (select * from emp) t1 where rownum -- Extract 6th to 10th records. This statement can be used as a paging template.Select * from(Select t1. *, rownum rn from (select * from emp) t1 where rownum Where rn> = 6;-- Start the paging Process-- 1. Create a package first. The test_cursor type defined
Configuration environment:
1. Database: Oracle 8i R2 (8.1.7) for NT Enterprise Edition
2, Installation path: c:oracle
Implementation method:
1.d:>set Nls_lang=american_america. USACII7
Or
D:>set Nls_lang=american_america. We8iso8859p1
D:>set
Direct SET command to view environment variables
2. Under D: Create the A.sql file, which reads as follows:
Java code
Create or Replace procedure test1 (i in number) as
Method 1
Today, I want to compare two characters in the stored procedure, but I found that the expected results were not obtained. The main problem is that the comparison of any value and null results are null, I found two methods on the Internet for your reference.
In Oracle, the Null String is considered null, and any value compared with null is null. In thi
PHP Program Access to the database, fully use stored procedures, some people think that the use of stored procedures for easy maintenance
But, benevolent see, on this issue, I think the use of stored procedures means that DBAs and developers need to work more closely together, and if one of them is notconsistent, it is obviously difficult to maintain.
But there a
further explained:
We need to modify the following SC table foreign key Declaration, add the name of the foreign key constraint, to facilitate our subsequent masking and recovery of foreign KEY constraints:
create table SC (s# integer , C # integer , Scor E integer , constraint sidfk foreign key (s#) references Student (s#) on delete cascade , constraint cidfk foreign key (C #) references Course (C #) on delete cascade ); Here the two foreign keys are named SIDF
. Column Name 1+cur_result. Column Name 2END; ENDLOOP; END;7, with PL/SQL developer debugCreate a test Window after connecting to the database Enter the code for the calling SP in the window, F9 start debug,ctrl+n single-Step debugging Precautions:1) The stored procedure parameter does not take the value range, in indicates the incoming, out represents the output; 2) variable can take the value range, follo
the stored procedure to take this parameter as a whole to deal with, not like ordinary SQL, he as an array to treatThird, the solutionBaidu a bit, found online programs quite a lot, but I chose the following scheme, is to customize a function, to deal with this parameter.Step one, create a new Oracle variable: (Normal SQL query window can be created)CREATE OR RE
Today, I found that this error always occurs when I use PHP to call the Oracle stored procedure. ORA-01008: notallvariablesbound later tossing for a long time, found that the variable name is wrong. Amp; lt ;? Php $ connoci_connect (SCOTT, TIGER) ordie; establish a connection if (! $ Conn) {$ eoci_err... today, I found that this error always occurs when using PH
Oracle stored procedure returns (N) working days based on the specified date
I have never written any Oracle stored procedures. Today I have a sudden demand: Calculate the first N working days of the specified date or the next N working days (excluding weekends, which cannot
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.