Print Thread
Spesial Copy of Procedures and functions.
#42365 09/30/11 08:04 AM
Joined: Dec 2005
Posts: 3
Norway
P
Petrus Offline OP
Member
OP Offline
Member
P
Joined: Dec 2005
Posts: 3
Norway

In the SQL window there is a spesical copy function where the sql state can be turned into a C#, VB variable. This is a nice function that I use a lot.

It would be great if this also was available on the procedure and function level to generate code that can be pasted into the client.


Re: Spesial Copy of Procedures and functions.
Petrus #42370 09/30/11 09:40 AM
Joined: Aug 1999
Posts: 22,203
Member
Offline
Member
Joined: Aug 1999
Posts: 22,203
Can you provide an example?


Marco Kalter
Allround Automations
Re: Spesial Copy of Procedures and functions.
Marco Kalter #42372 09/30/11 11:42 AM
Joined: Dec 2005
Posts: 3
Norway
P
Petrus Offline OP
Member
OP Offline
Member
P
Joined: Dec 2005
Posts: 3
Norway
Oracle function:
FUNCTION Is_Numeric(Parameter_ IN VARCHAR2) RETURN NUMBER IS

char_ VARCHAR2(1);
char_counter_ INTEGER;
is_numeric_ NUMBER;

BEGIN

is_numeric_ := 1;
char_counter_ := 0;
WHILE (char_counter_ <= LENGTH(Parameter_)) LOOP
char_counter_ := char_counter_ + 1;
char_ := SUBSTR(Parameter_,
char_counter_,
1);
IF (INSTR('0123456789',
char_,
1) = 0) THEN
is_numeric_ := 0;
EXIT;
END IF;
END LOOP;

RETURN(is_numeric_);
END Is_Numeric;

VB.NET code to run this function:

Imports System.Data.OracleClient
Imports System

Module ModuleTest

Const _oracleuser As String = "oracle user>"
Const _connectstring As String = "Oracle connect string"
Public Class TEST_API

' FUNCTION Is_Numeric(Parameter_ IN VARCHAR2) RETURN NUMBER IS
Public Function IsNumeric(ByVal Parameter_ As String) As Decimal
Dim _return_value As Decimal
Dim _commandtext As String = _oracleuser + ".TEST_API.Is_Numeric"
Using connection As New OracleConnection(_connectstring)
Dim Cmd As New OracleCommand(_commandtext, connection)
Try
Cmd.CommandType = CommandType.StoredProcedure
Cmd.Parameters.Add("Parameter_", OracleType.VarChar).Direction = ParameterDirection.Input
Cmd.Parameters.Add("Return_Value_", OracleType.Number).Direction = ParameterDirection.ReturnValue
Cmd.Parameters("Parameter_").Value = Parameter_
connection.Open()
Cmd.ExecuteNonQuery()
_return_value = Cmd.Parameters("Return_Value_").Value
Catch ex As Exception
MessageBox.Show("Oracle error message: " + ex.Message)
Return (-1)
Finally
connection.Close()
End Try
End Using
Return (_return_value)

End Function
End Class

End Module

Last edited by Petrus; 09/30/11 01:11 PM.

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.027s Queries: 15 (0.010s) Memory: 2.5065 MB (Peak: 3.0393 MB) Data Comp: Off Server Time: 2024-04-25 04:06:06 UTC
Valid HTML 5 and Valid CSS