Problem with parameter of stored procedure....
HI,
I've this stored procedure:
CREATE OR REPLACE procedure ST_DAT (NAME_IN VARCHAR2) as
BEGIN
insert into REP_NAME
select COD_ID,DESCR_ID,AREA, NAME_IN, sysdate
from REP_TAB;
COMMIT;
END ST_DAT;
this procedure is called from an external program
It run correctly, but I have any problem when I tried to insert into tab REP_NAME one value of NAME_IN
with apostrophe.
for example if I write (from external program) Mary run correctly, but If I write Mary's Bar I get
this error:
ORA-01756: quoted string not properly terminated.
I tried with REPLACE:
insert into REP_NAME
select COD_ID,DESCR_ID,AREA, REPLACE(NAME_IN,'',''''), sysdate
from REP_TAB;
BUT I GET SAME ERROR:
How can I call this procedure with apostrophe?
Thanks in advance!
You need to handle this in the calling program by escaping the apostophe with another apostrophe...
exec st_dat('Mary''s Bar')Of course that's easy to do when I'm typing in a literal. It's a bit trickier to automate :)
Cheers, APC
Similar Messages
-
Problem with Parameter on stored procedure for in() condition
Hello,
I would like to pass a parameter to a stored procedure like :
procedure sps_country(zones varchar2)
is
begin
select * from country where zone in (zones);
end sps_country;
My problem is : when i have one value in "zones" parameter all is OK but when i have 2, 3 ... values in zones with this format : ##, ##, ## there is no error, but there is no results found.
have you a solution please ?
ThanksAlso this document has some suggestions.
-
Problem while using oracle stored procedure in VC
Hi All,
I have created JDBC system and connected my locally installed Oracle data base to the VC. I mapped the data base user to my VC user. I tested connection and it is fine. Further I see the DB alias in Visual Composer and I can drop stored procedures to my story board. I can define parameters, but when I am executing procedures I get the error message.
Problem: I can not execute stored procedures stored in Oracle data base. Error Message: Portal request failed. Could not execute stored procedure.
In the stored procedure, I have used select query, that returns set of records, so that I have used REF CURSOR as OUT Parameter. Is REF CURSOR supported by VC?. Else, any tricks available to solve this problem?.
Note: Stored Procedure of Sql server is working fine in VC.
Thanks,
Venkatesh RReturning (or sending in) multiple rows directly from (or to) a stored procedure is not currently possible. I have been in contact with SAP on this subject earlier, and they suggest using a web service to do the job. I used this as a work around, calling the stored procedure from a web service. I send in VC tables to this web service, and this in turn contacts my stored procedure.
The problem is related to the connector framework in the J2EE environment.
I am on 7.0 sps 17
If you use stored procedure single value parameters of type varchar, number ... then VC has no problem communicating with your procedures.
Good luck
Henning Strand -
Pass a date parameter to Stored Procedure
Hello friends,
Can you help to pass a date parameter to Stored procedure from JSP. This is my code:
In Oracle 9i I have this:
PROCEDURE SP_EDORES(
pfechaini IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field
pfechafin IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field
p_recordset OUT PKG_REP_CIERRE.cursor_type) AS
In JSP have this:
CallableStatement stmt = (CallableStatement)conn.prepareCall( "begin PKG_REP_CIERRE.SP_EDORES(?,?,?); end;" );
stmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
stmt.setDate(1,Date.valueOf("01-06-2005"));
stmt.setDate(2,Date.valueOf("30-06-2005"));
ResultSet rset = (ResultSet)stmt.getObject(3);
while (rset.next()) {
%>
<TR>
<TD ALIGN=CENTER> <%= rset.getString(1) %> </TD>
<TD ALIGN=CENTER> <%= rset.getString(2) %> </TD>
<TD ALIGN=CENTER> <%= rset.getString(3) %> </TD>
<TD ALIGN=CENTER> <%= rset.getInt(4) %> </TD>
</TR>
<%
The Stored Procedure returns de Result set, however I think does not recognized the date format because I need it with this format dd-mm-yyyy.
Thanks in advanceto use Date you will need the oracle package.
u can try this other solution: use String, not Date
CallableStatement stmt = (CallableStatement)conn.prepareCall( "begin PKG_REP_CIERRE.SP_EDORES(?,?,?); end;" );
stmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
stmt.setString(1,"01-06-2005");
stmt.setString(2,"30-06-2005");
ResultSet rset = (ResultSet)stmt.getObject(3);
while (rset.next()) {
%>
if this don't work you can change your PL/SQL to get Strings and do the conversion with TO_DATE in the sql statement. -
Passing parameter into stored procedure
Hi guys,
I have a big problem here passing as a parameter in stored
procedure.
If i pass as a parameter in where clause it is working fine.
Whenever i pass the parameter in order by it was not working..
How to implement this issue????
Here i am giving the example for package:
PACKAGE XTRA.TEST_STATUS
AS
TYPE GenericCurTyp IS REF CURSOR;
PROCEDURE SP_MAIN
( insortgroup IN VARCHAR2,GENERAL_CUR IN OUT GenericCurTyp);
END TEST_STATUS;
PACKAGE BODY XTRA.TEST_STATUS
AS
PROCEDURE SP_MAIN
( insortgroup IN VARCHAR2, GENERAL_CUR IN OUT GenericCurTyp
) AS
BEGIN
OPEN GENERAL_CUR FOR
select last_name,first_name from applicant Order By insortgroup;
END SP_MAIN;
END TEST_STATUS;
Passing as a parameter i am getting the below details.
LAST_NAME FIRST_NAME
ASFSDAF DASDFASF
Ad DASD
Adams John
DANA WITEST
If i hot code the parameter insortgroup to last_name
i am getting the below values:
LAST_NAME FIRST_NAME
'ANNUNZIO GIANCOLA GABRIEL
0'BRIEN ARMA
0120453EZ ESTANISLAO
082479 ELIZABETH
Thanks,
RaoCREATE OR REPLACE PACKAGE xtra.test_status
AS
TYPE GenericCurTyp IS REF CURSOR;
PROCEDURE sp_main
(insortgroup IN VARCHAR2,
general_cur IN OUT GenericCurTyp);
END test_status;
CREATE OR REPLACE PACKAGE BODY xtra.test_status
AS
PROCEDURE sp_main
(insortgroup IN VARCHAR2,
general_cur IN OUT GenericCurTyp)
AS
select_statement VARCHAR2 (4000) := NULL;
BEGIN
select_statement :=
'SELECT last_name,
first_name
FROM applicant
ORDER BY ' || insortgroup;
DBMS_OUTPUT.PUT_LINE (select_statement);
OPEN general_cur FOR select_statement;
END sp_main;
END test_status; -
Is it possible to pass TABLE as the output parameter in stored procedure
Hey Experts,
Is it possible to pass TABLE as the output parameter in stored procedure.
eg
create procedure spGetData
@tableName as TABLE(intValue INT NOT NUL)
asYou can use OPENQUERY or OPENROWSET, as mentioned above, to make stored procedure results table like. There are
some limitations with these methods:
http://technet.microsoft.com/en-us/library/ms188427.aspx
In OPENQUERY this-sql-server-instance can be used instead of a linked server name. It requires setting data accces server option:
exec sp_serveroption @server = 'PRODSVR\SQL2012'
,@optname = 'DATA ACCESS'
,@optvalue = 'TRUE'
LINK: http://www.sqlusa.com/bestpractices/select-into/
Kalman Toth Database & OLAP Architect
SELECT Video Tutorials 4 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Problems with Parameter Mapping
Hi All,
I have problems with parameter-mapping. For me its a black box, sometimes it works sometimes not.
Lots of times my mappings doesnt work, and I dont know the reason.
For example: I want to map my Execution-CO to the Display-CO. For that I map the in the affected Action.
But it doesnt work, although I do have the same Context Structures, because its the same CO. The technical Name is also the same.
What could it be?
Thanks for answering me
Bye SteveHi Andre,
sorry for my late answer, but I'm writing my diploma thesis and wasnt at work since wednesday and so I dont have a access to our GP-System.
Hope I understood you right.
The Use Case of parameter mapping is that Users of further steps has the possibility to see the Input of previous steps.
When I dont map the parameter inside one action, it isnt possible. I tried it out with the SAP example "Time-off-process". I took the CO "Create Request" and add it in one Action (as Display & Execution). When I understand you right mapping inside an action is not necessary, to see the Inputs from further Actions --> But this way I cannot see the Inputs.
The mapping of my application works before I changed it.
I know never touch a running system, but It was necessary, we need a new Input and Output Parameter.
Cause I have 20 parameter the mapping was very time-consuming, to map every single parameter. I read a method to reduce the time: Adding a structure requires only mapping of the two structures. But now the Mapping doesnt work.
Hope you can help me
Bye Steve -
Problems with parameter button in Crystal Report Server 2008
Dear all,
I have problems with parameter button in Crystal Report Server 2008.
when I created some parameters and groups in Crystal Report 2008, they showed both parameters in 'Parameter button' and group in 'Group button' on the left, so I can choose or type without clicking 'Refresh button' But when I added it to Crystal Report Server 2008 and I click parameter button , it doesn't show any parameter. Only click refresh button to choose them. On the other hand, for 'Group Tree' is ok. When go to Default Setting-> Parameter, all parameters are in 'Unused parameter' First time I think I had problems with my installation, but when I reinstalled it again, it was like before.
Could any one help me with this?
I appreciate looking forward to your reply
KetyaTry posting your questionin the correct forum, this is for SAP Business One, not Crystal reports Server
-
Return a parameter through stored procedures
Hello Experts
I want to return parameter through stored procedures so as to ensure that the application has been executed properly.
My source message format is
<StatementName5>
<storedProcedureName action=u201D EXECUTEu201D>
<table>Summarize_prc</table>
<empid [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</empid>
</storedProcedureName >
</StatementName5>
Do i need to put some extra parameters for return values from the stored procedures?
What would be the response message format to return the parameters from stored procedure.
Thanks
SabyasachiHi,
If you wants to read the return values from stored procedure, the scanario should be designed as Sync.
The format looks like thsi
<Message Type Name>
<STATEMENTNAME_response>
<Field1> </Field1>
</STATEMENTNAME_response>
</Message Type Name> -
Help with running a stored procedure
Hi, could anybody help me with debugging this stored procedure:
extraction_date in varchar2
as
begin
execute immediate '
declare
/* Output file handler */
fileHandler UTL_FILE.FILE_TYPE;
asset_id VARCHAR2(60) := '''';
cursor c_table is
SELECT "ASSET ID"
FROM REUT_MAIN_BOND
WHERE MATURITY > TO_DATE(' || extraction_date || ', "MM-DD-YYYY");
row c_table%ROWTYPE;
begin
fileHandler := UTL_FILE.FOPEN(''TEMP'', ''northfielddescupdate.in'', ''w'',32000);
for row in c_table
loop
asset_id := row.ASSET;
UTL_FILE.PUTF(fileHandler, ''asset_id'', ''\n'');
end loop;
UTL_FILE.FCLOSE(fileHandler);
end;';
commit;
end;
when I run it - SQL> exec create_in_file('08102004')
it gives me the following errors:
ERROR at line 1:
ORA-06550: line 8, column 11:
PL/SQL: ORA-06553: PLS-103: Encountered the symbol "CALL" when expecting one of
the following:
<an identifier> <a double-quoted delimited-identifier>
ORA-06553: PLS-112: end-of-line in quoted identifier
ORA-06550: line 7, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 6, column 8:
PLS-00341: declaration of cursor 'C_TABLE' is incomplete or malformed
ORA-06550: line 10, column 5:
PL/SQL: Item ignored
ORA-06550: line 15, column 14:
PLS-00364: loop index variable 'ROW' use is invalid
ORA-06550: line 15, column 2:
PL/SQL: Statement ignored
ORA-06512: at "PETAR_NORTHFIELD.CREATE_IN_FILE", line 6
ORA-06512: at line 1
Thank you for your helpQ #1 (and possibly the only question) - why are you using NDS for this?
-
REF CURSOR as IN parameter to stored procedure
Currently, ODP.NET supports REF CURSOR parameter as OUT parameter only.
Based on the project requirements it is necessary to pass
multiple records to the stored procedure.
In this case REF CURSOR as IN parameter is useful.
What are the plans to implement REF CURSOR as IN parameter to stored procedure?
What is the work around in case it is necessary to pass several different
record types as arrays to stored procedure?ODP.NET does not limit REF Cursor parameters to IN parameters. This is a known PL/SQL limitation.
An excerpt from Application Developer's Guide:
"If you pass a host cursor variable to PL/SQL, you cannot fetch from it on the server side unless you also open it there on the same server call". -
Trouble with calling a stored procedure with VARCHAR parameter from trigger
Hi everybody,
today I ran across a problem with stored procedures and triggers that try to call them. Background info: I want to log changes in certain tables to another table in a trigger, so I can replicate the changes to another (non-Oracle) database in an asynchronous way. As an example I have the first data table "bak_s3_berufliste" and the table to store the changes in is "bak_s3_change_request".
DROP TABLE BAK_S3_BERUFLISTE;
CREATE TABLE bak_s3_berufliste (
id_bl NUMBER(27,0) NOT NULL,
berufsbez VARCHAR2(255),
CONSTRAINT PK_BAK_S3_BERUFLISTE PRIMARY KEY (id_bl) ENABLE);
DROP TABLE bak_s3_change_request;
CREATE TABLE bak_s3_change_request (
ID_CR NUMBER(27,0) NOT NULL,
TABELLE_NAME VARCHAR2(50) NOT NULL,
TABELLE_ID_ALT NUMBER(27,0),
TABELLE_ID_NEU NUMBER(27,0),
CONSTRAINT PK_BAK_S3_CHANGE_REQUEST PRIMARY KEY (ID_CR) ENABLE);
DROP SEQUENCE seq_bak_s3_change_request;
CREATE SEQUENCE seq_bak_s3_change_request;
For testing purposes I created the following stored procedure and trigger:
CREATE OR REPLACE PROCEDURE schreibe_cr (t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
BEGIN
INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
END;
CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
FOR EACH ROW
call schreibe_cr(:old.id_bl,:new.id_bl)
*... and everything worked perfectly - except from the fact that I need to know which table had changed of course. So I added another parameter to the stored procedure:*
CREATE OR REPLACE PROCEDURE schreibe_cr (t_name IN VARCHAR2, t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
BEGIN
INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
END;
and tested it:
CALL schreibe_cr('Test',1,2);
*... successfully. So I also added the parameter to the trigger:*
CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
FOR EACH ROW
call schreibe_cr('Tabellenname',1,2)
and what i get is:
Error starting at line 31 in command:
CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
FOR EACH ROW
call schreibe_cr('Tabellenname',1,2)
When I try to insert something into that table I get the following error:
insert into bak_s3_berufliste (id_bl, berufsbez) values (seq_bak_s3_change_request.NEXTVAL, 'tueduelue');
Error report:
ORA-00911: Ungültiges Zeichen
00911. 00000 - "invalid character"
Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
Action:
I tried everything that came to my mind, like using double-quotes (") instead of quotes (') in the trigger code or escaping the quotes (\'), but nothing worked. Can anybody help my and tell me what's wrong? After googling for hours I'm outta ideas :-(
Any ideas appreciated!
Thanks in advance,
JensWhy?
Are you looking for this?
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:01.61
satyaki>
satyaki>
satyaki>create table aud_dup_emp
2 as
3 select empno, ename
4 from dup_emp
5 where 1=2;
Table created.
Elapsed: 00:00:01.86
satyaki>
satyaki>select * from dup_emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 4450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 7000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
18 rows selected.
Elapsed: 00:00:00.10
satyaki>
satyaki>
satyaki>create or replace procedure ins_aud_dup(eno in number, enm in varchar2)
2 is
3 begin
4 insert into aud_dup_emp(empno,ename) values(eno,enm);
5 end;
6 /
Procedure created.
Elapsed: 00:00:03.36
satyaki>
satyaki>
satyaki>
satyaki>ed
Wrote file afiedt.buf
1 create or replace trigger trg_aud_dup
2 before insert on dup_emp
3 for each row
4 begin
5 ins_aud_dup(:old.empno,:new.ename);
6* end;
satyaki>/
Trigger created.
Elapsed: 00:00:01.47
satyaki>
satyaki>
satyaki>select * from aud_dup_emp;
no rows selected
Elapsed: 00:00:00.10
satyaki>
satyaki>
satyaki>insert into dup_emp(empno,ename,deptno) values(8855,'BILLY',40);
1 row created.
Elapsed: 00:00:00.19
satyaki>
satyaki>commit;
Commit complete.
Elapsed: 00:00:00.03
satyaki>
satyaki>
satyaki>select * from dup_emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 4450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 7000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
8855 BILLY 40
19 rows selected.
Elapsed: 00:00:00.20
satyaki>
satyaki>select * from aud_dup_emp;
EMPNO ENAME
BILLY
Elapsed: 00:00:00.09
satyaki>Regards.
Satyaki De. -
Looking for some help with using Oracle stored procedures in vb2010
First off thank you to whoever lends me a hand with my problem. A little background first I am in a software development class and we are currently building our program using VB (I have no experience in this), and Oracle(currently in a Oracle class so I know how to use Oracle itself just not with VB).
I am using vb2010 express edition if that helps. Currently I have a stored procedure that takes a 4char "ID" that returns a position (ie, salesperson,manager ect). I want to use the position returned to determine what vb form is displayed (this is acting as a login as you dont want a salesperson accessing the accountants page for payroll ect).
Here is the code I have currently on the login page of my VB form
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Login
Dim conn As New OracleConnection
Private Sub empID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles empID.Click
End Sub
Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
conn.ConnectionString = "User ID = Auto" & _
";Password = ********" & _
";Data Source = XE"
conn.Open()
Dim sq1 As String = "Return_Position" 'name of procedure
Dim cmd As New OracleCommand(sq1, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New OracleParameter("I_EmpID", OracleDbType.Char, 4)).Value = Emp_ID.Text
Dim dataReader As OracleDataReader = cmd.ExecuteReader
dataReader.Read()
Dim position As New ListBox
position.Items.Add(dataReader.GetString(0)) 'were I am getting an error, I also tried using the dataReader.getstring(0) to store its value in a string but its a no go
If position.FindStringExact("MANAGER") = "MANAGER" Then
Me.Hide()
Dim CallMenu As New Menu()
CallMenu.ShowDialog()
End If
LoginBtn.Enabled = False
End Sub
I have read the oracle.net developer guide for using oracle in vb2010 and have successfully gotten through the document however they never use a stored procedure, since the teacher wants this program to user a layered architecture I cannot directly store sql queries like the document does, thus the reason I want to use stored procedures.
This is getting frustrating getting stuck with this having no background in VB, I could easily do this in c++ using file i/o even through it would be a pain in the rear....Hello,
I am calling Oracle 11g stored procedures from VB.Net 2010. Here is a code sample (based on your code) you should be able to successfully implement in your application.
Please note that you may have to modify your stored procedure to include an OUT parameter (the employee position) if it doesn't have it yet.
Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
Dim sProcedureName As String = "Return_Position" 'name of stored procedure
Dim ORConn as OracleConnection, sConn as String
Dim sPosition as String, sDataSource as String, sSchema as String, sPWD as String
Dim cmd As OracleCommand
'please provide below sDataSource, sSchema and sPWD in order to connect to your Oracle DB
sConn = "Data Source=" & sDataSource & ";User Id=" & sSchema & ";Password=" & sPWD & ";"
ORConn = New OracleConnection(sConn)
ORConn.Open()
cmd = New OracleCommand(sProcedureName, ORConn)
With cmd
.CommandType = Data.CommandType.StoredProcedure
'input parameter in your stored procedure is EmpId
.Parameters.Add("EmpID", OracleDbType.Varchar2).Value = Emp_ID.Text
.Parameters.Item("EmpID").Direction = ParameterDirection.Input
'output parameter in your stored procedure is Emp_Position
.Parameters.Add("Emp_Position", OracleDbType.Varchar2).Direction = ParameterDirection.Output
.Parameters.Item("Emp_Position").Size = 50 'max number of characters for employee position
Try
.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Exit sub
End Try
End With
sPosition = cmd.Parameters.Item("Emp_Position").Value.ToString
'close Oracle command
If Not Cmd Is Nothing Then Cmd.Dispose()
Cmd = Nothing
'close Oracle connection
If Not ORConn Is Nothing Then
If not ORConn.State = 0 Then
ORConn.Close()
End If
ORConn.Dispose()
End If
ORConn = Nothing
If UCase(sPosition) = "MANAGER" Then
Me.Hide()
Dim CallMenu As New Menu()
CallMenu.ShowDialog()
End If
LoginBtn.Enabled = False
End Sub
If you need further assistance with the code, please let me know.
Regards,
M. R. -
Missing parameter in stored procedure
Hi all,
I am new to Crystal Report, and I am facing this situation:
a file .rpt reporting results of a sql server stored procedure, which takes one parameter in input.
This .rpt is invoked by an .net web service, via libraries, passing the parameter.
Now I evolved this stored procedure by adding a new parameter. Each of the two parameter is optional; the stored
procedure returns correctly formatted data with one parameter, the other one, both or none.
Then I adapted the .rpt file so that it can manage the updated stored procedure, via "Verify Database" istruction.
Also the .rpt has obviously two input parameters now, with a default value.
The problem is, the web service acting as handler gives the error "Missing parameter values", because actually it is passing still
one parameter.
If I update the web service code by passing both parameters, even with null value, it works, but for internal reasons I can't deploy
this updated code now
So, there is a way by modifying the .rpt using a stored procedure with two parameters, to make the invocation successfully even with one input parameter ?
The missing parameter would have, in the execution logic now, value null or default; it could fit for me.
Thanks in advance to everyone who will give advice!Thanks Don for your answer.
Unless you change the SP so it has the logic to accept only one value which depends on the parameter type, if they are both strings for example then your SP can use logic the determine what/which param to fill and null the other one.
What do you mean? Now if I call my stored procedure from SQL Server management studio with this command
EXEC [dbo].[StoredProcedureForCR] @FirstParameter = 2
so, passing only the first parameter, I have no error.
Which improvements to the SP are you suggesting?
If I modify the web service, the CR is working, but I cannot deploy it in production for internal reasons related to the company
Now I am planning these attempts:
- calling the stored procedure via a command
- creating in sql server a view and then filtering results in the report
Do you think they could make sense ?
Have a nice monday!
Lidia -
IN Operator Parameter using stored procedure
Hi Guys,
I'm running a reporting services report using stored procedure and I'm facing a dilemma with the IN Operator in the stored procedure.
Can someone please help me out debugging the statement below? (run it on AdventureWorks Database)
Can I have the @Title Parameter based on another select statement something like this
Set @Title = SELECT Title FROM TableTitle
DECLARE @Title varchar(1000)
set @Title = 'Design Engineer', 'Tool Designer', 'Marketing Assistant'
SELECT FirstName, LastName, e.Title
FROM HumanResources.Employee AS e
JOIN Person.Contact AS c
ON e.ContactID = c.ContactID
WHERE e.Title IN (@Title)
Appreciate all the help on this.
Thank you
JohnHi John,
For your problem, we can use dynamical statement to solve the issue.
Here are 2 options to be clarified:
1. A multi-value parameter will return an array value.
2. It is not able to pass an array in a stored procedure.
To solve the issue, we can use the following steps:
1. Cconvert the array into string that delimited by “,” using the function “Join” in SQL Server Reporting Services.
2. Pass the string in the stored procedure.
3. Combine the parameter and the statement into one simply string.
4. Execute the simply string.
Here are the detailed steps for your reference:
1. In Report Designer, create a new dataset as “SELECT Title FROM TableTitle”.
2. Create a new multi-value parameter, set the available value from the dataset above.
3. Set the query of the main dataset as :
="spSelect_Title "&Join(Parameters!para.Value, ",")
4. Change the stored procedure as:
ALTER PROCEDURE [dbo].[spSelect_Title]
-- Add the parameters for the stored procedure here
--@Query NVarchar(Max),
@Title NVarchar(MAX)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @Query Varchar(Max)
SET @Query = 'SELECT FirstName, LastName, e.Title
FROM HumanResources.Employee AS e
JOIN Person.Contact AS c
ON e.ContactID = c.ContactID
WHERE e.Title IN (' + @Title+ ')'
-- PRINT ' QUERY = '+ ISNULL(@Query,'NULL')
Execute sp_executesql @Query
END
If you have any more questions, please feel free to ask.
Thanks,
Jin
Jin Chen - MSFT
Maybe you are looking for
-
Error in source system, SQL ERROR 1652
Hello Experts, While loading data from data mart, cube to cube, the data load runs for an hour or so and the request turns red. The error message is SQL error:1652, Errors occured in Source System. Previously a day back I was able to load the data su
-
hi everybody I am creating a application in which i am reading a text file from resource and using this text in my canvas but i am facing problem in fetching some characters like currency sign like euro in text and some other characters that are not
-
Nokia is cheating us with their 5800 :( - Screen B...
I bought nokia 5800 on the first day of its release(jan 3rd,2009) in Bangalore,India. The fone was gr8. But all of a sudden the screen got spoilt, it used to go blur rendering it useless whenever the screen was unlocked(using the slider on the righ
-
How to know internally redirect in Proxy Server
Hello, I notice that our developed NSAP codes, at very first time, Sun Java System proxy Server internally redirect in Proxy Server. If anyone knows how we can get the behavior difference between internal redirect and normal procedure to see the pblo
-
What Is This Icon In a Thumbnail View?
When viewing thumbnails in Bridge CS3 I am seeing a "symbol" or icon in the upper right-hand corner of the selected image. It appears to be a gray circular shape with small up/down or circular arrows inside. Can't find any reference to it. Anyone kno