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 advance
to 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.
Similar Messages
-
How to pass a date parameter(from a procedure IN) to a API
Hi,
CREATE OR REPLACE package body xxal_basic_sal_increment_pkg1 as
procedure emp_pro_inc1(ERRBUF VARCHAR2,RETCODE OUT NUMBER,
p_business_group_id_enter in number,p_change_date in varchar2) is
CURSOR STAFF IS
SELECT pp.ASSIGNMENT_ID
,peo.EMPLOYEE_NUMBER employee_no
,pp.OBJECT_VERSION_NUMBER
,pp.PAY_PROPOSAL_ID
,pp.PROPOSED_SALARY_N basic_salary
,pp.PROPOSAL_REASON
,pp.change_date
,pp.BUSINESS_GROUP_ID
,pg.name
,pr.PERFORMANCE_RATING,
'' v_effective_start_date,
'' v_effective_end_date
FROM per_all_people_f peo,
per_all_assignments_f pa,
per_pay_proposals pp,
per_grades_tl pg,
per_performance_reviews_v pr
where pa.person_id = peo.PERSON_ID
and pa.ASSIGNMENT_ID = pp.ASSIGNMENT_ID
and peo.PERSON_ID=pr.PERSON_ID
and pg.GRADE_ID=pa.GRADE_ID
--and peo.EMPLOYEE_NUMBER=STAFF_VAR.employee_no
and sysdate between peo.EFFECTIVE_START_DATE and peo.EFFECTIVE_END_DATE
and sysdate between pa.EFFECTIVE_START_DATE and pa.EFFECTIVE_END_DATE
and peo.BUSINESS_GROUP_ID = p_business_group_id_enter
and pp.change_DATE = (select max(change_DATE) from per_pay_proposals temp
where ASSIGNMENT_ID =pp.ASSIGNMENT_ID);
--L_BUSINESS_GROUP_ID NUMBER:=5128;
L_ASSIGNMENT_ID NUMBER;
L_PAY_PROPOSAL_ID NUMBER;
L_OBJECT_VERSION_NUMBER NUMBER;
L_pyp_proposed_sal_warning BOOLEAN;
L_additional_comp_warning boolean;
l_person_id number;
L_COMMON boolean;
L_ELEMENT_ENTRY_ID NUMBER;
TEMP NUMBER;
L_EFFECTIVE_START_DATE DATE;
L_MULTI VARCHAR2(30):='N';
L_APPROVED VARCHAR2(30):='Y';
L_CHANGE_DATE DATE:=TO_DATE('31-JAN-2008','DD-MON-YYYY');
BEGIN
v_disp_output:='EMPLOYEE_NUMBER'||','||
'BASIC'||','||
'EFF START DATE'||','||
'EFF END DATE';
fnd_file.put_line(FND_FILE.output,v_disp_output);
FOR STAFF_VAR IN STAFF LOOP
L_ELEMENT_ENTRY_ID:=null;
begin
select assign.assignment_id,assign.effective_start_date into
l_assignment_id,l_change_date_new
from per_people_f peo,per_assignments_f assign
where peo.person_id=assign.person_id
and sysdate between peo.effective_start_date and peo.effective_end_date
and sysdate between assign.effective_start_date and assign.effective_end_date
and current_employee_flag='Y'
and primary_flag='Y'
and peo.business_group_id=l_business_group_id
and peo.employee_number=staff_var.employee_no;
L_CHANGE_DATE_new:=L_CHANGE_DATE;
--L_CHANGE_DATE_new:=STAFF_VAR.v_effective_start_date;
begin
HR_MAINTAIN_PROPOSAL_API.INSERT_SALARY_PROPOSAL
P_PAY_PROPOSAL_ID=>L_PAY_PROPOSAL_ID
,P_ASSIGNMENT_ID=>staff_var.ASSIGNMENT_ID
,P_BUSINESS_GROUP_ID=>staff_var.BUSINESS_GROUP_ID
,P_CHANGE_DATE=>L_CHANGE_DATE_new
,P_PROPOSED_SALARY_N=>STAFF_VAR.basic_salary
,P_OBJECT_VERSION_NUMBER=>STAFF_VAR.OBJECT_VERSION_NUMBER
,p_multiple_components=>L_MULTI
,p_approved=>L_APPROVED
,P_VALIDATE=>false
,p_element_entry_id =>L_ELEMENT_ENTRY_ID
,P_INV_NEXT_SAL_DATE_WARNING=>l_common
,P_PROPOSED_SALARY_WARNING=>L_COMMON
,P_APPROVED_WARNING=>L_COMMON
,P_PAYROLL_WARNING=>L_COMMON
in the above code the variable L_CHANGE_DATE DATE is hard coded .
but we need to supply this variable value as dynamic, means (p_change date--procedure IN Parameter )
i tried like below ,
CREATE OR REPLACE package body xxal_basic_sal_increment_pkg1 as
procedure emp_pro_inc1(ERRBUF VARCHAR2,RETCODE OUT NUMBER,
p_business_group_id_enter in number,p_change_date in varchar2) is
CURSOR STAFF IS
SELECT pp.ASSIGNMENT_ID
,peo.EMPLOYEE_NUMBER employee_no
,pp.OBJECT_VERSION_NUMBER
,pp.PAY_PROPOSAL_ID
,pp.PROPOSED_SALARY_N basic_salary
,pp.PROPOSAL_REASON
,pp.change_date
,pp.BUSINESS_GROUP_ID
,pg.name
,pr.PERFORMANCE_RATING,
'' v_effective_start_date,
'' v_effective_end_date
FROM per_all_people_f peo,
per_all_assignments_f pa,
per_pay_proposals pp,
per_grades_tl pg,
per_performance_reviews_v pr
where pa.person_id = peo.PERSON_ID
and pa.ASSIGNMENT_ID = pp.ASSIGNMENT_ID
and peo.PERSON_ID=pr.PERSON_ID
and pg.GRADE_ID=pa.GRADE_ID
--and peo.EMPLOYEE_NUMBER=STAFF_VAR.employee_no
and sysdate between peo.EFFECTIVE_START_DATE and peo.EFFECTIVE_END_DATE
and sysdate between pa.EFFECTIVE_START_DATE and pa.EFFECTIVE_END_DATE
and peo.BUSINESS_GROUP_ID = p_business_group_id_enter
and pp.change_DATE = (select max(change_DATE) from per_pay_proposals temp
where ASSIGNMENT_ID =pp.ASSIGNMENT_ID);
--L_BUSINESS_GROUP_ID NUMBER:=5128;
L_ASSIGNMENT_ID NUMBER;
L_PAY_PROPOSAL_ID NUMBER;
L_OBJECT_VERSION_NUMBER NUMBER;
L_pyp_proposed_sal_warning BOOLEAN;
L_additional_comp_warning boolean;
l_person_id number;
L_COMMON boolean;
L_ELEMENT_ENTRY_ID NUMBER;
TEMP NUMBER;
L_EFFECTIVE_START_DATE DATE;
L_MULTI VARCHAR2(30):='N';
L_APPROVED VARCHAR2(30):='Y';
L_CHANGE_DATE DATE:=TO_DATE(p_change_date,'DD-MON-YYYY');
BEGIN
v_disp_output:='EMPLOYEE_NUMBER'||','||
'BASIC'||','||
'EFF START DATE'||','||
'EFF END DATE';
fnd_file.put_line(FND_FILE.output,v_disp_output);
FOR STAFF_VAR IN STAFF LOOP
L_ELEMENT_ENTRY_ID:=null;
begin
select assign.assignment_id,assign.effective_start_date into
l_assignment_id,l_change_date_new
from per_people_f peo,per_assignments_f assign
where peo.person_id=assign.person_id
and sysdate between peo.effective_start_date and peo.effective_end_date
and sysdate between assign.effective_start_date and assign.effective_end_date
and current_employee_flag='Y'
and primary_flag='Y'
and peo.business_group_id=l_business_group_id
and peo.employee_number=staff_var.employee_no;
L_CHANGE_DATE_new:=L_CHANGE_DATE;
--L_CHANGE_DATE_new:=STAFF_VAR.v_effective_start_date;
begin
HR_MAINTAIN_PROPOSAL_API.INSERT_SALARY_PROPOSAL
P_PAY_PROPOSAL_ID=>L_PAY_PROPOSAL_ID
,P_ASSIGNMENT_ID=>staff_var.ASSIGNMENT_ID
,P_BUSINESS_GROUP_ID=>staff_var.BUSINESS_GROUP_ID
,P_CHANGE_DATE=>L_CHANGE_DATE_new
,P_PROPOSED_SALARY_N=>STAFF_VAR.basic_salary
,P_OBJECT_VERSION_NUMBER=>STAFF_VAR.OBJECT_VERSION_NUMBER
,p_multiple_components=>L_MULTI
,p_approved=>L_APPROVED
,P_VALIDATE=>false
,p_element_entry_id =>L_ELEMENT_ENTRY_ID
,P_INV_NEXT_SAL_DATE_WARNING=>l_common
,P_PROPOSED_SALARY_WARNING=>L_COMMON
,P_APPROVED_WARNING=>L_COMMON
,P_PAYROLL_WARNING=>L_COMMON
but we are getting the error Cause: FDPSTP failed due to ORA-01839: date not valid for month specified
ORA-06512: at "APPS.XXAL_BASIC_SAL_INCREMENT_PKG1", line 45
ORA-06512: at line 1
we tried the solution available in the metalink still its giving error ..
pl help us to solve this issue ...
how should we pass the date parameter while we run the concurrent program(we used date value set).
also we tried with some other value set also ..
Regards,
kumardear,
I have the following code to create proposal, but the API create salary proposal for all record s and does not create entry for all records it just creates for the first record
any advice
the code ....
/* Formatted on 2007/08/29 16:20 (Formatter Plus v4.8.8) */
----------------------- P R O P O S A L -------------------------
DECLARE
l_rows_processed NUMBER := 0;
l_commit_point NUMBER := 500;
l_business_group_id NUMBER
:= fnd_profile.VALUE ('PER_BUSINESS_GROUP_ID');
l_proposal_salry NUMBER;
l_approved CHAR (1);
l_rowid VARCHAR2 (30);
l_errmessage VARCHAR2 (400);
l_entry_indecator NUMBER;
l_assignment_id NUMBER;
p_ctr_object_version_number NUMBER;
-- Out Parameters --
l_element_entry_id NUMBER;
p_element_entry_id NUMBER;
l_ctr_object_version_number NUMBER;
l_pay_proposal_id NUMBER;
l_inv_next_sal_date_warning BOOLEAN;
l_proposed_salary_warning BOOLEAN;
l_approved_warning BOOLEAN;
l_payroll_warning BOOLEAN;
CURSOR crs_dc_mn
IS
SELECT xdp.ROWID, xdp.assignment_id, xdp.change_date,
xdp.proposal_reason, xdp.proposed_salary,
xdp.assignment_number, xdp.employee_number, xdp.person_id,
xdp.new_asg_id
FROM apps.xx_dc_proposal xdp
WHERE xdp.assignment_id <> -1
AND xdp.processed = 'N'
AND xdp.change_date =
(SELECT MIN (xdc.change_date)
FROM xx_dc_proposal xdc
WHERE xdc.assignment_id = xdp.assignment_id
AND xdc.processed = 'N')
ORDER BY assignment_id, change_date ASC;
pro_rcrd crs_dc_mn%ROWTYPE;
CURSOR crs_dc_proposal1 (p_asg_id IN NUMBER)
IS
SELECT xdp.ROWID, xdp.assignment_id, xdp.change_date,
xdp.proposal_reason, xdp.proposed_salary,
xdp.assignment_number, xdp.employee_number, xdp.person_id,
xdp.new_asg_id
FROM apps.xx_dc_proposal xdp
WHERE xdp.assignment_id <> -1
AND xdp.processed = 'N'
AND xdp.assignment_id = p_asg_id
ORDER BY assignment_id, change_date ASC;
BEGIN
OPEN crs_dc_mn;
FETCH crs_dc_mn
INTO pro_rcrd;
LOOP
BEGIN
hr_maintain_proposal_api.insert_salary_proposal
(p_pay_proposal_id => l_pay_proposal_id,
p_assignment_id => pro_rcrd.assignment_id,
p_business_group_id => l_business_group_id,
p_change_date => pro_rcrd.change_date,
p_comments => NULL,
p_next_sal_review_date => NULL,
p_proposal_reason => NULL,
p_proposed_salary_n => pro_rcrd.proposed_salary,
p_forced_ranking => NULL,
p_performance_review_id => NULL,
p_attribute_category => NULL,
p_attribute1 => NULL,
p_attribute2 => NULL,
p_attribute3 => NULL,
p_attribute4 => NULL,
p_attribute5 => NULL,
p_attribute6 => NULL,
p_attribute7 => NULL,
p_attribute8 => NULL,
p_attribute9 => NULL,
p_attribute10 => NULL,
p_attribute11 => NULL,
p_attribute12 => NULL,
p_attribute13 => NULL,
p_attribute14 => NULL,
p_attribute15 => NULL,
p_attribute16 => NULL,
p_attribute17 => NULL,
p_attribute18 => NULL,
p_attribute19 => NULL,
p_attribute20 => NULL,
p_object_version_number => l_ctr_object_version_number,
p_multiple_components => 'N', -- 918219
p_approved => 'Y',
p_validate => FALSE,
p_element_entry_id => l_element_entry_id,
p_inv_next_sal_date_warning => l_inv_next_sal_date_warning,
p_proposed_salary_warning => l_proposed_salary_warning,
p_approved_warning => l_approved_warning,
p_payroll_warning => l_payroll_warning
UPDATE xx_dc_proposal
SET processed = 'Y'
WHERE ROWID = pro_rcrd.ROWID;
l_rows_processed := l_rows_processed + 1;
IF l_rows_processed = l_commit_point
THEN
COMMIT;
l_rows_processed := 0;
END IF;
EXCEPTION
WHEN OTHERS
THEN
l_errmessage := SQLERRM;
UPDATE xx_dc_proposal
SET err_message = l_errmessage
WHERE ROWID = pro_rcrd.ROWID;
END;
END LOOP;
CLOSE crs_dc_mn;
COMMIT;
END;
.............................. -
Passing multi-value parameter in stored procedure ssrs
I have customer parameter which is a drop down list in my report and I have set it to "allow multiple values". This is an SSRS report.
How do I pass multiple values to my stored procedure?
RJHi ,
Create a Table valued function in SQL Functions as below
Step 1
CREATE FUNCTION [dbo].[FnSplit]
@List nvarchar(2000),
@SplitOn nvarchar(5)
RETURNS @RtnValue table
Id int identity(1,1),
Value nvarchar(100)
AS
BEGIN
While (Charindex(@SplitOn,@List)>0)
Begin
Insert Into @RtnValue (value)
Select
Value = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1)))
Set @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End
Insert Into @RtnValue (Value)
Select Value = ltrim(rtrim(@List))
Return
END
Step 2 in your store procedure change the parameter where condition something like below
ALTER PROCEDURE [dbo].[SomeSP]
-- Add the parameters for the stored procedure here
@CostCentre NVARCHAR(255)
SELECT
[ProjectCode],[ProjectName],[ProjectManager],SUM([Hours]) AS [Hours MTD]FROM dbo.Rpt_NRMA_CATS NC
INNER JOIN PeriodID P ON NC.PeriodID=P.PeriodID
WHERE
([CostCentre]) collate database_default IN(SELECT Value FROM dbo.FnSplit(@CostCentre,','))
END
I hope this will help you.
Dasari -
Passing XMLType Data into oracle stored procedure using JDBC
Hi Friends,
I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.
Following are the environment details
JDK Version: 1.6
Oracle: 10g
Server: Tomcat 6.x
Thanks in Advanceuser4898687 wrote:
I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.As stated - no.
A 'file' is a file system entity. There is no way to pass a 'file' anywhere. Not PL/SQL. Not java.
Now you can pass a file path (a string) in java and to PL/SQL.
Or you can pass xml data (a string) in java and to PL/SQL. For PL/SQL you could use eithe a varchar2, if the xml is rather small, or a blob/clob. -
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 -
Passing data from Oracle stored procedures to Java
We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
We're considering one of the 2 following scenarios:
passing objects and lists of objects (DB object types defined on the schema level)
passing a sys_refcursor
We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
I'd appreciate any hints.user1754151 wrote:
We're going to write a new web interface for a big system based on Oracle database. All business rules are already coded in PL/SQL stored procedures and we'd like to reuse as much code as possible. We'll write some new stored procedures that will combine the existing business rules and return the final result dataset.
We want to do this on the database level to avoid java-db round trips. The interface layer will be written in Java (we'd like to use GWT), so we need a way of passing data from Oracle stored procedures to Java service side. The data can be e.g. a set of properties of a specific item or a list of items fulfilling certain criteria. Would anyone recommend a preferable way of doing this?
We're considering one of the 2 following scenarios:
passing objects and lists of objects (DB object types defined on the schema level)
passing a sys_refcursor
We verified that both approaches are "doable", the question is more about design decision, best practice, possible maintenance problems, flexibility, etc.
I'd appreciate any hints.If logic is already written in DB, and the only concern is of passing the result to java service side, and also from point of maintenance problem and flexibility i would suggest to use the sys_refcursor.
The reason if Down the line any thing changes then you only need to change the arguments of sys_refcursor in DB and as well as java side, and it is much easier and less efforts compare to using and changes required for Types and Objects on DB and java side.
The design and best practise keeps changing based on our requirement and exisiting design. But by looking at your current senario and design, i personally suggest to go with sys_refcursor. -
Passing dynamic parameter to stored procedure from CR formula?
Dear all,
I need to insert in some textboxes the right string based on the desired Language Code.
I crated a stored procedure in my db.
CREATE PROCEDURE MY_GET_TRANSLATION
@TextID nvarchar(8),
@LangCode int
This parameters are used as keys to get the Trans field.
I created a workshop formula: GetTranslation
Please, can someone suggest the correct statement to call my MY_GET_TRANSLATION stored procedure passing parameters?
I would like to call the GetTranslation formula from all my textboxes, passing the specific TextID value
and visualized the right translated string.
For example:
in my TEXT1 textbox, I would like to call the GetTranslation formula passing the parameters
TextID = "T000001"
and
LangCode = 13 (Italian language)
How can pass dynamic parameters to a formula?
How can pass dynamic parameters to a stored procedure from a CR formula?
Regards
EmanueleDear Jason,
I'm trying to modify a SAP B1 CR marketing report.
This CR marketing document is called by SAP B1 automatically passing the Document Number and Document Type.
The report uses the right SAP B1 tables to read the information of the header and rows of the document.
The language of the document is contained in a field of the header table
{MyMarketingDocTable.LanguageID}
I created a user table named "MyTranslationTable" where I added some strings in different langiages.
For example:
TexiID TextString LangID
T00001 Delivery 8
T00001 Consegna 13 (Italian translation)
T00002 Invoice 8
T00002 Fattura 13 (Italian translation)
In the header of the report I'd like, for example, to visualise the string "Consegna" if my document is a delivery in italian language.
I'd like to implement this method to translate all the textboxes (header, comments, etc.) based on the languageID of my document.
For each textboxes, in the CR designer statically I know what TextID I want to visualized but dinamically I need to pass to my stored procedure the right language. I'd like my report automatically gets the language at run-time. I don't want that when I press the Print-preview button in SAP B1, the report asks to prompt the languageID.
It already read the DocNum and DocType and it already filter the SAP B1 tables basing on the DocNum and DocType of the document. In this way it reads the right row in the SAP B1 table and in this way I can read all the fields of this row (also the languageID of the actual document).
Regards
Emanuele
Edited by: Emanuele Croci on Dec 3, 2010 9:03 AM -
Passing Comma separated input to stored procedure in IN clause
Hi All,
I have a query below in a stored procedure as like this
Create PROCEDURE insertinfo
@userids varchar(MAX)
AS
BEGIN
INSERT INTO records
(id
,name
,address1
,address2
,pincode
SELECT
id,
name,
addr1,
addr2,
pin,
FROM userinfo
WHERE userinfo.id in(@userids)
END
I am not using any dynamic sql. Its a simple insert into select query with multiple parameters supplied via thd @userids parameter. When i run the query nothing is inserting in the "records" table. I have gone throught the web search have
tried with few options but no result yet. The query works fine when i pass only a single value, but it does not work when is pass multiple values.
Please guide on this.
Your help is appreciated.
Thanks,
mds2907mds2907,
CHeck this:
--Method 1
--Usage of TVP
--Method 2
--Usage of SPLIT fn()
Create PROCEDURE insertinfo(@userids varchar(MAX))
AS
BEGIN
INSERT INTO records
(id,name,address1,address2,pincode)
SELECT id, name,addr1,addr2, pin
FROM userinfo
WHERE userinfo.id in(select * from sample_split(@userids,','))
END
--Method3
--Usage of Dynamic SQL
Applicable only when the values in csv are integers
like '1,2,3'
Create PROCEDURE insertinfo(@userids varchar(MAX))
AS
BEGIN
DECLARE @sql nvarchar(max)
SET @sql='
INSERT INTO records
(id,name,address1,address2,pincode)
SELECT id, name,addr1,addr2, pin
FROM userinfo
WHERE userinfo.id in('+@userids')'
EXEC sp_executesql @sql
END
Sample_Split():
CREATE FUNCTION dbo.sample_Split
@RowData nvarchar(2000),
@SplitOn nvarchar(5)
RETURNS @RtnValue table
Id int identity(1,1),
Data nvarchar(100)
AS
BEGIN
Declare @Cnt int
Set @Cnt = 1
While (Charindex(@SplitOn,@RowData)>0)
Begin
Insert Into @RtnValue (data)
Select
Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
Set @Cnt = @Cnt + 1
End
Insert Into @RtnValue (data)
Select Data = ltrim(rtrim(@RowData))
Return
END
Usage of TVP for a scenario similar to yours is explained herE:
http://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/0ead7ceb-3fdd-4625-aa82-1d4195f984b1/passing-multivalue-parameter-in-stored-procedure-ssrs
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
URGENT: I want to pass a variable to a stored procedure at run time
Post Author: aruplabs
CA Forum: Data Connectivity and SQL
I work for a health care provider and I have reports that pull PHI (Protected Health Information) about patients that needs to be logged according to federal HIPAA regulations. One of the pieces of information that needs to be logged is the username of the person who ran the report. Since these reports will be run from our Crystal Enterprise server I can get this from the CurrentCEUserName variable but I am looking for a way to pass this value to a stored procedure that will not only return the records for the report, but also log the disclosure in our PHI disclosure tracking table. I know you can pass a parameter to a stored procedure but I dont know how, or if it is even possible, to pass a run time variable. This is an urgent problem that I need to find a solution for. Any help would be appreciated.
Thank you.Here it is. Right now, when i press te "Go" it runs for the specific time i've set and when its done the variable "Run" is set true. When i call this VI from another VI it waits for the loop to be finished before it will read the variable.
Regards
Viktor
Attachments:
Untitled 2.vi 26 KB -
Passing multiple values to a stored procedure
Hi All,
I have a stored procedure which displays a chart. The header of this procedure is:
create or replace procedure chart ( p_period IN VARCHAR2) is
When calling this procedure with something like the folloeing:
<PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=MONTH">
everything works OK.
Now, I would like to replace p_period=MONTH with a value coming from an ITEM on the page, so something like:
<PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=:P13_PERIOD">
However, the above doesn't work.
Can anyone give me the correct syntax please?
Also what would be the syntax for passing more than one value? ie:
source=ohsinit.chart?p_period=:P13_PERIOD,p_start=:P13_START_DATE ?
Regards,
Pawel.Hi Denes,
I am not sure I understand your post...
What I am trying to do here is to pass 3 values namely
P13_PERIOD (VARCHAR2),
P13_START_DATE (DATE),
P13_END_DATE (DATE)
into a stored procedure which displays the graph.
So far I managed to get it working using:
<PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=&P13_PERIOD.">
However when I try to put in:
<PARAM NAME=movie VALUE="/i/charts.swf?library_path=/i/charts_library&xml_source=ohsinit.chart?p_period=&P13_PERIOD.,p_start=&P13_START_DATE.">
I get the graph blank (but not the orange timeout message... if you are familiar with XML/SWG graphs.) -
Read data from a Stored Procedure in Android
I have a Stored Procedure say CustOrdersDetail. I have created a MBO for it in the workspace and deployed it on SAP Mobile Server. I am unable to read data from the stored procedure in code of the Android Application. If I pass a default load argument, then I am able to read data using findAll method. How to get the data from the stored procedure by passing it an argument in the Android Code ?
Message was edited by: Abhijit KadamCurrently I am trying to call the stored procedure and retrieve the results. The stored procedure accepts 'orderId' as an argument and fetches the Product and Order Details.
-
Use return date value in stored procedure
hi
i am new in oracle , i make stored procedure to fetch data in the form and i make calendar , i want user when they select a date from date LOV the stored procedure use this date in the query.. i try like this in the query:
when time=:blok.date_item;
but i get IN OUT error in the procedure.
any help will be appreciated.ok this is the package header:
create or replace package get_outvalue_test is
type rec is record (time archive.time%type,
value archive%type);
type value_tab is table of rec index by binary_integer;
procedure get_value(p_returnvalue IN OUT value_tab);
end;
package body :
create or replace package body get_outvalue_test is
procedure get_value(p_returnvalue IN OUT value_tab)
is
ii number;
cursor valselect is
select time,value from archive where u_id=5666
and time=:block.date_item ; -- this is the return date from LOV
begin
open valselect;
ii:=1
loop
fetch valselect into
p_returnvalue(ii).time;
p_returnvalue(ii).value;
exite when valselect %notfound;
ii:=ii+1;
end loop;
end;
end;
this is the error when i compile the package body :
MIssing IN or OUT parameter at index
i hope itis cleare and easy . -
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 -
Passing comma separated string to stored procedure
Hi,
There is thread with same query I created earlier and that was answered. That solution worked if I pass comma separated string containing IDs. But due to changes in the logic, I have to pass usernames instead of userIDs. I tried to modify the solution provided to use with this.
Following the link to previous post :
Re: Passing comma separated string to stored procedure
------Package-------
TYPE refcurQID IS REF CURSOR;
TYPE refcurPubs IS REF CURSOR;
procedure GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID
, TestPubs OUT Test.refcurPubs);
------Package-------
------Package Body-------
PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs) as
BEGIN
Open TestQID for
select id from cfq where name in (p_user_name);
Open TestPubs for
SELECT qid FROM queues WHERE qid in(
select id from cfq where name in (p_user_name));
END GetAllPersonalQueue;
------Package Body-------
Thanks in advance
AdityaHi,
I modified the query as per the solution provided by isotope, after which the logic changed and I am passing username instead of userID in comma separated string.
Following is the changes SP, which does not throw any error, but no data is returned.
PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs
) is
--local variable
strFilter varchar2(100);
BEGIN
Open TestQID for
select id, name from cfq where name in
select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
from dual
connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
from dual)
Open TestPubs for
SELECT qid FROM queues WHERE qid in(
select id from cfq where name in
select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
from dual
connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
from dual)
END GetAllPersonalQueue;
Edited by: adityapawar on Feb 27, 2009 8:38 AM
Maybe you are looking for
-
What line type should I use for a)Return with no credit, and b) for the corresponding replacement item(ship-only workflow)? Can I put these 2 lines in the same SO?
-
Shipping Date was off and no updates on when it wil arrive.
Hi there, I purchased a 50" inch Samsung TV at the beginning of this week 4/27 and when I chose my shipping option, Best Buy's website stated that I could either pay 60 bucks for a next day (4/28 Tuesday) delivery or get it delivered by Weds 4/29 fo
-
Datatemplate query and publishing the output
I'm troubleshooting performance problem in Oracle Apps r12 while running GL/XLA reports using the XML Publisher. The query which is defined in datatemplate takes less then a minute to complete while I execute it from PLSQL environment, however the en
-
HT4623 I want to restore my iPad.
I want to restore my iPad to factory settings, but when I try to it tries to download iOS 5.1.1 before I can restore. I have already updated the iPad with iOS 5.1.1 using wifi. My itunes says that the iPad is updated, and yet it still wants to downlo
-
DMP-4400G How can I change the local time
Hi, Recently I installed DMS 5.0.2 and DMP-4400G for Digital Signage. Now I am running a Flash application that is embedded into a HTML page, but sometimes the DMP does not show the content of the flash, the LCD shows a temporary error; this error ne