How to call PL/SQL stored procedure with TWO or more arguments from URL?
Hi all,
does anybody know, how to call stored procedure with more than one argument?
How to do this with one argument is known -
<img src="#OWNER#.retreive_img_data?i_id=#IMG_ID#" width="70" height="80" alt="No Picture">
But if I need to call procedure with two formal parameters? And need to pass through URL, for example, two page item values?
Just separate with an "&". Using your previous example, I'll add i_name and i_type:
<img src="#OWNER#.retreive_img_data?i_id=#IMG_ID#&i_name=somename&i_type=jpg" width="70" height="80" alt="No Picture" />
Tyler
Similar Messages
-
How to call pl/sql stored procedure in JDBC query dialogbox
Hi,
how to call pl/sql stored procedure in JDBC query dialogbox(reports 9i) .
Cheers,
Raghuplease refer : Re: problem If you have more doubts, please ask in that question.
-
How to call PL-SQL/stored procedure in Creator
Anybody can tell how to call PL-SQL/Stored procedures inside creator...
Hi!!!
You can see this topic http://forum.sun.com/jive/thread.jspa?threadID=106046
There is how to call oracle stored procedures. Also I put a lot of links in these topic doing reference stored procedures. I have one that it tells specially how to call oracle stored procedures from java, is in spanish but you can understand the code.;-)
http://yoprogramador.vampisol.com/index.php?title=pl_sql_oracle_desde_java&more=1&c=1&tb=1&pb=1
Byeee -
How to call PL/SQL stored procedure using ODBC?
Could anyone tell me how can I call PL/SQL stored procedure using
ODBC? Are there any sample codes?
Thanx!
nullYou are correct on all counts, they all should work.
Oracle Product Development Team wrote:
: Hi,
: I don't know the exact syntax in ODBC, but reasoning by analogy
: with other API's, I'd bet one of the following works
: (for a call to: procedure my_proc(n1 number, n2 number);):
: "{ my_proc(1,2); }"
: "{ call my_proc(1,2); }"
: "{ begin my_proc(1,2); end }"
: "begin my_proc(1,2); end;"
: "begin my_proc(1,2); end"
: Hope this helps. - Pierre
: jiangbuf (guest) wrote:
: : Could anyone tell me how can I call PL/SQL stored procedure
: using
: : ODBC? Are there any sample codes?
: : Thanx!
: Oracle Technology Network
: http://technet.oracle.com
null -
How to call a sql stored procedure in java...... HELP
Hi I am making an application for taking backup in sql automatically so i have created a dts package which is called by a stored procedure. Now the problem is that how to call that stored procedure in a Java program so that after running my java program i get my database backup.
Please please solve my problem.
thanks in advance.
If possible please send the code.
Message was edited by:
Andy_Davis
Message was edited by:
Andy_DavisHi... I am trying to create a dts package which is called by a stored procedure... How can i do this? IF possible can you please send me the code as well..
Thanks a ton...
Susan_Davis -
How to call pl sql stored procedure or function in OAF 10 plus versions
Hello All,
I am using J-dev 10.1.3.3.0.3 version.I want to call stored procedure from package in one of my controller. I tried using "txn.createCallableStatement" but it is saying that createcallablemethod is not available.Does any one knows about this.
ThanksTry the OA Framework Forum.
John -
Calling PL/SQL stored procedure from JSP tag
Hello,
I need to call a PL/SQL procedure from a JSP tag , I donot want to use any Bean to call the PL/SQL procedure. How would I call PL/SQL stored procedure from within JSP using JSP tag library, need some code.
Thank you
Syedneed to call a PL/SQL procedure from a JSP tag , I donot want to use any Bean to call the PL/SQL procedure. How would I call PL/SQL stored procedure from within JSP using JSP tag library, need some code.
regards
Indira Rani Bandi -
How Do I Call PL/SQL Stored Procedure That Returns String Array??
I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
(As Good As String Array Type..)
In This Fourm, I Can't Find Out Example Source.
(Question is Exist.. But No Answer..)
I Want An Example,, Because I'm A Beginner...
(I Wonder...)
If It Is Impossible, Please Told Me.. "Impossible"
Then, I'll Give Up to Resolve This Way.....
Please Help Me !!!
Thanks in advance,// Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
import java.sql.*;
class RunStoredProc
public static void main(String args[])
throws SQLException
try
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(Exception ex)
ex.printStackTrace();
java.util.Properties props = new java.util.Properties();
props.put("user", "********"); // you need to replace stars with db userid
props.put("password", "********"); // you need to replace stars with userid db password
// below replace machine.domain.com and DBNAME, and port address if different than 1521
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
// replace "Your Stored Procedure" with your stored procedure
CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
ResultSet rset = stmt.execute();
while(rset.next())
System.out.println(rset.getString(1)); -
Urgent: unable to call a plsql stored procedure with a struts data action
Hello ALL,
I'm trying to call a plsql stored procedure within a struts DataAction,
The scenario is:
When a user a click on a button, then it should call a specific stored procedure,,
I create struts data action a class to handle the event which is to call the procedure
Here is my code:
public class RequestAction extends DataForwardAction
public void onCall(DataActionContext ctx)
String amDef = "model.AppModule";
String config = "AppModuleLocal";
ApplicationModule am =
Configuration.createRootApplicationModule(amDef, config);
try{
AppModuleImpl myAm = (AppModuleImpl)am;
DBTransaction tr = (DBTransaction) myAm.getTransaction();
CallableStatement stmt = tr.createCallableStatement
("begin pkg_test.test; end;", DBTransaction.DEFAULT);
stmt.execute();
stmt.close();
tr.commit();
catch(Exception e){System.out.println(e.getMessage());}
Configuration.releaseRootApplicationModule(am,true);
but when I ran the application and click on the button, I got the following Exception:
04/07/08 00:45:50 ORA-06550: line 1, column 7:
PLS-00201: identifier 'PKG_TEST.TEST' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
It seems that the DBTransaction object unable to see the stored procedure,
Am I do something wrong or miss something???
I've checked the examples on the OTN HOW TO, and searched in the JDeveloper Forum but unable to find an answer,
Please anyone can help???
Thanks a lot
With Regards,
HayatHere's an example application that illustrates how to do this. I haven't had a chance to writeup a little paper to go with it yet, but will as soon as I have a chance.
http://otn.oracle.com/products/jdev/tips/muench/storedproc/CallStoredProc.zip
See the "callStoredProcedure" method in the application module in the Model project.
See the "callStoredProcedure" method binding in the binding container of the "CallStoredProcedure" data page.
Notice the name "event_callStoredProcedure" of the (Call Stored Procedure) button on the CallStoredProcedure.jsp page which triggers the declaratively invocation of the method.
You could also call the method from code in a custom data action.
The code example illustrates how to create your own JDBC prepared statement for invoking the stored procedure, and doing it in a way that is efficient by keeping the prepared statement around across invocations. -
Error calling PL/SQL stored procedure
Hi,
I'm pretty new to JDeveloper having used NetBeans for the last few years.
I'm getting an error when trying to call a PL/SQL stored procedure. When I click on any of the oracle errors I get an "unable to find source file" message. The errors occurs in call.execute(). The error message and Java code are listed below. Any help is much appreciated.
Cheers,
Stevie
Errors:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 33
at java.lang.String.charAt(String.java:558)
at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:877)
at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:811)
at oracle.jdbc.driver.OracleSql.getSql(OracleSql.java:284)
at oracle.jdbc.driver.OracleSql.getSqlBytes(OracleSql.java:538)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:169)
at oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:873)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1161)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3093)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4286)
at oracle.CallPLSQL.callLMO(CallPLSQL.java:118)
at oracle.TestHarness.main(TestHarness.java:18)
Jave Code:
package oracle;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
public class CallPLSQL {
private Connection conn;
public CallPLSQL() {
*Constructor.
try {
//Register Oracle Database Drive
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//set connection
String connectionString="jdbc:oracle:thin:TSD/TSD@DEV:1526:DEVELOP";
this.setConn(DriverManager.getConnection(connectionString,"TSD", "TSD"));
} catch (SQLException ex) {
public int callproc () throws SQLException {
CallableStatement call;
String callString = "{call proc" +
call = conn.prepareCall(callString);
call.setInt(1, 120289);
call.setInt(2, 2008);
call.registerOutParameter(3, Types.INTEGER);
call.registerOutParameter(4, Types.INTEGER);
call.registerOutParameter(5, Types.INTEGER);
call.registerOutParameter(6, Types.DATE);
call.registerOutParameter(7, Types.VARCHAR);
call.registerOutParameter(8, Types.INTEGER);
call.registerOutParameter(9, Types.INTEGER);
call.execute();
int i = call.getInt("app_id");
return i;
public void setConn(Connection conn) {
this.conn = conn;
public Connection getConn() {
return conn;
}I've fixed it now. I'd missed a } in prepareCall. What a doughball.
-
Calling ORACLE/SQL stored procedure...
Hello,
Is it possible to invoke non-parametrized Stored Procedures (a procedure that, neither having IN parameter nor OUT parameter) from BizTalk.?
Any suggestion/solution?
Thanks,
Prajakt.
Praj DixitPraj,
Yes possible.
Create a .NET helper which will call the stored procedure and handle the return value/recordset from sp and in your BizTalk artifacts call this .NET helper/wrapper to SQL stored procedure.
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
How to retrive a STANDARD stored procedure with java?
I have searched and searched, I have not found a direct, CLEAR, answer to this.
how do you call a standard, (not java) stored procedure from oracle database that requires input variables?
I have looked, searched and read and cannot find one simple example code, or message that explains this in clear concise info.
can some one please send me a email on this:
[email protected]
Don't bother leaving a message here, once I save this message and come back a day later its gone and can't be found by me..Hi... I am trying to create a dts package which is called by a stored procedure... How can i do this? IF possible can you please send me the code as well..
Thanks a ton...
Susan_Davis -
I am new to XS but i managed to enable a table through xsodata:
service namespace "sap.hana.democontent.epm" {
"AA465342"."TMP_HENK" as "TMP_HENK";
But now i am looking for code that can call a stored procedure that has 2 input- and 3 output parameters.... who can help me out with this?Hi Vivek, thanks for the quick response!
I already found that blog, but it does not completely answer my question. i am struggling to get my content procedure working. call the R (catalog) stored procedure:
the code
/********* Begin Procedure Script ************/
BEGIN
call "AA465342"."MO_PP_SENTIMENT"(SP_IN,SP_OUT) with overview;
END;
/********* End Procedure Script ************/
where it goes wrong:
: Only table variable is allowed in input parameter in a nested call
I have defined SP_IN and SP_OUT....
Can someone give me a clue what i have to change? -
Pointbase : How can I create a stored procedure with Pointbase database?
Hello,
Excuse me for my english, I'm not anglophone. I try to create a stored procedure.
This is my file SampleExternalMethods.java :
import java.sql.*; //import com.pointbase.jdbc.jdbcInOutDoubleWrapper; public class SampleExternalMethods { // A connection object to allow database callback static Connection conn = null; static Statement l_stmt; static Statement m_stmt; static CallableStatement m_callStmt = null; static ResultSet l_rs = null; public static void main(String[] args) { try { String url = "jdbc:pointbase:server://localhost/pointbaseDB"; String username = "PBPUBLIC"; String password = "PBPUBLIC"; conn = DriverManager.getConnection(url, username, password); doCreateProcedure(); doInvokeProcedure(); } catch (SQLException e) { e.printStackTrace(); } finally { if (m_stmt != null) { try { m_stmt.close(); } catch (Exception e) { e.printStackTrace(); } } if (m_callStmt != null) { try { m_callStmt.close(); } catch (Exception e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (Exception e) { e.printStackTrace(); } } } } public static void getCountry(String Iso_Code) { try { // Query the database for the country iso code l_stmt = conn.createStatement(); l_rs = l_stmt.executeQuery( "SELECT * FROM countries" + " WHERE country_iso_code ='" + Iso_Code + "'"); //Affichage du résultat de la requête l_rs.next(); System.out.print(l_rs.getString(1) + " - "); System.out.print(l_rs.getString(2) + " - "); System.out.println(l_rs.getString(3)); // Close the result set l_rs.close(); } catch (SQLException e) { e.printStackTrace(); } finally { if (l_rs != null) { try { l_rs.close(); } catch (Exception e) { e.printStackTrace(); } } if (l_stmt != null) { try { l_stmt.close(); } catch (Exception e) { e.printStackTrace(); } } } } public static void doCreateProcedure() throws SQLException { // SQL statement to create a stored procedure String SQL_CREATE_PROC = "CREATE PROCEDURE getCountry(IN P1 VARCHAR(30))" + " LANGUAGE JAVA" + " SPECIFIC getCountry" + " NO SQL" + " EXTERNAL NAME \"SampleExternalMethods::getCountry\"" + " PARAMETER STYLE SQL"; // Create a SQL statement m_stmt = conn.createStatement(); // Execute the SQL m_stmt.executeUpdate(SQL_CREATE_PROC); // Close the statement //m_stmt.close(); } public static void doInvokeProcedure() throws SQLException { // Create SQL to invoke stored procedures String SQL_USE_PROC = "{ call getCountry(?) }"; // Create a callable statement with three binding parameters m_callStmt = conn.prepareCall(SQL_USE_PROC); m_callStmt.setString(1, "CA"); m_callStmt.executeQuery(); // Close the callable statement //m_callStmt.close(); } }
Afterwards, I have read this note in a Pointbase document:
To invoke the dateConvert external Java method from a stored function, you must use the
CREATE FUNCTION statement. The dateConvert external Java method is called from the
class, SampleExternalMethods.
In order for the database to access this external Java method, the class SampleExternalMethods
must be included in the database CLASSPATH. For PointBase Embedded - Server Option, it
must be in the Server CLASSPATH, but not in the Client CLASSPATH.
If PointBase Server is run with the Java Security Manager, in the java policy file grant
’com.pointbase.sp.spPermission’ to the class that implements the external Java method.
An "spPermission" consists of a class name with no action. The class name is a name of a class
that could be used in creating a Stored Procedure in PointBase. The naming convention follows
the hierarchical property naming convention and that is supported by
"java.security.BasicPermission". An asterisk may appear by itself, or if immediately preceded
by ".", may appear at the end of the name, to signify a wildcard match. The name cannot
contain any white spaces.
I'm not sure, but I suppose that I must include the class SampleExternalMethods in a .jar file.
The database CLASSPATH could be : C:\Sun\AppServer\pointbase\lib\
These my files in this database CLASSPATH:
pbclient.jar
pbembedded.jar
pbtools.jar
pbupgrade.jar
I have tryed to include the class SampleExternalMethods in pbclient.jar and pbembedded.jar with this command:
jar -uf pbembedded.jar SampleExternalMethods
Afterwards I do that,
1) Start Pointbase
2) Configuration of classpath
set classpath=C:\Sun\AppServer\pointbase\lib\pbclient.jar
set classpath=%classpath%;D:\J2EE\Ch07Code\Ch07_06
I precise that my file SampleExternalMethods is into D:\J2EE\Ch07Code\Ch07_06\Ch07.
Then, I run the program:
D:\J2EE\Ch07Code\Ch07_06>java -Djdbc.drivers=com.pointbase.jdbc.jdbcUniversalDriver Ch07.SampleExternalMethods
But I have an error message:
Exception in thread "main" java.lang.NoClassDefFoundError: Ch07.SampleExternalMethods (wrong name: SampleExternalMethods)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.DefineClass(ClassLoader.java:539)
The problem, I suppose, comes from that the class SampleExternalMethods
must be included in the database CLASSPATH, but there is a pbserver.jar with pointbase normally, but I didn't find it. That's why I use pbembedded.jar or pbclient.jar in order to include the class SampleExternalMethods. May be I must start from C:\Sun\AppServer\pointbase\lib\ instead of D:\J2EE\Ch07Code\Ch07_06\Ch07?
Please, can somebody helps me?
Thank you in advance.
cagou!jschell wrote:
And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
>And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
>
And I doubt you can recurse like that for embedded java. You must have a class that does the functionality and another class that creates the proc.
Thank you for your response, I have done two classes:
SampleExternalMethods.java:
package Ch07;
import java.sql.*;*
*public class SampleExternalMethods*
*public static void getCountry(String Iso_Code)*
*// A connection object to allow database callback*
*Connection l_conn = null;*
*Statement l_stmt = null;*
*ResultSet l_rs = null;*
*try*
*String url = "jdbc:pointbase:server://localhost/pointbaseDB";*
*String username = "PBPUBLIC";*
*String password = "PBPUBLIC";*
*l_conn = DriverManager.getConnection(url, username, password);*
*// Query the database for the country iso code*
*l_stmt = l_conn.createStatement();*
*l_rs = l_stmt.executeQuery( "SELECT* FROM PBPUBLIC.COUNTRIES"
+" WHERE country_iso_code ='"+ Iso_Code +"'");+
+//Affichage du résultat de la requête+
+l_rs.next();+
+System.out.print(l_rs.getString(1)+ " - ");
System.out.print(l_rs.getString(2) +" - ");+
+System.out.println(l_rs.getString(3));+
+// Close the result set+
+l_rs.close();+
+} catch (SQLException e) {+
+e.printStackTrace();+
+} finally {+
+if (l_rs != null) {+
+try {+
+l_rs.close();+
+} catch (Exception e) {+
+e.printStackTrace();+
+}+
+}+
+if (l_stmt != null) {+
+try {+
+l_stmt.close();+
+} catch (Exception e) {+
+e.printStackTrace();+
+}+
+}+
+if (l_conn != null) {+
+try {+
+l_conn.close();+
+} catch (Exception e) {+
+e.printStackTrace();+
+}+
+}+
+}+
+}+
+}+
CreateMethods.java:
+package Ch07;+
+import java.sql.*;+
+public class CreateMethods+
+{+
+// A connection object to allow database callback+
+static Connection m_conn = null;+
+static Statement m_stmt;+
+static CallableStatement m_callStmt = null;+
+public static void main(String[] args)+
+{+
+try+
+{+
+String url = "jdbc:pointbase:server://localhost/pointbaseDB";+
+String username = "PBPUBLIC";+
+String password = "PBPUBLIC";+
+m_conn = DriverManager.getConnection(url, username, password);+
+doCreateProcedure();+
+doInvokeProcedure();+
+} catch (SQLException e) {+
+e.printStackTrace();+
+} finally {+
+if (m_stmt != null) {+
+try {+
+m_stmt.close();+
+} catch (Exception e) {+
+e.printStackTrace();+
+}+
+}+
+if (m_callStmt != null) {+
+try {+
+m_callStmt.close();+
+} catch (Exception e) {+
+e.printStackTrace();+
+}+
+}+
+if (m_conn != null) {+
+try {+
+m_conn.close();+
+} catch (Exception e) {+
+e.printStackTrace();+
+}+
+}+
+}+
+}+
+public static void doCreateProcedure() throws SQLException {+
+// SQL statement to create a stored procedure+
+String SQL_CREATE_PROC = "CREATE PROCEDURE PBPUBLIC.getCountry(IN P1 VARCHAR(30))"+
" LANGUAGE JAVA"
+" SPECIFIC getCountry"+
" NO SQL"
+" EXTERNAL NAME \"SampleExternalMethods::getCountry\""+
" PARAMETER STYLE SQL";
// Create a SQL statement
m_stmt = m_conn.createStatement();
// Execute the SQL
m_stmt.executeUpdate(SQL_CREATE_PROC);
// Close the statement
//m_stmt.close();
public static void doInvokeProcedure() throws SQLException {
// Create SQL to invoke stored procedures
String SQL_USE_PROC = "{ call getCountry(?) }";
// Create a callable statement with three binding parameters
m_callStmt = m_conn.prepareCall(SQL_USE_PROC);
m_callStmt.setString(2, "CA");
m_callStmt.executeQuery();
// Close the callable statement
//m_callStmt.close();
}But I have the same error message that previously.
I have read this note and I suppose that the problem is linked:
If PointBase Server is run with the Java Security Manager, in the java policy file grant
*com.pointbase.sp.spPermission to the class that implements the external Java method.*
An "spPermission" consists of a class name with no action. The class name is a name of a class
that could be used in creating a Stored Procedure in PointBase. The naming convention follows
the hierarchical property naming convention and that is supported by
*"java.security.BasicPermission". An asterisk may appear by itself, or if immediately preceded*
by ".", may appear at the end of the name, to signify a wildcard match. The name cannot
contain any white spaces.
Can you explain me what I must to do in order to solve this problem of spPermission.
Thanks. -
How to call a Oracle Stored Procedure from Excel?
Hi,
I am new to Oracle database programming.I have an application in excel which has to update info in every row to the database.I am calling a stored procedure in excel for this.The stored procedure is as follows which is executing without a hitch in Oracle:
CREATE OR REPLACE PROCEDURE APD_MASS_UPLOAD_UNITS
(PRODUCT_ID VARCHAR2,Product_Code VARCHAR2, str_Adpt_Grp VARCHAR2,str_Adpt_Type VARCHAR2,
str_PDC VARCHAR2,str_Release_ID VARCHAR2,str_Created_by VARCHAR2,
str_Last_Updated_By VARCHAR2, dt_created_Date VARCHAR2,dt_Last_Updated_Date VARCHAR2,
StrMonth1 VARCHAR2,strMth2 VARCHAR2,StrMth3 VARCHAR2,StrMth4 VARCHAR2,
StrMth5 VARCHAR2,StrMth6 VARCHAR2,Sample Varchar2,str_message OUT Varchar2)
AS
type Month_type is table of VARCHAR2(10) index by binary_integer;
str_month Month_Type;
Fac_ID VARCHAR2(20);
Org_ID VARCHAR2(20);
Cnt_Units NUMBER;
i_POS NUMBER;
i_Month NUMBER;
i_UNITS NUMBER;
CURSOR C1 IS
SELECT * FROM TBLLINE_ADOPT_PLAN WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_Adpt_Grp AND ADOPT_TYPE = str_Adpt_Type
AND RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
CURSOR C3 IS
SELECT ORG_ID FROM APD_DV_PRODUCT_V WHERE SPEC_ID = Product_ID;
CURSOR C4 IS
SELECT * FROM TBLPROD_CSC WHERE PROD_SPEC_ID = Product_ID;
Adopt_Rec C1%ROWTYPE;
Fac_Rec C2%ROWTYPE;
PMORG_REC C3%ROWTYPE;
CSC_Rec C4%ROWTYPE;
i_Count NUMBER;
Message VARCHAR2(20);
BEGIN
Message := APD_SPECID_VALIDATE(Product_ID,Product_code,Str_PDC, str_Release_ID);
IF TRIM(Message) is null then
OPEN C1;
FETCH C1 INTO Adopt_Rec;
IF C1%NOTFOUND THEN
INSERT INTO TBLLINE_ADOPT_PLAN (SPEC_ID,ADOPT_GROUP, ADOPT_TYPE,RELEASE_ID, SAMPLES,CREATED_BY,CREATED_DATE, LAST_UPDATED_BY,LAST_UPDATED_DATE,SAMPLE_ONLY_IND, GRID_TYPE_CD) VALUES
(Product_ID,str_Adpt_Grp ,str_Adpt_Type,
APD_Get_Release_ID(str_PDC,str_Release_Id), 0,str_Created_By,
TO_DATE(dt_Created_Date,'DD/MM/YYYY'),str_Last_Updated_By,
TO_DATE(dt_Last_Updated_Date,'DD/MM/YYYY'),'N','C');
END IF;
CLOSE C1;
str_Month(1) := strMonth1;
str_Month(2) := strMth2;
str_Month(3) := strMth3;
str_Month(4) := strMth4;
str_Month(5) := strMth5;
str_Month(6) := strMth6;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
OPEN C3;
FETCH C3 INTO PMORG_Rec;
Org_ID := PMORG_Rec.Org_ID;
CLOSE C3;
OPEN C4;
FETCH C4 INTO CSC_Rec;
IF C4%NOTFOUND THEN
INSERT INTO TBLPROD_CSC(PROD_SPEC_ID,CSC_FACILITY_ID, PROFIT_CENTER_CD,DEFAULT_IND, CREATED_BY, CREATED_DATE, LAST_UPDATED_BY, LAST_UPDATED_DATE) VALUES
(Product_ID , Fac_ID,Org_id, 'N', str_Created_by ,
To_date ( dt_Created_Date,'DD/MM/YYYY') ,str_Last_updated_by ,
To_Date (dt_Last_Updated_Date ,'DD/MM/YYYY'));
END IF;
CLOSE C4;
IF Sample > 0 Then
UPDATE TBLLINE_ADOPT_PLAN
SET SAMPLES = Sample
WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_adpt_grp AND
ADOPT_TYPE = str_Adpt_Type AND
RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
END IF;
str_Message := 'Updated';
END IF;
END;
The code to call the stored procedure in Excel is as follows:
Dim Conn As New ADODB.Connection
Dim InputParam1 As New ADODB.Parameter
Dim InputParam2 As New ADODB.Parameter
Dim InputParam3 As New ADODB.Parameter
Dim InputParam4 As New ADODB.Parameter
Dim InputParam5 As New ADODB.Parameter
Dim InputParam6 As New ADODB.Parameter
Dim InputParam7 As New ADODB.Parameter
Dim InputParam8 As New ADODB.Parameter
Dim InputParam9 As New ADODB.Parameter
Dim InputParam10 As New ADODB.Parameter
Dim InputParam11 As New ADODB.Parameter
Dim InputParam12 As New ADODB.Parameter
Dim InputParam13 As New ADODB.Parameter
Dim InputParam14 As New ADODB.Parameter
Dim InputParam15 As New ADODB.Parameter
Dim InputParam16 As New ADODB.Parameter
Dim InputParam17 As New ADODB.Parameter
Dim InputParam18 As New ADODB.Parameter
Dim OutputParam As New ADODB.Parameter
Dim Mth1, Mth2, Mth3, Mth4, Mth5, Mth6 As String
Dim Rs_data As New ADODB.Recordset
Conn.ConnectionString = ("Provider=MSDAORA.1;User ID=" & "cnbg" & ";PASSWORD=" & "cnbg" & ";Data Source=" & "DAQ01" & ";Persist Security Info=False")
Conn.Open
OraCmd.ActiveConnection = Conn
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
OraCmd.CommandType = adCmdStoredProc
Conn.CursorLocation = adUseClient
OraCmd.Parameters.Refresh
Set InputParam1 = OraCmd.CreateParameter("Product_ID", adVarChar, adParamInput, 20)
InputParam1.Value = spec_id
Set InputParam2 = OraCmd.CreateParameter("Product_code", adVarChar, adParamInput, 20)
InputParam2.Value = str_product_code
Set InputParam3 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam3.Value = Adopt_Group
Set InputParam4 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam4.Value = Adopt_Type
Set InputParam5 = OraCmd.CreateParameter("str_pdc", adVarChar, adParamInput, 10)
InputParam5.Value = ThisWorkbook.strDbPDC
Set InputParam6 = OraCmd.CreateParameter("str_Release_ID", adVarChar, adParamInput, 10)
InputParam6.Value = str_Release_Id
Set InputParam7 = OraCmd.CreateParameter("str_created_by", adVarChar, adParamInput, 10)
InputParam7.Value = ThisWorkbook.User_Name
Set InputParam8 = OraCmd.CreateParameter("str_last_updated_by", adVarChar, adParamInput, 10)
InputParam8.Value = ThisWorkbook.User_Name
Set InputParam9 = OraCmd.CreateParameter("dt_created_date", adVarChar, adParamInput, 10)
InputParam9.Value = Sheet1.Cells(8, 2)
Set InputParam10 = OraCmd.CreateParameter("dt_Last_Updated_Date", adVarChar, adParamInput, 10)
InputParam10.Value = Sheet1.Cells(8, 2)
Set InputParam11 = OraCmd.CreateParameter("strMonth1", adVarChar, adParamInput, 10)
InputParam11.Value = Mth1
Set InputParam12 = OraCmd.CreateParameter("strMth2", adVarChar, adParamInput, 10)
InputParam12.Value = Mth2
Set InputParam13 = OraCmd.CreateParameter("strMth3", adVarChar, adParamInput, 10)
InputParam13.Value = Mth3
Set InputParam14 = OraCmd.CreateParameter("strMth4", adVarChar, adParamInput, 10)
InputParam14.Value = Mth4
Set InputParam15 = OraCmd.CreateParameter("strMth5", adVarChar, adParamInput, 10)
InputParam15.Value = Mth5
Set InputParam16 = OraCmd.CreateParameter("strMth6", adVarChar, adParamInput, 10)
InputParam16.Value = Mth6
Set InputParam17 = OraCmd.CreateParameter("Sample", adInteger, adParamInput, 10)
InputParam17.Value = 0
Set InputParam18 = OraCmd.CreateParameter("str_message", adVarChar, adParamOutput, 10)
OraCmd.Parameters.Append InputParam1
OraCmd.Parameters.Append InputParam2
OraCmd.Parameters.Append InputParam3
OraCmd.Parameters.Append InputParam4
OraCmd.Parameters.Append InputParam5
OraCmd.Parameters.Append InputParam6
OraCmd.Parameters.Append InputParam7
OraCmd.Parameters.Append InputParam8
OraCmd.Parameters.Append InputParam9
OraCmd.Parameters.Append InputParam10
OraCmd.Parameters.Append InputParam11
OraCmd.Parameters.Append InputParam12
OraCmd.Parameters.Append InputParam13
OraCmd.Parameters.Append InputParam14
OraCmd.Parameters.Append InputParam15
OraCmd.Parameters.Append InputParam16
OraCmd.Parameters.Append InputParam17
OraCmd.Parameters.Append InputParam18
Set Rs_data = New ADODB.Recordset
Set Rs_data = OraCmd.Execute
I am getting an error at this point which
ORA-06550:line 1,column 54:
PLS-00103:Encountered the symbol ">" when expecting one of the following:
. ( ) * @ % & = - + < / > at in is mod not rem
<an exponent(**)> <> or != or ~= or >= <= <> and or like
between ||
Can anyone pls help me?Thanks.You do not need to code an explicit cursor for a single fetch. An implicit cursor is less code to write, read, maintain and execute.
E.g. Instead of all this:
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
Simply code this:SELECT
Fac_Rec.FACILITY_ID INTO Fac_ID
FROM BLADOPT_GROUP_CSC
WHERE ADOPT_GROUP = str_Adpt_Grp;PL/SQL procedure calls have to be made (to Oracle) as anonymous PL/SQL blocks. This means that you need to wrap the procedure call into BEGIN..END tags.
So instead of coding this:
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
You need to code something like:
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS; END;"
However, this will not work as APD_MASS_UPLOAD_UNITS expects a bunch of input parameters. And you're on the right track about attempting to bind your Excel variables' values to the PL/SQL procedure's parameters.
Unsure how ADO works, but typically you can bind by name or by position. Let's assume bind by position (typically in PHP):
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( ?, ?, ?, ?, ?. ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); END;"
Then you will bind values to positions 1 to 18 (did I count the number of params right?). Something like:
OraCmd.CreateParameterByPosition( 1, adVarChar, adParamInput, 20)
Or you can bind by name. E.g.
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( :pid, :pcode, ..etc.. ); END;"
And:
OraCmd.CreateParameterByName( 'pid', adVarChar, adParamInput, 20)
Read up on your OraCmd.CreateParameter() to see how to correctly use it.
A few more comments. 18 parameters in a call is something I would seriously reconsider. It is quite easy to get it wrong - transpose two parameters. It is very difficult to read and check. Very difficult to maintain. It is much safer to rather define a %ROWTYPE structure to pass, or a PL/SQL record structure.
You are passing date values as VARCHAR2. Rather pass the parameter as the correct data type. E.g.
create or replace procedure foo( custID number, invoiceDate date )...
And then when you call it (in your client code), you specify the date string and date format and make it into a date. E.g.
OraCmd.CommandText = "begin foo( :myCust, TO_DATE(:myDateString,:myDateFormat) ); end;"
Maybe you are looking for
-
Final Cut Pro with OS 10.5.8?
I just downloaded the Final Cut Pro Final (trial) but it says I cannot use "this version of the application.. with this version of Mac OS X". I am using version 10.5.8. Is there a different FCP application that I can download or a Mac OS software upd
-
Two phones on same account, one roaming the other isn't?
My husband and I both have the Samsung Galaxy S3. His phone has been roaming for days now, and my phone hasn't been. How can this be? We have a share everything plan that is nationwide. Will we be charged for roaming?
-
Dynnamic Field Symbol returning short dump ASSIGN_TYPE_CONFLICT
Hi everyone, I have a RFC FM and make a dynamic access via SYMBOL FIELD, declared as ANY TABLE. The problem is that sometimes I can get a structure instead of a table and then the error occurs. How do I handle this error if the check IS ASSIGN not wo
-
Hello All, SQL Server is on Windows and our oracle is on Unix. Now i want to use Hetrogenous Service of oracle to pull data which requires me to connect to system dsn. Now i create a system dsn in windows. How should the HS_FDS_CONNECT_INFO value set
-
Start workflow on Document check In
Workflows initiate the moment I add a document even though it has not been checked in yet. I only want to start the workflow once the document has been checked in. How can I do that?