Code Reviewing stored procedures
Hi team,
Is there any shortcut way to code review stored procedures in sql.
Note: Condn. need to check are below
Checking whether all temp tables dropped, if its not dropped then to identify that table
checking update and delete statement on physical table which should include PRIMARY KEY column in where condition
checking Every JOIN stmt shouldn't combine more than five physical tables
Checking any temp table created like select * into #table from some physical table
Checking any physical table creation during run time of Sp
Thanks in advance
Regards, Muthukumar Balu
Hi all,
Following function gives the create tmp table and drop temp table stmt in row wise.Hence we can count the create tmp tables and drop tables. Count will identify the missing drop tables ,Like this am asking shortcuts for code reviewing.
===========================================
Create FUNCTION [dbo].[uftReadfileAsTable]
@Path VARCHAR(255),
@Filename VARCHAR(100)
RETURNS
@File TABLE
[LineNo] int identity(1,1),
line varchar(8000))
AS
BEGIN
DECLARE @objFileSystem int
,@objTextStream int,
@objErrorObject int,
@strErrorMessage Varchar(1000),
@Command varchar(1000),
@hr int,
@String VARCHAR(8000),
@YesOrNo INT
select @strErrorMessage='opening the File System Object'
EXECUTE @hr = sp_OACreate 'Scripting.FileSystemObject' , @objFileSystem OUT
if @HR=0 Select @objErrorObject=@objFileSystem, @strErrorMessage='Opening file "'+@path+'\'+@filename+'"',@command=@path+'\'+@filename
if @HR=0 execute @hr = sp_OAMethod @objFileSystem , 'OpenTextFile'
, @objTextStream OUT, @command,1,false,0--for reading, FormatASCII
WHILE @hr=0
BEGIN
if @HR=0 Select @objErrorObject=@objTextStream,
@strErrorMessage='finding out if there is more to read in "'+@filename+'"'
if @HR=0 execute @hr = sp_OAGetProperty @objTextStream, 'AtEndOfStream', @YesOrNo OUTPUT
IF @YesOrNo<>0 break
if @HR=0 Select @objErrorObject=@objTextStream,
@strErrorMessage='reading from the output file "'+@filename+'"'
if @HR=0 execute @hr = sp_OAMethod @objTextStream, 'Readline', @String OUTPUT
INSERT INTO @file(line) SELECT @String
END
if @HR=0 Select @objErrorObject=@objTextStream,
@strErrorMessage='closing the output file "'+@filename+'"'
if @HR=0 execute @hr = sp_OAMethod @objTextStream, 'Close'
if @hr<>0
begin
Declare
@Source varchar(255),
@Description Varchar(255),
@Helpfile Varchar(255),
@HelpID int
EXECUTE sp_OAGetErrorInfo @objErrorObject,
@source output,@Description output,@Helpfile output,@HelpID output
Select @strErrorMessage='Error whilst '
+coalesce(@strErrorMessage,'doing something')
+', '+coalesce(@Description,'')
insert into @File(line) select @strErrorMessage
end
EXECUTE sp_OADestroy @objTextStream
-- Fill the table variable with the rows for your result set
RETURN
END
==================================================
steps to check:
1. Execute the function n ur DB
2. Store your sql file in some location.
3. Execute following query in ur DB and path should be replaced with where u have stored ur SQl file
--QUERY
Select line from
Dbo.uftReadfileAsTable('D:\SQL_CODE_REVIEW','filename.sql')
where line like '%create%table%#%'
Select line from
Dbo.uftReadfileAsTable('D:\SQL_CODE_REVIEW','filename.sql')
where line like '%drop%table%#%'
Regards, Muthukumar Balu
Similar Messages
-
How to encrypt the source code of stored procedures ?
Is it possible to encrypt the source code of the stored procedures so no one can read the content. I want to deliver a compiled code not the source
Database 8i and later
thanks in advanceWrap Utility<br>
<br>
Nicolas. -
C code in stored procedure ?
Is it possible to invoke a C function/ program in a stored procedure? How?
Read these lines. If you needs more: [email protected]
=======================================================================
Bookmark Fixed font Go to End
Doc ID: Note:99136.1 Content Type: TEXT/PLAIN
Subject: Calling Operating System Commands from PL/SQL using External Procedures Creation Date: 15-FEB-2000
Type: BULLETIN Last Revision Date: 27-NOV-2001
Status: PUBLISHED
Overview
The ability to call operating system commands from PL/SQL is a feature that
is easily implemented in Oracle8 using External Procedures. This article
contains a simple example of implementing this functionality.
Note: The example in this article was created on Solaris and tested with
Oracle 8.0.4 and 8.0.5.
Listener Configuration
The following represents a typical listener.ora configuration. Details
for your particular installation may vary.
LISTENER_PROC =
(ADDRESS_LIST =
(ADDRESS= (PROTOCOL= IPC)(KEY=external))
(ADDRESS= (PROTOCOL= TCP)(HOST=otcsol1)(PORT=23000))
SID_LIST_LISTENER_PROC =
(SID_LIST =
(SID_DESC =
(SID_NAME = L804)
(ORACLE_HOME = /u11/app/oracle/product/8.0.4)
(SID_DESC =
(SID_NAME = external)
(ORACLE_HOME = /u11/app/oracle/product/8.0.4)
(PROGRAM = /u11/app/oracle/product/8.0.4/bin/extproc)
(ENVS='PATH=/bin:/usr/bin:/usr/ccs/bin:/usr/ucb')
# The ENVS is used to define any environment variables that will
# be used by the external procedure.
STARTUP_WAIT_TIME_LISTENER_PROC = 0
CONNECT_TIMEOUT_LISTENER_PROC = 10
TRACE_LEVEL_LISTENER_PROC = OFF
TNSNAMES.ORA Configuration
The following represents a typical tnsnames.ora configuration. Details
for your particular installation may vary:
extproc_connection_data =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = external))
(CONNECT_DATA = (SID = external)(SERVER=DEDICATED))
L804=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(Host = otcsol1)(Port = 23000))
(CONNECT_DATA = (SID = L804))
External Procedure Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sh(char *);
void sh( char *cmd )
int num;
num = system(cmd);
Issue the following commands to compile the code and generate the shared
object in Solaris:
cc -G -c shell.c
ld -r -o shell.so shell.o
You can also use the demo_rdbms.mk makefile to build shared libraries
for use in external procedures. Using this method insulates you from
any Operating System specific dependencies (e.g., which flags to use
for ld).
For example:
In 8.0.X,
$ make -f demo_rdbms.mk extproc_nocallback \
SHARED_LIBNAME=shell.so OBJS=shell.o
In 8.1.X,
$ make -f demo_rdbms.mk extproc_no_context \
SHARED_LIBNAME=shell.so OBJS=shell.o
Library Definition
CREATE LIBRARY shell_lib is '/u11/home/lsupport/proc/shell.so';
Note: The directory in quotes is the current of location of the library that
was created in the steps above.
PL/SQL Wrapper Procedure
create or replace procedure shell(cmd IN char)
as external
name "sh"
library shell_lib
language C
parameters (cmd string);
Execution
SQL> exec shell('ls');
cli.trc exe_prba.sql prueba.mk shell.c.old
core listener.old prueba.o shell.o
dec2bin.c listener.ora prueba.so shell.so
dec2bin.c.old nena.lst prueba.sql shell.sql
dec2bin.o p.sql sal.1 shell.sql.old
dec2bin.so pepito.lst sal.2 sqlnet.log
dec2bin.sql prb sal.3 tnsnames.ora
dec2bin.sql.old prb.c salida.lst tnsnames.ora.old
envoltorio.sql prueba.c shell.c uno.sql
PL/SQL procedure successfully completed.
The output produced by the executed command is not viewable in general since
it is directed to the controlling terminal for the extproc process. The
extproc process inherits its controlling terminal from the listener, which in
turn inherits its terminal from the shell used to start the listener. If this
shell is no longer visible, the output is never displayed.
To see the output returned from the system command, redirect the output to a
file and then view/process the output file. This can be done simply on UNIX
platforms by appending "> myoutput.txt" to the command being executed.
Standard error can be redirected similarly.
The executed commands only see the directory pointed by the TNS_ADMIN
environment variable defined in the server, therefore, when specifying a file,
be sure to include the path of its desired location.
References
[NOTE:14082.1] Dynamic SQL and System Commands Using DBMS_PIPE
[NOTE:74159.1] External Procedures Using Pro*C
[NOTE:68061.1] Creating External Procedures on Windows NT
"PL/SQL User's Guide and Reference, Release 8.0"
"Oracle8i Application Developer's Guide - Fundamentals"
====================================================================
CREATE OR REPLACE procedure up_sim_exec_shell(p_comand IN VARCHAR2)
as external
name "sh"
library shell_lib
language C
parameters (p_comand string); -
Handling Return Codes from SQL Stored Procedures
Hi,
Please can you let me know how to take care of system return codes from Stored Procedure in JDBC program. Is there any way it can be handled using Callabale Statement.
Regards.not sure what you mean by "system" return codes, but to capture return values from stored procedures you can use CallableStatement.registerOutParameter(), just like with output parameters. see http://www.j-netdirect.com/GenStoredProcedures.htm#ReturnStatus.
-
Stored Procedure for custom permission check
Hi,
I have created 2 UDTs for Master Data and Master Rows, and generated a UDO form for this.
Only few users can add master data, but all users should be able to update fields in the rows for existing master records (but not the fields in the header).
For this, I can probably add a custom permission UDF in User Master.
But how can I code the Stored Procedure based on this UDF in the User Master, and whether rows are modified for existing records?
Thanks.John......
Try this.....
IF (@object_type = '140' And (Select ObjType From OPDF
Where DocEntry = @list_of_cols_val_tab_del)='46'
AND @transaction_type IN ('A'))
BEGIN
if exists(select t0.DocEntry from OPDF T0 inner join PDF4 T1 on
T0.DocNum = T1.DocNum where t1.ObjType ='46' AND (T0.Series = '15' AND T1.OcrCode != 'U-1')
and T0.DocEntry = @list_of_cols_val_tab_del)
begin
select @error = 1,
@error_message = 'Check Unit'
end
End
Above SP will only work when your Series Code is 15 and OcrCode is not equal to 'U-1'....
Please confirm........
And Object type for Payment Draft 140 is right.....
Regards,
Rahul -
How to use Stored Procedures in form 6i Blocks
Dear Friends,
I would like to know how to use Stored Procedures while creating blocks in Data Block Wizard in forms 6i application.
Please send me sample code of stored procedure.
Regards,
Khader.The Data Block Wizard is not for creating stored procedures. It will allow you to use a stored procedure in your form. See the help documentation for how to use the wizard.
Here's an example of a simple procedure. If you search the database forum or the web, you will find many examples.
CREATE OR REPLACE PROCEDURE procedure_name (value OUT NUMBER ) AS
BEGIN
SELECT COUNT(*) INTO value
FROM your_table;
END;
Message was edited by:
Mark Roberts -
How to pass parameter from 1 stored procedure to another stored procedure inside crystal report
Hi
I have several stored procedure in my Crystal Report. I am wondering if it is possible for me to pass a parameter to one of the stored procedure and to use the result of that stored procedure E.g. CustomerCode. To another 2 stored procedure to generate the report dynamically?
I have 3 stored procedure
The 1st one is used to gather information and process the calculation
another 2 stored procedure is used for generate the graph and both of them required to take 2 parameters. The 1st stored procedure will require 1 parameter (E.G. Reference Code) and will return a set of information including the data that could be use on the other 2 stored procedures.
After I added these 2 stored procedure, it requires me to pass 3 parameters to the report. I would like to know if I could only pass the Reference Code for stored procedure 1 and use it to retrieve the information for the other 2 parameter?
Thanks in advance
ChiHi Chi
To pass parameter from 1 stored procedure to another stored procedure, you will have to create sub report. In your case you will have to create 2 sub reports for 2nd and 3rd stored procedure and link those sub reports with the main report using Reference Code field in order to pass the values.
After creating the report when you will refresh the report, it will ask 4 parameters, one parameter for main report, one for the first subreport and two for second subreport to fetch the data correctly.
Regards
Poonam Thorat. -
Oracle stored procedure works in toad but lots of error in java
I've tested this stored procedure in toad 7.3 and it completes ok.
I do pass the same IN parameters and OUT parameters.
I registered the out parameter as a OracleTypes.CURSOR
if it works in toad or pl/sql, what is wrong? how can this be fixed.
however, when i execute this in java, this is the exception and garbage i receive:
java.sql.SQLException: ORA-06550: line 1, column 22:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
The symbol "(" was substituted for "" to continue.
ORA-06550: line 1, column 33:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( ) , * @ % & | = - + < / > at in mod not range rem => ..
<an exponent (**)> <> or != or ~= >= <= <> and or like
between is null is not || indicator is
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
my stored procedure is as follows:
CREATE OR REPLACE PROCEDURE getUserByLogin (
arg_subscriptionName IN varchar,
arg_loginName IN varchar,
arg_password IN varchar,
arg_rec_userinfo_valLanguage OUT types.rec_userinfo_valLanguage
) AS
var_userNum int;
BEGIN
select
u.userNum into var_userNum
from
userInfo u,
subscription s
where
s.subscriptionName = arg_subscriptionName AND
s.subscriptionNum = u.subscriptionNum AND
u.loginName = arg_loginName AND
u.password = arg_password;
if (var_userNum is null) then
var_userNum := 0;
end if;
getUser(var_userNum, arg_rec_userinfo_valLanguage);
END;
/I'm using a callable statement.
The strange thing is that, when i remove all IN and OUT paramters in the java code and the stored procedure, both the call to the stored procedure and teh execution of the stored procedure works.
The moment I add in just a IN parameter (in the stored procedure, and setting it in the java code) it stops working, and i receive this error.
java.sql.SQLException: ORA-06550: line 1, column 23:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
heres the java code and stored procedure
CREATE OR REPLACE PROCEDURE sampleProcedure(tax out number)
is
BEGIN
tax := 10 *.15;
/END;
CallableStatement statement =conn.prepareCall("{call sampleprocedure ?}");
statement.registerOutParameter(1,java.sql.Types.INTEGER);
statement.execute();
ResultSet rs = statement.getResultSet();
if((rs = statement.getResultSet()) != null){ -
Stored procedure with IN and OUT parameter
HI all,
here is code example
declare
in_dt date := '1-feb-2010' ;
col1 ...;
col2 ...;
col3 ...;
begin
select e.*
into col1,
col2,
col3
from table_xyz e
where e.start_dt = in_dt;
end;
How do i convert the above code into stored procedure by accepting "in_dt" as IN parameter and getting the result set displayed (output) through OUT parameter say "cur_out" (OUT paramter)
Thank you so much !!! I really appriciate it !!i ran my procedure which is very similar syndra posted
create or replace procedure foo(p_dt in date, cv out sys_refcursor) as
begin
open cv for
select e.*
from table_xyz e
where start_dt = p_dt;
end;
/Here is how is executed
DECLARE
P_DT DATE;
CV SYS_REFCURSOR;
BEGIN
P_DT := '10-oct-2005';
-- CV := NULL; Modify the code to initialize this parameter
scott.foo ( P_DT, CV );
COMMIT;
END;
-- i get PL/SQL procedure successfully complted , But i dont see the result set Or output
- How do i see the output when i m using refcursor ?? i tried using print , but nothing didnt work
- Any idea ??
Thank you!!
Edited by: user642297 on Jun 24, 2010 1:35 PM -
Translate Stored Procedure from MS SQL Server to ORACLE 9i
Hi...
I work usually with MS SQL Server, and now I need to migrate an application from MS SQL Server to ORACLE 9i. I think to preserve most of User Interface made actually in MS Visual Basic .NET 2003 and change or "translate" all the MS SQL Server stored procedures to ORACLE 9i(most of business logic was code in Stored Procedures). So I need an advise of how to do that, if there are a tool for migration (tables, PK, FK, Rules, Defaults...etc) and, if possible, a procedure or tips for translate the stored procedures.
Thanks in advance....
Eusebio MHere's some links:
Oracle Migration Workbench:
http://www.oracle.com/technology/tech/migration/workbench/index.html
Forums for Migration:
http://forums.oracle.com/forums/forum.jspa?forumID=183
Database and Application Migrations
Good luck!
Christian -
Passing parameter to stored procedure from windows form getting error
I've written a procedure which shows the data in a table according to the table flag selected from the windows form. My code is:
--- stored procedure ------
CREATE PROC [dbo].[PROC_SELECT_TABLES]
@TBL_FLAG INT
AS
BEGIN
SET NOCOUNT ON;
IF (@TBL_FLAG = 1)
SELECT * FROM MHT_APPUSER ;
IF (@TBL_FLAG = 2)
SELECT * FROM MHT_ISA11 ;
IF (@TBL_FLAG = 3)
SELECT * FROM MHT_ISA22 ;
SET NOCOUNT OFF;
END
GO
Now, the module for calling the above procedure
namespace DAL;
public class DisplayData
SqlLayer layer = new SqlLayer();
public int tblFlag { get; set; }
public DataTable GetData(int tblFlag)
SqlParameter[] p = new SqlParameter[1];
p[0] = new SqlParameter("@tblFlag", this.tblFlag);
return layer.ExecuteDataSet("PROC_SELECT_TABLES", p).Tables[0];
Now the SQL LAYER, containing the ExecuteDataSet and database connection code:
namespace DAL;
public class SqlLayer
// sql connection code
public DataSet ExecuteDataSet(string commandText, SqlParameter[] sqlParameter)
SqlCommand cmd = new SqlCommand(commandText, this.conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(sqlParameter);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
return ds;
Now the windows form layer:
using DAL;
namespace BookKeepingSystem
public partial class DisplayDataForm : Form
DisplayData view = new DisplayData();
private void GetData()
view.tblFlag = 3;
DataTable dt = view.GetData(view.tblFlag);
dgvDisplayData.DataSource = dt;
public DisplayDataForm()
InitializeComponent();
private void DisplayData_Load(object sender, EventArgs e)
GetData();
private void btnExit_Click(object sender, EventArgs e)
Application.Exit();
When I run the code I got the error:
"Unhandled exception has occurred in your application...
Procedure or function 'PROC_SELECT_TABLES' expects parameter @TBL_FLAG, which was not supplied"
I can not figure what is missing with my code. Please can any one point out please.
Thank You!!!Try something like this for starting -- do just this procedure to see if it works first.
private DataTable GetDataTable(SqlConnection conn1)
SqlDataAdapter daS1 = new SqlDataAdapter();
daS1.SelectCommand = new SqlCommand();
daS1.SelectCommand.Connection = conn1;
if (conn1.State == ConnectionState.Closed) conn1.Open();
daS1.SelectCommand.CommandType = CommandType.StoredProcedure;
daS1.SelectCommand.CommandText = "yourStoredProcedureName";
daS1.SelectCommand.Parameters.Add("@ParamName", SqlDbType.Int, 4);
DataSet DS1 = new DataSet();
daS1.Fill(DS1, "tbl1");
return DS1.Tables["tbl1"];
Note: in the CommandText part place the name of your stored procedure. In the Parameter part put the name of your parameter exactly as it is in the actual stored procedure. Also, (if you have not done this already) make sure your stored
procedure runs OK -- first -- test out your stored procedure in Sql Server Management Studio. If the procedure runs OK in SSMS, then try it from you app. Just create a simple form with one button . Place GetDataTable() code under
the button and call it something like this:
private void button1_Click(object sender, EventArgs e)
int i = GetDataTbl().Rows.Count;
Console.WriteLine("i is {0}", i);
Rich P -
Stored Procedure error in Java
My Java application is invoking stored procedure(Oracle 10g). The stored procedure is opening a cursor for a SQL query that is created dynamically in side the procedure. Whenever there is an error while opening the cursor (i.e. executing the SQL query), I get the following exception message in Java application logs irrespective of what error has caused during SQL execution.
SQLException for SQL [{call PRC_TEST(?, ?, ?, ?, ?, ?, ?, ?)}]; SQL state [60000]; error code [604]; ORA-00604: error occurred at recursive SQL level 1
ORA-01003: no statement parsed
; nested exception is java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01003: no statement parsed
e.g. If the query is like select * from tableA and I dont have proper privlieges. I should get error message while opening the cursor :- insufficient privileges.
Is there any way where we can get more precise(or exact!) error message (in Java application logs) that stopped SQL execution while opening the cursor?I'm using a callable statement.
The strange thing is that, when i remove all IN and OUT paramters in the java code and the stored procedure, both the call to the stored procedure and teh execution of the stored procedure works.
The moment I add in just a IN parameter (in the stored procedure, and setting it in the java code) it stops working, and i receive this error.
java.sql.SQLException: ORA-06550: line 1, column 23:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
heres the java code and stored procedure
CREATE OR REPLACE PROCEDURE sampleProcedure(tax out number)
is
BEGIN
tax := 10 *.15;
/END;
CallableStatement statement =conn.prepareCall("{call sampleprocedure ?}");
statement.registerOutParameter(1,java.sql.Types.INTEGER);
statement.execute();
ResultSet rs = statement.getResultSet();
if((rs = statement.getResultSet()) != null){ -
Can we have an example of using update, insert, and delete stored procedure
I would like to see an example of using retrieve (return resultset), update, insert, and delete stored procedures in JSF. I need to see syntax how JSF can call those stored procedures. This option is absolutely important when building web-application. Currently, I haven't found resource to do for this purpose yet. The database can be any such Oracle, DB2, pointbase, etc that support stored procedures.
Anyone knows?
Thanks,
Tue VuHi ttv,
I asked around a bit and here's some more info:
To bind a ResultSet to a read only Data Table component just set the "value" property of the Data Table component to point at it, and JSF will synthesize a DataModel around it.
* Note that because we can't call the stored procedure at design time, Creator can't do the fancy table layout stuff it does for rowsets. You'll need to hand craft the columns just like the Google Client example.
* As I mentioned previously, you will have to manually code the stored procedure access in your java code - see the code clip I mentioned in previous reply (and if this is via a stored procedure, then any textbook about JDBC will undoubtedly have examples). Simplest way might be a getter method on the page bean that contains the call to the stored procedure and returns the resulting ResultSet object.
* Don't forget to close the result set - we typically do this at the end of the request (i.e. add a close in the afterRenderResponse() method.
* Don't throw exceptions - or if you have to, make sure you close the result set in a finally clause (thrown exceptions bypass the afterRenderResponse method in the lifecycle).
* You give up on the caching provided by our RowSetDataModel (which can't be connected to a ResultSet even manually), so I would recommend that you only use datatables to display the data and then go to a single row page to do edits/deletes (similar to the TwoPage example in AppModel and the Update, Insert Delete tutorial).
And yes please do submit an example - we will gladly post it!!! :) The best way to submit this kind of thing would be through:
http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
on the right side, Related Links, under Creator Heros, click Submit Content and there you can send it in!
Hope this helps!
Val -
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 -
Why recompiling a stored procedure would change returned data?
We have a web ASP.net application and Oracle database. Everything was working fine for at least last 5 years and now we can't figure out why
our stored procedures no longer work.
Here is what huppening
On our Oracle database if we do SELECT * FROM web_usertable we see every user who can ‘access’ the our system via website.
user1 is me
583 user1 null John q us 0 02 605
670 user2 null Ed Black us 0 02 693
Information about me and user2 is in the Oracle.
The only difference is that I have been in the database for years and user2 is for about one month.
When I go to the website and ‘enter’ ... Website is calling USP_GETUSERPROFILE that returns all my data. Everything works fine
When user2 performs exactly the same task no data from Oracle is being returned. (Why NOT??? Data is in the Oracle Table)
Order of things doesn’t make any difference: I can go 1st and everything would work ... then user2 and his data isn’t working OR he can go 1st and nothing being returned and I go 2nd and everything will work for me.
Here is what we found and it is only one of many ways we can reproduce this problem:
I go 1st and everything would work (We know that code and Stored Procedure is working) user2 goes 2nd and no data is returned (Something is wrong)(Why NOT??? Data is in the Oracle Table)
Without closing any windows or restarting any application or IIS or any other actions … if at this point we simply drop and recreate USP_GETUSERPROFILE all user2 data immediately comes back.
This issue is not only occurring with user2 data. It appears that any recently added user has this problem.
It also isn’t limited to the USP_GETUSERPROFILE procedure we found other instances when recompiling a Stored Procedure solved a problem.
We don't even know where to look. We also suspect that it might have someting to do with .NET because some other stored procedures in our applications being executed by C++ code don't have this problem.
Edited by: user11296530 on Aug 21, 2009 10:56 AMterrn wrote:
that would do it, I guess
now the newbie question: within the function block: how do I assign the results va1 and va2 from a select query into the attributes of the object? I couldn't find an example where that's demonstrated (if possible).
simplified I should have:
create or replace function my_function(a number, b varchar2) return my_type
as
my_obj my_type;
begin
-- here:
select val1, val2 from table1 -- this is always only one row
-- my_obj := my_type(a,b); -- how do I assign those here?
return my_obj;
end
select my_type(val1,val2) into my_obj
from table1;Edited by: Toon Koppelaars on Feb 24, 2011 10:16 AM
Maybe you are looking for
-
MacBook Pro freezing issue.
My MacBook Pro was acting fine, then, out of nowhere, it froze. I figured nothing was wrong, so I restarted the computer (which took longer than normal), then proceeded to log in. Once logged in, the desktop had trouble loading, then the screen froze
-
After update to 10.0.1, Firefox is now slow to check add-ons and sends me to "Hooray! Your Firefox is up to date.", every time. This happens with my PC and Netbook. Please advise.
-
What does the registration process expect as my screen name?
What does the registration process expect as my screen name? i used BILL-PC WKYBURZ [ email address removed by admin ] nothing works my conclusion : it is a bug
-
When using onclipevent via on(rollover), how do I still paused a movie?
Hey all, I have a movie that is running free on the timeline and when I rollover it I am attaching a movie to the cursor. My problem is that when I do this, I then cant seem to pause the running time line. eg: on (rollOver){ framevar = _currentframe;
-
How do you separate favorites for Phone App and Facetime App?
I was wondering if there was a way to separate the phone favorites from the Facetime favorites. I find it kind of annoying that I can't just add a Facetime favorite without it appearing in my phone favorites.