How to run a SQL server store procedure from Apex (oracle)?
Our application needs to call a store procedure in the SQLserver database. The sotre procedure works fine in the SQL server side. However, when I tried to call the store procedure in TOAD as:
exec my_store_procedure(para1, para2);
I kept getting the error message:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'my_store_procedure'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I have searched online but couldn't find the solution. This is an emergency, so prompt reply is Highly Appreciated!
Luc
How is Oracle connecting to the SQL Server?
With the Transparent Gateway or Generic Connectivity?
I don't think that Generic Connectivity supports stored procedures.
The documentation for Heterogeneous Connectivity is here:
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14232/toc.htm
You'd probably get better answers from the Heterogeneous Connectivity forum:
Heterogeneous Connectivity
Similar Messages
-
How to call a sql server stored procedure from oracle
Hi all,
Please anybody tell me how to call a sql server stored procedure from oracle.
I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
"dbo"."CreateReceipt"@hsa
where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
my database version is 10g
Please help me how can i call it... I need to pass some parameters too to the SP
thanking youhi,
thank you for the response.
when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
my code is,
declare
c INTEGER;
nr INTEGER;
begin
c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
end;
Create_Receipt is the sp which requires two parameters.
please give me a solution
thanking you
sreejith -
How to run a SQL Server Stored Procedure
I need to run a SQL Server Stored Procedure in answer, the stored procedure use a hash table (temporary table) and I nedd to pass a parameter to stored procedure
anyone know if is it possible in OBIEE, if yes how.
thank you
maxthank you, but I'm not understand what you mean. I need to run this command in answer "direct access database"
exec storedprocedure 1,1,1
if I run this I receive thi error:
error : [nQSError: 16001] ODBC error state: S0002 code: 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server]object name '#TempList' not valid.. [nQSError: 16002] Cannot obtain number of columns for the query result. (HY000).
here is the code of stored procedure:
ROC [dbo].[GetOrderListmax]
@OrderList varchar(500)
AS
BEGIN
SET NOCOUNT ON
CREATE TABLE #TempList
OrderID int
DECLARE @OrderID varchar(10), @Pos int
SET @OrderList = LTRIM(RTRIM(@OrderList))+ ','
SET @Pos = CHARINDEX(',', @OrderList, 1)
IF REPLACE(@OrderList, ',', '') <> ''
BEGIN
WHILE @Pos > 0
BEGIN
SET @OrderID = LTRIM(RTRIM(LEFT(@OrderList, @Pos - 1)))
IF @OrderID <> ''
BEGIN
INSERT INTO #TempList (OrderID) VALUES (CAST(@OrderID AS int)) --Use Appropriate conversion
END
SET @OrderList = RIGHT(@OrderList, LEN(@OrderList) - @Pos)
SET @Pos = CHARINDEX(',', @OrderList, 1)
END
END
SELECT o.OrderID, CustomerID, EmployeeID, OrderDate
FROM dbo.Orders AS o
JOIN
#TempList t
ON o.OrderID = t.OrderID
END -
How to run a SQL Server Agent job step on certain days/frequency
I've a SQL Server Agent job. One of the requirement is that a particular step should only run on certain frequency i.e. Certain Date and time. Any suggestions how can that be done?
GBMyes
1. Make first step as a Transact SQL step. Keep command as below
IF DAY(GETDATE()) = <Your date value>
AND DATEPART(hh,GETDATE()) = <your time hour)
AND DATEPART(minute,GETDATE()) = <your time minute)
SELECT 1
ELSE
RAISERROR 'Job cant be run at this time'
Then for job step properties set the following properties in advanced tab
This would make sure it will quit the job without executing other core steps untill it reaches the required day and time
You can add more conditions in IF based on requirement like if you want time to be on certain second or month to be particular value etc
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
SQL Server Store Procedure, selecting rows from multiple tables
i have got a store procedure that is pulling data from one table, now i have got the same data collected in a different table,
as the IDs are different i cannot put all data from the second table into the first one. so now i have to have two select statements in one store procedure. Although the corresponding data is same but the field names in both table are different. for instance
BRIEF_TITLE would be briefTitle in the second table. how can i merge the data from two different tables into one. the result is bonded to ASP.net grid view control.>> I have a store procedure that is pulling data from one table, now I have got the same data collected in a different table, as the IDs are different I cannot put all data from the second table into the first one. <<
This is redundancy. The idea of databases even before RDBMS, was to remove redundancy. Oh, columns are not fields. These are basic concepts.
>> so now I have to have two select statements in one store procedure. Although the corresponding data is same but the field [sic] names in both table are different.<<
NO! Where is your data dictionary that assures data elements have one and only one name everywhere in the enterprise! You are is serious trouble here. The data element names should be universal and used everywhere with the same casing, so that case sensitive
standards will work.
>> for instance BRIEF_TITLE would be briefTitle in the second table.<<
The quick kludge is a VIEW with the ISO-11179 names over the camelCase crap
The moron who did the second table does not know ISO-11179 Standards and missed the research that showed us that camelCase does not work. Your eye is trained to jump to an Uppercase letter since it is the start of a semantic unit (proper name, sentence, paragraph,
emphasis, etc). When we researched this stuff at AIRMICS, this could add 8-12% to the time to maintain code in large systems. Your eyes twitch!
You really need to get your act together with a good text editor/ pretty printer tools. Get a copy of my SQL Programming Style and adapt it to those tools.
>> The result is bonded to ASP.net grid view control. <<
We are the SQL guys; we do not are about the presentation layers :)
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Running a SQL Server Stored Procedure in JSP
Hi peoples!
I have a whole heaps of stored procedure sitting in a SQL Server database I need to make use of.
Im not sure of the code I need to use to access them, and display information from them.
Thanks a heapYou Need to set up a connection object like thus:
Connection conn1 = DriverManager.getConnection("jdbc:odbc:NameOfDatabase", "UserName", "Password");
and then call the following:
CallableStatement cs = conn1.prepareCall("{call spHowMyTeamPerforms(?, ?)}");
cs.setString(1, TeamId);
cs.setInt(2, viewId);
ResultSet result2 = cs.executeQuery();
As you can see I have a stored procedure called spHowMyTeamPerforms which expects two parameters, which explains the bumpf underneath.
Look through the tutorials about PreparedStatements and Callable statements as well -
Call SQL Server Stored Procedure from BPEL
Could somebody send me the tutorial on how to use Stored Procedures for SQL Server (as mentioned by mchiocca in this thread: Stored Procedure Support?
[email protected]
Thanks!This is not a possibility.
Refer to Support for Non-Oracle Stored Procedures -
Call a SQL Server stored procedure from AppleScript
I've a stored procedure that runs and creates a new Job Number. I need to create an applescript and run this stored procedure and prompt
the user with the new Job number on screen. Does SQL server support applescript? Any suggestions/alternative? ThanksHi SSRS-Newebie,
I am not that into Java as well, based on my research, in your case, you shall modify the Java file as below.
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
public class Main {
public static void main(String[] argv) throws Exception {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://MYSERVER;databaseName=MYDATABASE",
"USERID", "PASSWORD");
/*call the procedure here*/
CallableStatement proc_stmt = con.prepareCall("{ call Int.dbo.GetNewJobNumber(?,?,?) }");
/*set values for SP parameters*/
proc_stmt.setString(1, "6852");
proc_stmt.setString(2, "Test Job");
proc_stmt.setString(3, "Manual SQL Query");
ResultSet rs = proc_stmt.executeQuery();
/*get the result set values*/
if (rs.next()) {
/*you need to change the below to get correlated columns according to what your SP returns*/
int employeeId = rs.getInt(1);
System.out.println("Generated employeeId: " + employeeId);
} else {
System.out.println("Stored procedure couldn't generate new Id");
For more professional and technical quesions, I suggest you post them in dedicated
Java Forums.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
How to use @jws:sql call Stored Procedure from Workshop
Is there anyone know how to use @jws tag call Sybase stored procedure within
Workshop,
Thanks,Anurag,
Do you know is there any plan to add this feature in future release? and
when?
Thanks,
David
"Anurag Pareek" <[email protected]> wrote in message
news:[email protected]..
David,
In the current release, we do not support calling stored procedures from a
database control. You will have to write JDBC code in the JWS file to call
stored procedures.
Regards,
Anurag
Workshop Support
"David Yuan" <[email protected]> wrote in message
news:[email protected]..
Anurag,
I know how to use DB connection pool and create a db control with it. In
fact, we have created a Web Service with the db control using plain SQL
in
@jws:sql. However, my question here is how to use @jws tag in Weblogic
Workshop to create a Web Services based on Sybase stored procedure orany
Stored Proc not plain SQL.
Thanks,
David
"Anurag Pareek" <[email protected]> wrote in message
news:[email protected]..
David,
You can use a database control to obtain a connection from any JDBC
Connection Pool configured in the config.xml file. The JDBC Connectionpool
could be connecting to any database, the database control is
independent
of
that.
Regards,
Anurag
Workshop Support
"David Yuan" <[email protected]> wrote in message
news:[email protected]..
Is there anyone know how to use @jws tag call Sybase stored
procedure
within
Workshop,
Thanks, -
How to call PL-SQL script/stored procedure from Java?
Assume I want to call a PL-SQL stored procedure from external Java program.
How can I do this?
Is there a simple "Hello world" example for this?
PeterThis forum is for Oracle only not for java
Ug -
How to call PL-SQL script/stored procedure from BPEL?
Assume I want to call a PL-SQL stored procedure from BPEL.
How can I do this?
Is there a simple "Hello world" example for this?
PeterThe database adapter supports calling stored procedures. There is an example called "File2StoredProcedure" that you can use as a reference to get started.
-
Is there a way of firing up SQL Server stroed procedures from
Flash 8?
If so could someone explain how to do it please, as I would
like to pass parameters from choices made via drop down lists
(populated from xml pages) to query a SQL Server 2000 database.
Any help appreciated.
ThanksYes, I understand. But Flash doesn't talk directly to your
SQL API.
The SQL interface is only available through ASP (in your
case, or any number of server-side technologies). That's why you
use getUrl() (or other http request) to send data to an ASP script
which then executes the SQL statement 'execute <blah>
<blah> <blah>'.
You then take the results of that SQL, format it, and return
something to Flash all as part of the one and only HTTP request.
Does this make sense? -
How to find the SQL Server Instances running across the given activer directory domain?
How to find the SQL Server Instances running across the given activer directory domain?
I have though of OSQL -L , Microsoft Assessment and Planning ( MAP ) tool and SQLPing3 (SQLSecurity) might help me.
I would appreciate if there any other way of finding the SQL Servers / Instances running across the given active directory domain.
Sivaprasad S
http://sivasql.blogspot.com
Please click the Mark as Answer button if a post solves your problem!Dear ,
Very simple u find all instances through the customized sp which is get all details about inventory. Like i put the sp bellow. This is without any tool.
USE [master]
GO
/****** Object: StoredProcedure [dbo].[DBStatus] Script Date: 08-01-2015 19:46:11 By Damodar Patle Sr. DBA Mumbai India ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DBStatus]
AS
SELECT
SERVERPROPERTY('servername') AS ServerName,
ConnectionProperty('local_net_address') AS 'local_net_address',
ConnectionProperty('local_tcp_port') AS 'local_tcp_port',
CONVERT(VARCHAR(25), @@VERSION) as VERSIONSQL,
SERVERPROPERTY('ErrorLogFileName') AS ErrorLogFilePath,
database_id,
CONVERT(VARCHAR(25), DB.name) AS DBName,
CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'status')) AS [Status],
CONVERT(VARCHAR(10), DATABASEPROPERTYEX(name, 'Recovery')) AS [Recovery_Model],
create_date as DBCreate_Date, --physical_device_name,
(SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS DataFiles,
(SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS [Data MB],
(SELECT COUNT(1) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'log') AS LogFiles,
(SELECT SUM((size*8)/1024) FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'log') AS [Log MB],
(SELECT physical_name FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'rows') AS MDF_File_Location,
(SELECT physical_name FROM sys.master_files WHERE DB_NAME(database_id) = DB.name AND type_desc = 'log') AS LDF_File_Location,
user_access_desc
FROM sys.databases DB
ORDER BY dbName, [Log MB] DESC, NAME -
Writing a stored procedure to import SQL Server table data into a Oracle table
Hello,
As a new DBA I have been tasked with writing a stored procedure to import SQL Server table data into an Oracle table. I have been given many suggestions on how to do it from SQL Server but I I just need to write a stored procedure to run it from the Oracle side. Suggestions/guidance on where to start would be greatly appreciated! Thank you!
I started to write it based on what I have but I know this is not correct :/
# Here is the select statement for the data source in SQL Server...
SELECT COMPANY
,CUSTOMER
,TRANS_TYPE
,INVOICE
,TRANS_DATE
,STATUS
,TRAN_AMT
,CREDIT_AMT
,APPLD_AMT
,ADJ_AMT
,TRANS_USER1
,PROCESS_LEVEL
,DESCRIPTION
,DUE_DATE
,OUR_DATE
,OUR_TIME
,PROCESS_FLAG
,ERROR_DESCRIPTION
FROM data_source_table_name
#It loads data into the table in Oracle....
Insert into oracle_destination_table_name (
COMPANY,
CUSTOMER,
TRANS_TYPE,
INVOICE,
TRANS_DATE,
STATUS,
TRANS_AMT,
CREDIT_AMT,
APPLD_AMT,
ADJ_AMT,
TRANS_USER1,
PROCESS_LEVEL,
DESCRIPTION,
DUE_DATE,
OUR_DATE,
OUR_TIME,
PROCESS_FLAG,
ERROR_DESCRIPTION)
END;CREATE TABLE statements would have been better as MS-SQL and Oracle don't have the same data types.
OUR_DATE, OUR_TIME will (most likely) be ONE column in Oracle.
DATABASE LINK
Personally, I'd just load the data over a database link:
insert into oracle_destination_table_name ( <column list> )
select ... <transform data here>
from data_source_table@mssql_db_link
As far as creating the database link from Oracle to MS-SQL ... that is for somebody else to answer.
(most likely you'll need to use an ODBC driver)
EXTERNAL TABLE
If the data from MS-SQL is in a CSV file, just use and external table.
same concept:
insert into oracle_destination_table_name ( <column list> )
select ... <transform data here>
from data_source_external_table
MK -
Converting SQL Server Stored Procedure to Oracle
Hi there,
I tried to use SwisSQL to convert my SQL Server stored procedure to Orcale without much success.
Is there anyone who could help me out with this?
My SQL Server Stored Procedure is:
CREATE PROCEDURE [dbo].[SP_BackgroundCheckRequest]
--MASTER Table
@MASTER_ID int,
@PERSONNEL_ID int = NULL,
@DATE_OF_BIRTH datetime = NULL,
@GENDER varchar(1) = NULL,
@COUNTRY_OF_BIRTH varchar(3) = NULL,
@TOWN_OF_BIRTH varchar(100) = NULL,
@STATE_OF_BIRTH varchar(50) = NULL,
@CHECK_CATEGORY varchar(10) = NULL,
@CHECK_TYPE varchar(10) = NULL,
@PRIORITY varchar(10) = NULL,
@PRIORITY_REASON varchar(100) = NULL,
@SCREENING_LEVEL nchar(1) = NULL,
@POSITION nchar(50) = NULL,
@REQUEST_SOURCE varchar(60) = NULL,
--NAME_TYPE Table
@NAME_TYPE varchar(5) = NULL,
@FAMILY_NAME varchar(50) = NULL,
@FIRST_NAME varchar(50) = NULL,
@MIDDLE_NAME varchar(50) = NULL,
@TITLE varchar(10) = NULL,
@PREFFERED_NAME varchar(40) = NULL,
@PREVIOUS_NAME varchar(140) = NULL,
--ADDRESS_TYPE Table
@ADDRESS_TYPE varchar(10) = NULL,
@ADDRESS_LINE_1 varchar(30) = NULL,
@ADDRESS_LINE_2 varchar(30) = NULL,
@ADDRESS_LINE_3 varchar(30) = NULL,
@COUNTRY varchar(3) = NULL,
@SUBURB varchar(50) = NULL,
@STATE varchar(50) = NULL,
@POSTCODE varchar(15) = NULL,
@START_DATE varchar(10) = NULL,
@END_DATE varchar(10) = NULL,
--LICENSE_TYPE Table
@LICENSE_TYPE varchar(5) = NULL,
@LICENSE_AGENCY varchar(15) = NULL,
@LICENSE_NUMBER varchar(100) = NULL,
@LICENSE_SIGHTED varchar(1) = NULL,
--PHONE_TYPE Table
@TELEPHONE_TYPE varchar(5) = NULL,
@TELEPHONE_NUMBER varchar(20) = NULL,
@MOBILE_TYPE varchar(5) = NULL,
@MOBILE_NUMBER varchar(20) = NULL,
@EXTENSION_TYPE varchar(5) = NULL,
@EXTENSION_NUMBER varchar(20) = NULL,
--PASSPORT_TYPE Table
@PASSPORT_TYPE varchar(5) = NULL,
@PASSPORT_NUMBER varchar(50) = NULL,
@PASSPORT_COUNTRY varchar(3) = NULL,
@PASSPORT_SIGHTED varchar(1) = NULL
AS
BEGIN TRANSACTION
INSERT into MASTER (MASTER_ID, PERSONNEL_ID, DATE_OF_BIRTH, GENDER, COUNTRY_OF_BIRTH,
TOWN_OF_BIRTH, STATE_OF_BIRTH, CHECK_CATEGORY, CHECK_TYPE, PRIORITY, PRIORITY_REASON,
SCREENING_LEVEL, POSITION, REQUEST_SOURCE)
VALUES (@MASTER_ID, @PERSONNEL_ID, @DATE_OF_BIRTH, @GENDER, @COUNTRY_OF_BIRTH,
@TOWN_OF_BIRTH, @STATE_OF_BIRTH, @CHECK_CATEGORY, @CHECK_TYPE, @PRIORITY, @PRIORITY_REASON,
@SCREENING_LEVEL, @POSITION, @REQUEST_SOURCE)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting values into MASTER table!', 16, 1)
RETURN
END
INSERT into NAME_TYPE (MASTER_ID,NAME_TYPE,FAMILY_NAME,FIRST_NAME,MIDDLE_NAME,TITLE)
VALUES (@MASTER_ID,@NAME_TYPE,@FAMILY_NAME,@FIRST_NAME,@MIDDLE_NAME,@TITLE)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting values into NAME_TYPE table!', 16, 1)
RETURN
END
INSERT into ADDRESS_TYPE (MASTER_ID,TYPE,ADDRESS_LINE_1,ADDRESS_LINE_2,ADDRESS_LINE_3,
COUNTRY,SUBURB,STATE,POSTCODE,START_DATE,END_DATE)
VALUES (@MASTER_ID,@ADDRESS_TYPE,@ADDRESS_LINE_1,@ADDRESS_LINE_2,@ADDRESS_LINE_3,
@COUNTRY,@SUBURB,@STATE,@POSTCODE,@START_DATE,@END_DATE)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting values into ADDRESS_TYPE table!', 16, 1)
RETURN
END
INSERT into LICENSE_TYPE (MASTER_ID,TYPE,AGENCY,NUMBER,SIGHTED_YN)
VALUES (@MASTER_ID,@LICENSE_TYPE,@LICENSE_AGENCY,@LICENSE_NUMBER,@LICENSE_SIGHTED)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting values into LICENSE_TYPE table!', 16, 1)
RETURN
END
INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
VALUES (@MASTER_ID,@TELEPHONE_TYPE,@TELEPHONE_NUMBER)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting Telephone number into PHONE_TYPE table!', 16, 1)
RETURN
END
IF ((@MOBILE_TYPE <> NULL) AND (@MOBILE_NUMBER <> NULL))
BEGIN
INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
VALUES (@MASTER_ID,@MOBILE_TYPE,@MOBILE_NUMBER)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting Mobile number into PHONE_TYPE table!', 16, 1)
RETURN
END
END
IF ((@EXTENSION_TYPE <> NULL) AND (@EXTENSION_NUMBER <> NULL))
BEGIN
INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
VALUES (@MASTER_ID,@EXTENSION_TYPE,@EXTENSION_NUMBER)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting Extension number into PHONE_TYPE table!', 16, 1)
RETURN
END
END
INSERT into PASSPORT_TYPE (MASTER_ID,NUMBER,COUNTRY,SIGHTED_YN)
VALUES (@MASTER_ID,@PASSPORT_NUMBER,@PASSPORT_COUNTRY,@PASSPORT_SIGHTED)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error inserting values into PASSPORT_TYPE table!', 16, 1)
RETURN
END
COMMITFirst, a basic concept. That also illustrates how different Oracle is (and PL/SQL) from SQL-Server (and T-SQL).
PL/SQL integrates two different languages. The PL language. The SQL language. It allows you to code SQL source code natively inside the PL language. The PL compiler is clever enough to do the rest - make calls to the SQL engine to create SQL cursors, bind PL variable values to bind variables in the SQL code. Etc.
PL is a "proper" programming language. It is much like Pascal (it is based on Ada, a close family member of Pascal). It is nothing at all like T-SQL.
Okay, now for the very basic rule for Oracle development.
Maximize SQL. This means using the SQL language to crunch data. It is the "closest" to the data. It is designed and optimised for dealing with data. Do your data processing using SQL.
Minimize PL/SQL. This means using the PL language not to crunch data, but to provide the conditional logic. Implement business rules. And then have the SQL language crunch the data as the data processing language.
Attempting to directly translate T-SQL code into PL/SQL is flawed. It is like trying to make coffee with teabags. Yeah, the tea may have caffeine it, but it is not coffee.
To do what that T-SQL script does, insert a row into a table, a typical PL/SQL equivalent will look as follows:
create or replace procedure InsertMaster( masterRow master%rowtype ) authid definer is
.. types and variables declared here
begin
-- masterRow is a record structure that matches the actual MASTER table
.. apply business rules and validation to the data.. raising user exceptions as needed
-- e.g. the POSITION column must be upper case
masterRow.position := upper(masterRow.position);
-- after the business logic and data validation we can add the row to the table
-- (PL will make the INSERT call to the SQL engine)
insert into master values masterRow;
end;No commit. The caller does the business transaction. It needs to decide when to commit to maintain the integrity of the data in the database. It may need to do several more calls, before committing.
With this approach, we can give the application schema (the caller) execute privs on this procedure. This procedure is defined with definer rights. This means it runs with the privs of owner of that procedure and MASTER table. It is trusted code. It does all the correct stuff to add a valid and checked row to the MASTER table. So we give the app schema execute privs on the procedure and no insert priv on the MASTER table.
The only way the caller can add row to the MASTER table is via this trusted procedure of ours.
And this is a typical approach in Oracle - using the PL/SQL (both PL language and SQL language) code to create an interface to a logical database in Oracle. Abstracting the complexities of SQL from the caller. Moving business and validation into PL. Allowing us the flexibility of modifying business and validation logic, without touching a single byte of caller/client code. Allowing us to manage and tune SQL performance without dealing with (badly designed and coded) SQL from a client - as the SQL resides in PL/SQL packages and procedures and functions.
Maybe you are looking for
-
I was trying to install XP last night on my imac with boot camp and ran into this problem. The partition I would create in Boot Camp would never show when rebooting with the XP cd so I thought, Maybe its on the next screen of XP install. I SELECTED t
-
We have two OBIEE environment running with the 11.1.1.6 version of OBIEE. We have developed a .rpd in one of the environment and able to run it in that envioronment. Using the Admin tool we have taken a copy of that .rpd file to an another enviornmen
-
Unload event for external swf[urgently need help]
hi all master, iI've mp3, eksternally loaded and I controlled from main time... the bugs are 1. If I wanna go to another .swf file, i still can hear the sound... 2. if I click the button wich linked to mp3.swf, the sound/song are duplicated by2, and
-
Cprojects / Cfolders new Install
We are planning a new installation of the Cprojects and Cfolders. We are having a problem with the new names of the products and what material needs to be installed. What we have planned is to install: Netweaver 2004s ABAP only instance on the Iserie
-
Are there any DVD duplicators that can also double as a burner to burn DVD's directly from my G4? And if so, will it work with DVD Studio Pro? With iDVD? With Disk Utility? I still use the superdrive in my G4. It works but of course is slow.