Creation of System Stored Procedure in SQL Server 2012 & SQL Server 2012 R2.
Hi all,
I am stuck at a point I am looking for a system stored procedure named 'sp_dboption' in SQL Server 2012 & R2 but could not find.
Searched for it on the net and found that, this stored procedure 'sp_dboption' is now obsolete. So I tried to copy the content of 'sp_dboption' stored procedure from SQL Server 2008 R2 and create new system stored procedure with this name 'sp_dboption' in
SQL Server 2012 but was unable to create the system stored procedure.
Can you guys please tell me how to create system stored procedure in SQL Server 2012 & SQL Server 2012 R2. The reason of why I want to achieve this is because I have used 'sp_dboption' system stored procedure in my application to create a database.
As 'sp_dbotion' stored procedure is present in SQL Server 2008 R2 I am able to create the database in SQL server 2008 R2 but not in SQL server 2012.
Can you please guide me how to create system stored procedure. I am out of luck.
Please assist me, thanks & looking for help at the earliest. Hope someone will come to the fore and help me.
Hi Vishwajeet,
If you tried to create any object in the sys schema, you will get the error below.
The specified schema name "sys" either does not exist or you do not have permission to use it.
So I am afraid creating any object in sys schema is not supported by SQL Server. Here is a similar link for your reference.
How to create table in SYS schema in SQL Server?
Though sp_dboption is not in SQL Server 2012, does creating a user-defined one with the same content in 2008 make any difference in your business? You just need to specify the fully qualified name dbname.dbo.sp_dboption.
If you are still interested in creating a system sp_dboption, you can register it with the
sp_ms_marksystemobject.
See
Creating Your Own SQL Server System Stored Procedures.
Eric Zhang
TechNet Community Support
Similar Messages
-
MS SQL Server system stored procedures can't be migrated into Oracle 11g
During database migration from MS SQL Server 2008 to Oracle 11g R2, if the application stored procedure invokes the MS SQL Server system stored procedures (for example: sp_getapplock, sp_releaseapplock ....), these SQL server system stored procedures can't be transferred. See following migrated Oracle application stored procedure for example:
create or replace
PROCEDURE spPwSysID_GetNextID
v_ID OUT NUMBER,
iv_SysType IN NVARCHAR2 DEFAULT NULL ,
iv_Cnt IN NUMBER DEFAULT NULL
AS
v_SysType NVARCHAR2(50) := iv_SysType;
v_Cnt NUMBER(10,0) := iv_Cnt;
v_result NUMBER(10,0);
BEGIN
--SQL Server BEGIN TRANSACTION;
utils.incrementTrancount;
v_Systype := UPPER(v_Systype) ;
IF v_Cnt < 1 THEN
v_Cnt := 1 ;
END IF;
v_result :=sp_getapplock(v_Resource => v_Systype,
v_LockMode => 'Exclusive') ;
IF v_result >= 0 THEN
BEGIN
SELECT ID
INTO v_ID
FROM PWSYSID
WHERE SysType = v_SysType;
IF SQL%ROWCOUNT = 1 THEN
UPDATE PwSysID
SET ID = ID + v_cnt
WHERE SysType = v_SysType;
ELSE
BEGIN
INSERT INTO PwSysID
( ID, SysType )
VALUES ( v_cnt + 1, v_SysType );
v_ID := 1 ;
END;
END IF;
v_result :=sp_releaseapplock(v_Resource => v_Systype) ;
END;
ELSE
BEGIN
raise_application_error( -20002, 'Lock failed to acquire to generate Cityworks Id.' );
END;
END IF;
utils.commit_transaction;
END;During database migration from MS SQL Server 2008 to Oracle 11g R2, if the application stored procedure invokes the MS SQL Server system stored procedures (for example: sp_getapplock, sp_releaseapplock ....), these SQL server system stored procedures can't be transferred. See following migrated Oracle application stored procedure for example:
create or replace
PROCEDURE spPwSysID_GetNextID
v_ID OUT NUMBER,
iv_SysType IN NVARCHAR2 DEFAULT NULL ,
iv_Cnt IN NUMBER DEFAULT NULL
AS
v_SysType NVARCHAR2(50) := iv_SysType;
v_Cnt NUMBER(10,0) := iv_Cnt;
v_result NUMBER(10,0);
BEGIN
--SQL Server BEGIN TRANSACTION;
utils.incrementTrancount;
v_Systype := UPPER(v_Systype) ;
IF v_Cnt < 1 THEN
v_Cnt := 1 ;
END IF;
v_result :=sp_getapplock(v_Resource => v_Systype,
v_LockMode => 'Exclusive') ;
IF v_result >= 0 THEN
BEGIN
SELECT ID
INTO v_ID
FROM PWSYSID
WHERE SysType = v_SysType;
IF SQL%ROWCOUNT = 1 THEN
UPDATE PwSysID
SET ID = ID + v_cnt
WHERE SysType = v_SysType;
ELSE
BEGIN
INSERT INTO PwSysID
( ID, SysType )
VALUES ( v_cnt + 1, v_SysType );
v_ID := 1 ;
END;
END IF;
v_result :=sp_releaseapplock(v_Resource => v_Systype) ;
END;
ELSE
BEGIN
raise_application_error( -20002, 'Lock failed to acquire to generate Cityworks Id.' );
END;
END IF;
utils.commit_transaction;
END; -
I am newbee in Oracle.
Are there any system stored procedures in Oracle to create a file on file system, as in SQL Server such as xsp_UpdateSignalFile, sp_makewebtask.
Pls advise.
ThanksThanks for the information.
I want to create a file on windows file system. Is that feasible? I tried with below code but got errors.....
PROCEDURE p_testproc
IS
v_file UTL_FILE.FILE_TYPE;
v_filename varchar2(40):='dep.log';
v_locat varchar2(200):='c:\tmp\';
BEGIN
dbms_output.put_line('proc begin.....');
if UTL_FILE.is_open(v_file) then
dbms_output.put_line('file opened');
else
dbms_output.put_line('file closed');
end if;
v_file:=SYS.UTL_FILE.FOPEN(v_locat,v_filename,'w');
UTL_FILE.FCLOSE(v_file);
dbms_output.put_line('File has been created');
END p_testproc;
Any help would be appreciated.
Thanks in advance -
Replicating System Stored Procedures in MSA Setup
I started replicating system stored procedures in my MSA environment due to the fact that commands such as sp_rename was not making it to my MSA server. This caused some issues downstream resulting in the DSI goign down and having to manually apply these statements on the target server.
My question is, are there any cons/drawback to enabling such option
In reading the manual one of the requirements was that
Make sure that both the primary and replicate data servers are the same version of Adaptive Server.
I am Replication from Sybase Cluster Edition 15.7 SP131 to Sybase SMP 15.7 SP131. So far I have not encountered any issues but I don't like surprises.
Other requirements are met
When replicating DDL – the primary and replicate databases must have the same login names and passwords; the DSI uses the original server login name and password to log in to the replicate database.
For me the logins are identical on both servers so this is not an issue
To replicate DDL and system procedures:
Mark the primary database using sp_reptostandby.
Set the RepAgent parameter send warm standby xacts to true—even if there is no standby database
I also have a warm standby setup and I am using the logical connection as the primary dataserver so these conditions are also met
ThanksI started replicating system stored procedures in my MSA environment due to the fact that commands such as sp_rename was not making it to my MSA server. This caused some issues downstream resulting in the DSI goign down and having to manually apply these statements on the target server.
My question is, are there any cons/drawback to enabling such option
In reading the manual one of the requirements was that
Make sure that both the primary and replicate data servers are the same version of Adaptive Server.
I am Replication from Sybase Cluster Edition 15.7 SP131 to Sybase SMP 15.7 SP131. So far I have not encountered any issues but I don't like surprises.
Other requirements are met
When replicating DDL – the primary and replicate databases must have the same login names and passwords; the DSI uses the original server login name and password to log in to the replicate database.
For me the logins are identical on both servers so this is not an issue
To replicate DDL and system procedures:
Mark the primary database using sp_reptostandby.
Set the RepAgent parameter send warm standby xacts to true—even if there is no standby database
I also have a warm standby setup and I am using the logical connection as the primary dataserver so these conditions are also met
Thanks -
Create stored procedure or function of pl/sql in jdeveloper
How can we create a stored procedure or function of pl/sql in jdeveloper 11.1.2.1.0? And how it will be called? Please help me?
Edited by: mrs on 4 Jul, 2012 3:07 AMI am a beginner to jdeveloper and adf so please give a step by step method for how to create a stored procedure of pl/sql in jdeveloper 11.1.2.1.0
-
Check Stored Procedures after Migration from MS SQL Server 2008 to Oracle11
I successfully migrated my application database (azteca) from MS SQL Server 2008 to Oracle 11g R2. After migration, I found there are few stored procedures are not valid. How do I check these invalid stored procedures and find what is wrong with them by using SQL Developer? Thanks for your help.
KevinHi Kevin,
You posted quite a bit today, so perhaps you have already worked this out. If not...
1. View -> Reports -> Data Dictionary Reports -> All Objects -> Invalid Objects [for a specific schema name]
2. Next, for each invalid stored procedure listed in (1)...
a. Open in the code editor from the Connections navigator tree
b. Click on the Compile icon (two gears meshed together) in code editor tool bar.
c. Look in the Compiler log pane for errors.
d. Correct the errorsOf course, success in addressing any errors depends on your skill level dealing with Oracle PL/SQL.
Also, it may be helpful to read over section *3.2 Stored Procedures* in the supplementary migration guide:
http://docs.oracle.com/cd/E35137_01/doc.32/e18462/trig_stored_proc.htm#CHDEIGBC
Regards,
Gary
SQL Developer Team -
Java Stored Procedures + oralce.xdb.XMLType + initxdbj.sql
In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
Please help, Thanks.
Andy Ting DBA (301)240-2223, [email protected](now include Listings)
In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
Please help, Thanks.
Andy Ting DBA (301)240-2223, [email protected]
====================================================================
List 1:
sql> select NAME,TYPE,SEQUENCE,LINE,substr(text,1,80) TEXT from user_errors order BY 1,2,3,4
NAME TYPE SEQUENCE LINE
TEXT
proto4a/database/XMLTypeTest JAVA CLASS 1 0
ORA-29535: source requires recompilation
proto4a/database/XMLTypeTest JAVA SOURCE 1 0
proto4a/database/XMLTypeTest:11: Class oracle.xdb.XMLType not found in import.
proto4a/database/XMLTypeTest JAVA SOURCE 2 0
proto4a/database/XMLTypeTest:12: Class XMLTYPE not found in import.
proto4a/database/XMLTypeTest JAVA SOURCE 3 0
Info: 2 errors
==============================================================
List 2:
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
where upper(object_name) like '%XMLTYPE%';
OWNER OBJECT_NAME OBJECT_TYP
SYS /219cdace_AQxmlTypeInfoRespons JAVA CLASS
/a341e963_AQxmlTypeInfoRequest
XMLTYPE TYPE
XMLTYPE TYPE BODY
XMLTYPE_LIB LIBRARY
PUBLIC /219cdace_AQxmlTypeInfoRespons SYNONYM
/a341e963_AQxmlTypeInfoRequest
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
where upper(object_name) like '%XDB%';
no rows selected
====================================================================
List 3:
Installing and using oracle.xdb.XMLType class
The oracle.xdb.XMLType is available in the xdb_g.jar file in the ORACLE_
HOME/rdbms/jlib where ORACLE_HOME refers to the Oracle home directory.
Using oracle.xdb.XMLType inside JServer:
This class is pre-loaded in to the JServer and is available in the SYS schema.
It is not loaded however, if you have upgraded your database from an earlier
version. If you need to upload the class into the JServer, you would need to run the
initxdbj.sql file located in the ORACLE_HOME/rdbms/admin directory, while
connected as SYS.
Using oracle.xdb.XMLType on the client:
If you need to use the oracle.xdb.XMLType class on the client side, then ensure that
the xdb_g.jar file is listed in your CLASSPATH environment variable.
===================================================================== -
Get System Stored Procedure Data in variables
Hello all Forum Members,
I am new to SQL Server.
My Requirement is that i want to get sp_helpuser procedure data in select query variables.
is it Possible?
Please Help.Hi Prashanth,
It works as per my requirement.
But, Can it be achieved without creating table type variable i.e by creating simple variables ?
Thanks very much for the reply.
its possible to get stored procedure resultset using a select as per method 2 below
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to invoke Oracle stored procedures in Web Intelligence Custom SQL ?
Hi,
Referring to some older posts, I see that there is a work around to invoke a stored procedure to return results for a Web Intelligence report. Its been posted for calling a MS SQL stored proc, whereas the mentioned method does not seem to work for an Oracle Stored Procedure.
Steps I followed:
a) This is the parameter I have added in the oracle.sbo file => <Parameter Name="Force SQLExecute">Procedures</Parameter>
b) My stored procedure code is as follows:
CREATE OR REPLACE PROCEDURE get_emp_details(var_first_name OUT VARCHAR) AS
BEGIN
SELECT first_name INTO var_first_name
FROM EMP_DETAILS_VIEW
WHERE EMPLOYEE_ID = 100;
END;
c) Custom SQL code I added in my Webi report:
set nocount on;
/* SELECT
EMP_DETAILS_VIEW.FIRST_NAME
FROM
EMP_DETAILS_VIEW
exec get_emp_details;
On trying to validate the SQL it gives me the following error message: "The SQL query has 0 instead of 1 columns.(WIS 10810)"
Has anyone been able to successfully call an Oracle Stored procedure using the above method ?
Version of BO: XI R3 SP2
Oracle version: 11gR2
PS: I am aware that web intelligence since XI R3.1 does allow use of a dedicated Stored Procedure Universe. I would want to know if it could
be made to run in a normal Universe(not a stored procedure Universe)
Thanks for your time and inputs.
Regards,
JezEXECUTE is a SQL Plus command. You can directly call SP in PL/SQL
DECLARE
modif number;
BEGIN
select data_length into modif from user_tab_columns where table_name='CONTROL' and column_name='POSITION';
IF modif < 10 THEN
droptable('CONTROL');
execute immediate('CRETAE TABLE CONTROL ....';
... -
Calling System Stored Procedures (Eg: sp_help)
Hi,
Can you help me on how to call the System SPs like sp_help using JDBC?
I'm using com.sybase.jdbc2.jdbc.SybDriver. I know that this will produce multiple ResultSet. Hope I can use the cstmt.getResultSet() to handle multiple ResultSets.
Code Snippet:
try {
cstmt = con.prepareCall("{call " + env + "..sp_help (" + table + ")}");
cstmt.setString(1, table);
if (cstmt.execute()) {
rs =cstmt.getResultSet();The stmt.execute() is returning false. Can you help me on this!!Bhavin:
You can call any stored procedures or functions which belong to any schema as long as you have thr proper privileges.
As long as you are granted as the following by SYS or DBA:
grant execute on ABS to SHAH;
You should be able to execute ABS regardless what's your client software (VB, JAVA, JSP, or SQLPLUS).
Jack
null -
Hi,
I am looking for inputs in tuning stored procedure using sql server 2008. l am new to performance tuning in sql,plsql and oracle. currently facing issue in stored procedure - need to increase the performance by code optmization/filtering the records using where clause in larger table., the requirement is Stored procedure generate Audit Report which is accessed by approx. 10 Admin Users typically 2-3 times a day by each Admin users.
It has got CTE ( common table expression ) which is referred 2 time within SP. This CTE is very big and fetches records from several tables without where clause. This causes several records to be fetched from DB and then needed processing. This stored procedure is running in pre prod server which has 6gb of memory and built on virtual server and the same proc ran good in prod server which has 64gb of ram with physical server (40sec). and the execution time in pre prod is 1min 9seconds which needs to be reduced upto 10secs or so will be the solution. and also the exec time differs from time to time. sometimes it is 50sec and sometimes 1min 9seconds..
Pl provide what is the best option/practise to use where clause to filter the records and tool to be used to tune the procedure like execution plan, sql profiler?? I am using toad for sqlserver 5.7. Here I see execution plan tab available while running the SP. but when i run it throws an error. Pl help and provide inputs.
Thanks,
VijiYou've asked a SQL Server question in an Oracle forum. I'm expecting that this will get locked momentarily when a moderator drops by.
Microsoft has its own forums for SQL Server, you'll have more luck over there. When you do go there, however, you'll almost certainly get more help if you can pare down the problem (or at least better explain what your code is doing). Very few people want to read hundreds of lines of code, guess what's it's supposed to do, guess what is slow, and then guess at how to improve things. Posting query plans, the results of profiling, cutting out any code that is unnecessary to the performance problem, etc. will get you much better answers.
Justin -
Can I pass an array as an input parameter for a stored procedure on SQL Server 2000
I am trying to pass an array to a stored procedure residing on my SQL Server 2000 database server. Is this even possible? If it is possible, what is the syntax for this?
Any help would be greatly appreciated.
ThanksI have passed arrays to and from a database using SQL and ActiveX, including to and from stored procedures, but I cannot recall the precise method used to do so. If memory serves, everything is in the form of a string. You need to do a lot of parsing and 'unparsing' to get this data into your stored procedure.
You are left with a couple of options to get your data to the stored procedure. I recommend using SQL in LabVIEW wherever possible as it saves the amount of external code calls (and believe me, calling ActiveX procedures developed by someone else in Visual Basic is NOT much fun at all...). You can either send the array and other data to the stored procedure (you will find the syntax in the SQL references in LabVIEW help under SQL), or you can send
the array to the database, and have the database then act upon the array.
I strongly recommend making routines (subVIs) to handle these operations.
Sorry I don't have the syntax, I don't have SQL installed on this machine. If you can't find the syntax in the help, please post here again.
-Mike Du'Lyea -
Stored Procedure Vs PL-SQL Block
Hi,
I came across an interesting problem last week. Fortunately, I was able to solve it or find an acceptable workaround for myself. But wanted to get some clarification from the experts. So posting it here.
Also, I am new to Orcle, so please excuse any shortcomings in the post.
My data model has following tables-
TABLE_PARENT (ID, other columns)
TABLE_CHILD (ID, other columns, PARENT_ID_FK)
Here, ID is the primary key column for the respective tables; PARENT_ID_FK is the foreign key referencing the ID column from the TABLE_PARENT.
I created a stored procedure programmatically (using MS Excel) to insert records in the two tables. The stored procedure has insert statements for an indefinite number of records in the parent table and for every such record, there's a corresponding record inserted in the child table. Here's the sample code.
BEGIN
/*first record*/
parent_id := MY_SEQUENCE_GENERATOR.NEXTVAL;
INSERT INTO TABLE_PARENT(ID, other columns) VALUES (parent_id, other values);
INSERT INTO TABLE_CHILD(ID, other values,parent_id );
/*second record*/
parent_id := MY_SEQUENCE_GENERATOR.NEXTVAL;
INSERT INTO TABLE_PARENT(ID, other columns) VALUES (parent_id, other values);
INSERT INTO TABLE_CHILD(ID, other values,parent_id );
/*third record*/
parent_id := MY_SEQUENCE_GENERATOR.NEXTVAL;
INSERT INTO TABLE_PARENT(ID, other columns) VALUES (parent_id, other values);
INSERT INTO TABLE_CHILD(ID, other values,parent_id );
/*and so on*/
END
When I run this stored procedure, I keep getting following exception intermittently-
ORA-02291: integrity constraint violated-parent key not found tips.
My thinking is that it comes because the insert statements are executing ahead of turn of the parent_id assignment statement. And this is happening possibly because of some parallelism that is taking place during the execution of the stored procedure, or, some sort of optmization that the DB server does (though erroneously) when it compiles the stored procedure.
I tried out everything that I could think of but it didn't go away. Finally, when I executed the same set of statements as a PL-SQL block, it worked fine.
To understand it better, I am looking for clarification on the following questions.
1) Why does the exception come with stored procedure but not with PL-SQL block? Is my reasoning given above correct (parallelism or some sort of optimization coming into play)?
2) If it is due to parallelism, how to run a Oracle stored procedure with defree of prallelism set to 1?
3) If it is due to optimization done by the compiler, how to instruct the compiler to not do any such optimization. Also, in any case, isn't it an error to optimize but lose program semantics?
4) Another question related to the same piece of work I have is to use transactions in the PL-SQL block, I had to explicitly COMMIT/ROLLBACK it in the code. In whatever references I had read, it was said that by default the transaction begins with BEGIN statement and commits with END. Also, it seems to work with a Stored Proedure though. So is it that a PL_SQL block needs explicity call to COMMIT/ROLLBACK to achive transactions but stored procedures do not?
Any inputs/clarifications will be much appreciated.
Thank you
NeeleshOk, your last couple of paragraphs were helpful. Here're the details that were missing in my earlier post.
- I am on Oracle 10.2.0.
- Table definitions-
CREATE TABLE "MYUSER"."TABLE_PARENT"
*( "ID" NUMBER(19,0) NOT NULL ENABLE,*
* "NAME" VARCHAR2(30),*
* "DESCRIPTION" VARCHAR2(80),*
* "RULETYPE" NUMBER(10,0) NOT NULL ENABLE,*
* "OPERATOR" NUMBER(10,0),*
* "MININTERCEPT" FLOAT(126),*
* "PRIORITY" NUMBER(10,0),*
* "PENALTY" NUMBER(10,0),*
* "STATUS" NUMBER(10,0),*
* PRIMARY KEY ("ID")*
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE,
*) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING*
STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
CREATE TABLE "MYUSER"."TABLE_CHILD"
*( "ID" NUMBER(19,0) NOT NULL ENABLE,*
* "WEIGHT" NUMBER(19,0),*
* "PARENTID_FK" NUMBER(19,0),*
* PRIMARY KEY ("ID")*
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE,
* CONSTRAINT "FK3A78BF1E6A9DCE51" FOREIGN KEY ("PARENTID_FK")*
* REFERENCES "MYUSER"."TABLE_PARENT" ("ID") ENABLE*
*) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING*
STORAGE(INITIAL 131072 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
- The Stored procedure definition is-
CREATE OR REPLACE PROCEDURE LOAD_RULES_SP AS
ruleid NUMBER(19,0);
tempid NUMBER(19,0);
BEGIN
*/* First parent record */*
SELECT IDGENERATOR.NEXTVAL INTO ruleid FROM dual;
INSERT INTO TABLE_PARENT (ID, NAME, DESCRIPTION, RULETYPE, OPERATOR, MININTERCEPT, PRIORITY, penalty, STATUS) VALUES (ruleid, 'Rule 1',null,3,0,0,null,null,1);
*/* Corresponding child records */*
SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
VALUES (tempid, 0.2, ruleid);
SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
VALUES (tempid, 0.5, ruleid);
SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
VALUES (tempid, 0.3, ruleid);
*/* First parent record */*
SELECT IDGENERATOR.NEXTVAL INTO ruleid FROM dual;
INSERT INTO TABLE_PARENT (ID, NAME, DESCRIPTION, RULETYPE, OPERATOR, MININTERCEPT, PRIORITY, penalty, STATUS) VALUES (ruleid, 'Rule 1',null,3,0,0,null,null,1);
*/* Corresponding child records */*
SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
VALUES (tempid, 0.2, ruleid);
SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
VALUES (tempid, 0.5, ruleid);
SELECT IDGENERATOR.NEXTVAL INTO tempid FROM dual;
INSERT INTO TABLE_CHILD (id, weight, PARENTID_FK)
VALUES (tempid, 0.3, ruleid);
*/* And so on for a few parent records more */*
END;
Can you throw some light on the exception I was seeing now? Note that when I changed from stored procedure to an anonymous block, it worked fine.
One correction in my earlier post is that as the code snippet shows, there are multiple inserts in the child table for every record inserted in the parent one. -
I have used a tool to convert my sql 2000 stored procedure to Oracle 10g PL/SQL, here is an example
SQL 2000 Stored Procedure
CREATE PROCEDURE [GetEmployees]
AS
Select * from EMPMST ORDER BY emp_name
GO
After Transformation i got 2 files, one was a procedure and other a package
CREATE OR REPLACE PACKAGE GLOBALPKG
AS
TYPE RCT1 IS REF CURSOR;
TRANCOUNT INTEGER := 0;
IDENTITY INTEGER;
END;
CREATE OR REPLACE PROCEDURE GetEmployees
RCT1 IN OUT GLOBALPKG.RCT1
AS
BEGIN
OPEN RCT1 FOR
SELECT *
FROM EMPMST
ORDER BY emp_name;
END;
When i execute the procedure GetEmployees i got this error :
SQL> execute GetEmployees;
BEGIN GetEmployees; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'GETEMPLOYEES'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Please Help me in debugging this error. Thanks in advance.As the poster above mentioned you cannot call "GetEmployees" without a parameter.
Note that the procedure declaration has the following line
RCT1 IN OUT GLOBALPKG.RCT1
This means that whenever you want to call the procedure you must pass it a variable of type GLOBALPKG.RCT1
However unless this is merely a homework or learning exercise (i.e. you are not porting the code of a production application) i would strongly recommend that you do not attempt to simply convert the code to PL/SQL.
The reasoning behind this is that Oracle's architecture will be completely different to the source of the original code and if you attempt to simply port the code (especially using an automatic tool) you will almost certainly hit problems.
For example the SQL Server's 2000 code may (should be) be written based on SQL Server's locking strategy. Oracle's locking strategy is completly different if you try to use the same techniques as you do in SQL Server the performance will suffer.
Porting a code or a database schema from one platform to another involves a lot of analysis in order to take advantage of the features of the destination platform.
As I said this may not be important to you depending on why you are attempting a port.
Good Luck. -
Creating a SQL Stored procedure to call a CF function
I need to create a method to migrate data from a DMZ inside a firewall. To do this I was thinking of making a call from the DMZ web server (using CF) to an internal SQL server database stored procedure. The stored procedure would then call a CF template on the internal web server to pull data inside the firewall. Not my first choice on implementation but as a consultant I don’t make the rules I create the code to enforce them... Anyway these are the steps I need to follow.
1.) Call the stored procedure and pass an int value with the call.
2.) The Stored procedure calls a URL and passes the INT with it. I.E. http://Mylocalhost/Xferdata/MyXferTemplate.cfm?MyIntValue=”PASSED IN INT VALUE”
3.) The MyXferTemplate does the actual data migration for me.
My question is how do I create a simple stored procedure to do this on SQL Server 2008??? After looking at the CF documentation I don’t think there will be much of a problem making the call to the stored procedure… its just writing the stored procedure… Any and all help is greatly appreciated!!!
Have an Ordinary Day...
Kurtis ~|:-)So far this is what I got... When I "execute' this code in SQ
L Server management studio it compiles without any errors but when I run it I get the message "http: is not recognized as an internal or extermnal command."
/********************************** Code to create the SP **************************/
USE
[KDLTransfer]
GO
/****** Object: StoredProcedure [dbo].[Migrate_DMZ_Data] Script Date: 03/07/2011 16:48:50 ******/
SET
ANSI_NULLS ONGO
SET
QUOTED_IDENTIFIER ONGO
-- =============================================
-- Author: KDL
-- Create date: 3/7/2011
-- Description: Migrate data
-- =============================================
ALTER
PROCEDURE [dbo].[Migrate_DMZ_Data]
-- Add the parameters for the stored procedure here
@MyIntValue
int = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
EXEC xp_cmdshell 'http://localhost/IREC/KDL/KDL.cfm?@MyIntValue, no_output';
END
/**************** Code to call the SP ******************/
execute Migrate_DMZ_Data @MyIntValue = N'5'
Maybe you are looking for
-
A/P & Consignment data pull to Planning Cube.....
I put this in "BC & Extractors" section, but did not get any response..... Need couple of clarifications (brief background is provided.....): 1. We do DELTA extractions using 0FI_AP_3 adn 0FI_AR_4 to a base cube which includes both 'Open' and 'Cleare
-
Trying to simply connect to Oracle with VBscript/ASP - and I cannot.
This is rather embarrassing. I am pretty fluent with ASP and VBscript, and I have written many a web application connecting to Microsoft SQL Server. Now I have a need to connect to an Oracle database, and I'm beating my head against the wall. 1) Web
-
Building mod_jk module on Solaris 10 (Intel Platform)
Hi, I am trying to build a mod_jk module on a Sun Blade 1500 (Solaris 10 Intel Platform). I downloaded the most recent tomcat connector I could find (jakarta-tomcat-connectors-current-src.tar.gz) and have attempted to build it, but I have received th
-
UCCX 9.0(2) XML question
I'm teaching myself about SOAP and XML responses for an upcoming project for a self-service application. We have UCCE/ICM UCCX/IPIVR premium licenses. I used the excellent article by Gergely (https://supportforums.cisco.com/document/97736/uccx-8x-rea
-
Hi DB Gurus, Our application is inserting 60-70K records in a table in each transaction. When multiple sessions are open on this table user face performance issues like application response is too slow. Regarding this table: 1.Size = 56424 Mbytes! 2.