顯示具有 oracle 標籤的文章。 顯示所有文章
顯示具有 oracle 標籤的文章。 顯示所有文章

2012年4月26日 星期四

How can we print the error code in exception handling section

EXCEPTION
WHEN No_privilages THEN
htp.p( '

Access denied

'); WHEN Rec_expired THEN htp.p('Other user has changed this record,Query the record and Update'); WHEN OTHERS THEN Htp.p(SQLERRM);

2011年12月22日 星期四

Xlib: connection to ":0.0" refused by server

Xlib: connection to ":0.0" refused by server

用root鍵入命令:xhost+
然後su - oracle繼續安裝


/tmp/CVU_11.2.0.1.0_oracle
./runfixup.sh


Response file being used is :./fixup.response
Enable file being used is :./fixup.enable
Log file location: ./orarun.log
Setting Kernel Parameters...
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)

2011年9月8日 星期四

How can we print the error code in exception handling section

EXCEPTION
WHEN No_privilages THEN
htp.p( '

Access denied

'); WHEN Rec_expired THEN htp.p('Other user has changed this record,Query the record and Update'); WHEN OTHERS THEN Htp.p(SQLERRM);

2011年7月6日 星期三

Get return value from stored procedure

Recently we changed our DAC layer from using inline SQL to stored procedures in the database. On some of these SQL, we did record deletion (usually only 1 record), and we just execute it via IDBCommand.ExecuteNonQuery() and then check the return value to see how many records were affected (which should be 1) for verification that the query actually does something.
With the change to stored procedure, we just return 1 in the stored procedure if the delete is successful. However, the calling code then started to show these deletions as errors. Apparently ExecuteNonQuery only returns the number of affected rows on SELECT, INSERT and DELETE statements; for everything else it returns -1.  So I tried to figure out how to get a return value from a stored procedure.
Let's assume a simplistic stored procedure as follows:


You can't use ExecuteScalar to get the returned value, and ExecuteNonQuery will always return -1.  To get the value back, you need to add a return value parameter to the command.  The name of the parameter is not important.  The code to get the value returned by that procedure will be as follows:

ALTER PROC ReturnOnly
AS
BEGIN
      RETURN 5
END



ALTER PROC ReturnOnly
AS
BEGIN
      RETURN 5
END

private int ExecuteStoredProcedure(string storedProcedureName)
{
   SqlConnection connection = new SqlConnection(connectionString);
   // Command - specify as StoredProcedure
   SqlCommand command = new SqlCommand(storedProcedureName, connection);
   command.CommandType = CommandType.StoredProcedure;
   // Return value as parameter
   SqlParameter returnValue = new SqlParameter("returnVal", SqlDbType.Int);
   returnValue.Direction = ParameterDirection.ReturnValue;
   command.Parameters.Add(returnValue);
    // Execute the stored procedure
   connection.Open();
   command.ExecuteNonQuery();
   connection.Close();
   return Convert.ToInt32(returnValue.Value);
}