Where is it declared the return variable?
Hi everyone,
please which system privileges must you have to recompile a stored procedure owned by another application developer?
and where is it declared the return variable?
thank you
In short you will need ALTER ANY PROCEDURE privilidge for that.
Lets do a test for this:
From User A:
SQL> create table test as select * from user_objects where rownum<10;
SQL> create procedure test_proc as
2 begin
3 delete test;
4 commit;
5 end;
6 /
Procedure created.
Now from User Scott:
alter procedure cr.test_proc compile
ERROR at line 1:
ORA-01031: insufficient privileges
Now connect to user A and do the following:
1* grant alter any procedure to scott
SQL> /
Grant succeeded.
Now from Scott user:
alter procedure cr.test_proc compile;
Procedure altered.
SQL> show errors
No errors.
Thats what you wanted.
Riaz
Similar Messages
-
Hello Experts,
Can You help me; I get the follwing error in my query
Msg 1087, Level 15, State 2, Line 31
Must declare the table variable "@ASE_SUBART_GROEP".
the @ASE_SUBART_GROEP is a self-defined table in this SQL environment.
Maybe you know the error or the missing part
Thanks in advance, Jos DielemansI'm not familiar with SAP Business One unfortunately, so can only be of limited help here. But I'm going to guess that @ASE_SUBART_GROEP is a table variable passed to a stored procedure and is defined and passed down by the application, so you won't
be able to copy-paste this code directly into management studio and get it to work.
You could remove the join to return *all* records. Although the dataset might be very big
SELECT T0.CardCode AS 'Klantnr'
,T0.CardName AS 'Klantnaam'
,T4.GroupName AS 'Klantgroep'
,T9.Descr AS 'Merknaam'
,T5.SlpName AS 'Verkoper'
,T3.MailCity AS 'Leverplaats'
,T7.NAME AS 'Leverland'
,T3.City AS 'Factuurplaats'
,T7.NAME AS 'Factuurland'
,T0.DocNum AS 'Documentnr'
,T0.DocDate AS 'Datum'
,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
,T1.ItemCode AS 'Artikelnr'
,T2.ItemName AS 'Artikelnaam'
,T1.Quantity AS 'Aantal VEH'
,T2.SVolume AS 'Aantal EH per VEH'
,(T1.Quantity * T2.SVolume) AS 'Aantal EH'
,T8.UnitName AS 'EH-Naam'
,T6.ItmsGrpNam AS 'Artikelgroep'
,T2.U_ItemGrp AS 'Hoofdgroep'
,T10.NAME AS 'Subgroep'
,T1.CogsAcct AS 'Kostpr.rek.'
,T1.AcctCode AS 'Opbrengstrek.'
,T1.LineTotal AS 'BrutoOmzet'
,T0.DiscPrcnt AS 'Korting'
,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
FROM dbo.OINV T0
INNER JOIN dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
INNER JOIN OCRY T7 ON T3.Country = T7.Code
LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
AND TableID = 'OCRD'
AND FieldID = 2
--LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
WHERE T0.DocDate >= '20120101'
AND T0.Canceled = 'N'
UNION ALL
SELECT T0.CardCode AS 'Klantnr'
,T0.CardName AS 'Klantnaam'
,T4.GroupName AS 'Klantgroep'
,T9.Descr AS 'Merknaam'
,T5.SlpName AS 'Verkoper'
,T3.MailCity AS 'Leverplaats'
,T7.NAME AS 'Leverland'
,T3.City AS 'Factuurplaats'
,T7.NAME AS 'Factuurland'
,T0.DocNum AS 'Documentnr'
,T0.DocDate AS 'Datum'
,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
,T1.ItemCode AS 'Artikelnr'
,T2.ItemName AS 'Artikelnaam'
,- T1.Quantity AS 'Aantal VEH'
,T2.SVolume AS 'Aantal EH per VEH'
,(- T1.Quantity * T2.SVolume) AS 'aantal EH'
,T8.UnitName AS 'EH-Naam'
,T6.ItmsGrpNam AS 'Artikelgroep'
,T2.U_ItemGrp AS 'Hoofdgroep'
,T10.NAME AS 'Subgroep'
,T1.CogsAcct AS 'Kostpr.rek.'
,T1.AcctCode AS 'Opbrengstrek.'
,- T1.LineTotal AS 'BrutoOmzet'
,T0.DiscPrcnt AS 'Korting'
,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
FROM dbo.ORIN T0
INNER JOIN dbo.RIN1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
INNER JOIN OCRY T7 ON T3.Country = T7.Code
LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
AND TableID = 'OCRD'
AND FieldID = 2
--LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
WHERE T0.DocDate >= '20120101'
AND T0.Canceled = 'N'
ORDER BY T0.CardCode
The join to the table variable has been commented out above, so the code should run. After that you might want to update the WHERE clause to include only particular sub-groups -
Getting "Must declare the scalar variable" Error
Hello All,
I have write following query to block invoice which has Prices not equal to PriceList as below.
-- To Block Invoices which has Prices not equal to PriceList
IF (@transaction_type='A' OR @transaction_type = 'U') AND CAST(@OBJECT_TYPE = '18')
BEGIN
SELECT T1.ItemCode,
T1.Price AS PO_Price,
T2.U_ListPrice AS Listed_Price
FROM OPCH AS T0
INNER JOIN
PCH1 AS T1 ON
T0.DocEntry = T1.DocEntry
LEFT OUTER JOIN
[dbo].[@PRICELISTS] AS T2 ON
T1.ItemCode = T2.U_ItemNo
WHERE
T1.DocEntry = @list_of_cols_val_tab_del) AND
(T1.Price <> T2.U_ListPrice)
BEGIN
SET @error = 123
SET @error_message = 'Deviation in price'
END
END
But after Execution got following Errors
Msg 137, Level 15, State 2, Line 2
Must declare the scalar variable "@transaction_type".
Msg 137, Level 15, State 2, Line 19
Must declare the scalar variable "@list_of_cols_val_tab_del".
Msg 137, Level 15, State 1, Line 22
Must declare the scalar variable "@error".
Msg 137, Level 15, State 1, Line 23
Must declare the scalar variable "@error_message".
Please Help
Regards
HitulHi Hitul,
Please check Snapshot.
Please see Red Lines for SBO_SP_TransactionNotification Procedure.
Paste your code below ADD YOUR CODE HERE.
Hope this help
Regards::::
Atul Chakraborty -
Hi,
I am getting an error: "Database error Must declare the Scalar variable *@prompt*.. (IES 10901)".
backend: SQLServer
The dim, Lovs are valid in IDT universe.
There is a Fiscal Year Month Dim in Universe=SELECT
cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int)
FROM "COST_SUMMARY_FACT_VR"
Lov
There are two LOVs FP_From, FP_To
1) FP_From= select distinct cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int) from COST_SUMMARY_FACT_VR order by 1
2) FP_To=select distinct cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int) from COST_SUMMARY_FACT_VR order by 1
Prompts
There are two universe prompts
1) FP_From is Numeric and LOV FP_From is attached
2) FP_To is Numeric and LOV FP_To is attached
Using the universe prompts in webi as
Fiscal Year Month between FP_From and FP_To
Qry is executing perfectly in backend.In addition to Visakh's solution: the reason you got the error message is because the piece of dynamic SQL is not part of the stored procedure, but constiutes a scope of its own. Thus variables declared in the surrounding procedure are not visible.
Also, you should the dynamic SQL this way:
SET @sql = N'
SELECT @Result=COUNT( Id ) FROM ' + quotename(@TableName) +
' WHERE RunRegisterKey=@ID'
SET @Params = N'@Result int OUTPUT, @ID int'
EXEC sys.sp_executesql @sql,@Params,@Result = @Result OUT, @ID = @ID
That is, use quotename for the table name, in case you have a table named
sys.objects; SHUTDOWN WITH NOWAIT; --
Furthermore, pass @ID as a parameter rather than concatenating it to the string. It is both easier and safer.
Erland Sommarskog, SQL Server MVP, [email protected] -
Must declare the scalar variable
I Am getting error as Must declare the scalar variable "@Imageid" for the following code,while executing,
exec spGetPager ' ' , ' ', ' 3 ', ' '
In my coding I pass querystring value like 1,2,3 etc
CREATE PROCEDURE spGetPager
@PageNo int = 1,
@ItemsPerPage int = 1,
@Imageid int,
@TotalRows int out
AS
BEGIN
SET NOCOUNT ON
DECLARE
@StartIdx int,
@SQL nvarchar(max),
@SQL_Conditions nvarchar(max),
@EndIdx int
IF @PageNo < 1 SET @PageNo = 1
IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
SET @SQL = 'SELECT Imageid,Imagepath,imagename,username
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
FROM Imageupload ) AS tbl WHERE Imageid=@Imageid AND Row >= '
+ CONVERT(varchar(9), @StartIdx) + ' AND
Row <= ' + CONVERT(varchar(9), @EndIdx)
EXEC sp_executesql @SQL
SET @SQL = 'SELECT @TotalRows=COUNT(*) FROM Imageupload'
EXEC sp_executesql
@query = @SQL,
@params = N'@TotalRows INT OUTPUT',
@TotalRows = @TotalRows OUTPUT
END
Thanks in Advanceyou cant use variable directly in concatenation operator as its of type int. you need to cast it first as below
CREATE PROCEDURE spGetPager
@PageNo int = 1,
@ItemsPerPage int = 1,
@Imageid int,
@TotalRows int out
AS
BEGIN
SET NOCOUNT ON
DECLARE
@StartIdx int,
@SQL nvarchar(max),
@SQL_Conditions nvarchar(max),
@EndIdx int
IF @PageNo < 1 SET @PageNo = 1
IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
SET @SQL = 'SELECT Imageid,Imagepath,imagename,username
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
FROM Imageupload ) AS tbl WHERE Imageid=' + CAST(@Imageid AS varchar(50)) + ' AND Row >= '
+ CONVERT(varchar(9), @StartIdx) + ' AND
Row <= ' + CONVERT(varchar(9), @EndIdx)
EXEC sp_executesql @SQL
SET @SQL = 'SELECT @TotalRows=COUNT(*) FROM Imageupload'
EXEC sp_executesql
@query = @SQL,
@params = N'@TotalRows INT OUTPUT',
@TotalRows = @TotalRows OUTPUT
END
That being I didnt understand why you need dynamic sql here. There's no dynamicity involved as i see
you could simply use a sql like below
CREATE PROCEDURE spGetPager
@PageNo int = 1,
@ItemsPerPage int = 1,
@Imageid int,
@TotalRows int out
AS
BEGIN
SET NOCOUNT ON
DECLARE
@StartIdx int,
@EndIdx int
IF @PageNo < 1 SET @PageNo = 1
IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
SELECT Imageid,Imagepath,imagename,username
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
FROM Imageupload ) AS tbl WHERE Imageid=@Imageid
AND Row >= @StartIdx
AND Row <= @EndIdx
SELECT @TotalRows=COUNT(*) FROM Imageupload
END
to achieve same requirement.
Make sure you read
http://www.sommarskog.se/dynamic_sql.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Must declare the scalar variable error
I am getting the error "Must declare the scalar variable "@Result"" when i execute the below query
declare @sql nvarchar(max),
@tablename varchar(200),
@Id int,
@Result int
set @tablename='xyz'
set @id=1
SET @sql = '
SELECT @Result=COUNT( Id ) FROM ' + @TableName+ ' WHERE RunRegisterKey=' +convert(nvarchar(100),@ID)
EXEC sys.sp_executesql @sqlIn addition to Visakh's solution: the reason you got the error message is because the piece of dynamic SQL is not part of the stored procedure, but constiutes a scope of its own. Thus variables declared in the surrounding procedure are not visible.
Also, you should the dynamic SQL this way:
SET @sql = N'
SELECT @Result=COUNT( Id ) FROM ' + quotename(@TableName) +
' WHERE RunRegisterKey=@ID'
SET @Params = N'@Result int OUTPUT, @ID int'
EXEC sys.sp_executesql @sql,@Params,@Result = @Result OUT, @ID = @ID
That is, use quotename for the table name, in case you have a table named
sys.objects; SHUTDOWN WITH NOWAIT; --
Furthermore, pass @ID as a parameter rather than concatenating it to the string. It is both easier and safer.
Erland Sommarskog, SQL Server MVP, [email protected] -
Where can I declare a final variable?
I'm wondering where excatly I can declare a final variable. I know I can declare them right after I start the class.
i.e.:
public class x {
public static final Scanner CONSOLE = new Scanner(System.in);
public static final Random GENERATOR = new Random();
}I would like to declare a final within the main method. i.e.:
public static void main(String[] args) {
System.out.print("Please type in your name and press return: ");
final String NAME = CONSOLE.next();
}Is this just not possible or am I just writing it wrong? Couldn't find an example using google. Any help?
fyi: I'm fairly new to using java so this may be obvious.public static void main(String[] args) {
System.out.print("Please type in your name and
nd press return: ");
final String NAME = CONSOLE.next();
}Is this just not possible or am I just writing it
wrong?No, you can declare a local variable final, which means that it's value can only be set once in or after the declaration. But be aware that a new variable is created each time the method is invoked.
About the only reason people do this is so it can be used in a local class declared further down the method. -
How do I declare the extra variable?
List the customer number, name, (first and last), order number, order date, employee number, employee, name (first and last), product number, product name, and order cost, (orderline.qty*prodprice) for products ordered on January 23, 2009
I have no column called order cost in any tables. How do I declare a new variable called order cost in the query? And to date line is missing a right parenthesis. The exact line worked with a different question but accept that I have added on the date in this line.
SELECT C.CUSTNO, C.CUSTFIRSTNAME, C.CUSTLASTNAME, O.ORNO, O.ORDDATE, E.EMPNO, E.EMPFIRSTNAME, E.EMPLASTNAME, P.PRODNO, P.PRODNAME, L.PRODNO, L.QTY, Order_cost
From Customer c, Orders o, ORDERLINE L, Employee e, Product P
where(C.CUSTNO=O.CUSTNO) and(O.EMPNO = E.EMPNO) and (O.ORDNO = L.ORDNO) and (P.PRODNO = L.PRODNO) and Order_cost= (L.QTY*ProdPrice)
and (o.OrdDate >= to_date('23/01/2009', 'dd/'mm/yyyy') and o.OrdDate <= add_months(to_date('23/01/2009','dd/'mm/yyyy'),+1)-1);
Thanks.Hi,
user9164240 wrote:
List the customer number, name, (first and last), order number, order date, employee number, employee, name (first and last), product number, product name, and order cost, (orderline.qty*prodprice) for products ordered on January 23, 2009
I have no column called order cost in any tables. How do I declare a new variable called order cost in the query? And to date line is missing a right parenthesis. The exact line worked with a different question but accept that I have added on the date in this line.
SELECT C.CUSTNO, C.CUSTFIRSTNAME, C.CUSTLASTNAME, O.ORNO, O.ORDDATE, E.EMPNO, E.EMPFIRSTNAME, E.EMPLASTNAME, P.PRODNO, P.PRODNAME, L.PRODNO, L.QTY, Order_cost
From Customer c, Orders o, ORDERLINE L, Employee e, Product P
where(C.CUSTNO=O.CUSTNO) and(O.EMPNO = E.EMPNO) and (O.ORDNO = L.ORDNO) and (P.PRODNO = L.PRODNO) and Order_cost= (L.QTY*ProdPrice)
and (o.OrdDate >= to_date('23/01/2009', 'dd/'mm/yyyy') and o.OrdDate <= add_months(to_date('23/01/2009','dd/'mm/yyyy'),+1)-1);Never write, let alone post, unformatted code.
Format your code so that it's easy to see (among other things) that
(1) the arguments to TO_DATE match each other, and
(2) parentheses are balanced.
For example:
SELECT C.CUSTNO
, C.CUSTFIRSTNAME
, C.CUSTLASTNAME
, O.ORNO
, O.ORDDATE
, E.EMPNO
, E.EMPFIRSTNAME
, E.EMPLASTNAME
, P.PRODNO
, P.PRODNAME
, L.PRODNO
, L.QTY
, L.QTY * ProdPrice AS Order_cost
From Customer c
, Orders o
, ORDERLINE L
, Employee e
, Product P
where (C.CUSTNO = O.CUSTNO)
and (O.EMPNO = E.EMPNO)
and (O.ORDNO = L.ORDNO)
and (P.PRODNO = L.PRODNO)
and (o.OrdDate >= to_date ( '23/01/2009'
, 'dd/'mm/yyyy' -- WRONG! Look at alignment
and o.OrdDate <= add_months ( to_date ( '23/01/2009'
, 'dd/'mm/yyyy' -- WRONG! Look at alignment
, +1
) -1
) -- Extra right parentheses
;When you post formatted text on this site, type these 6 characters
\(all small letters, inside curly brackets) before and after each section of formatted text. If you don't, this site will not show all the extra spaces. -
I was using the "configure Alarms" and "configure Logging" VIs to design two user interfaces to make use of these VIs when I came across a problem. In both VIs you can enable logging of alarms. So which one is valid? Which one has priority? Then I looked at the "Shared Variable Properties" built into the project explorer. Now I realize that I am spending all of this time redesigning this properties dialog (which also has two options of enabling logging of alarms (on the Alarms tab to the far right side as well as on the Logging tab). So now my question is, how do I access this "Shared Variable Properties" dialog through my program (Note: this would be on a different machine than where the shared variables are set up. The point is to configure shared variables remotely).
Thanks
MattHere is a VI I re-created and posted for all. I'm not sure why NI doesn't provide their VI to the developer. The only thing I can't figure out is that when reading in the "Ack Type" into a variable, it generates an error. It will work if you go into "project explorer" and right click on the library with the shared variable and "deploy" but eventually stops working. I have tried using the "undeploy library" and "deploy library" to see if this would be a work around but had no success.
Just pipe the path of the shared variable into the vi.
Mattk
Attachments:
Shared Variable Properties.vi 95 KB -
USE [NC_DB]
GO
/****** Object: StoredProcedure [dbo].[S_EDIT_USER] Script Date: 12/23/2013 12:32:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[S_EDIT_USER]
( @DSA_CODE VARCHAR(10)
,@REQUESTOR_DEPT VARCHAR(40)
,@ACTIVE_STATUS INT
,@MAKER_ID VARCHAR(10)
,@MAKER_IP VARCHAR(20)
,@ERROR_CODE INT OUTPUT
AS
BEGIN
DECLARE @CNT INT;
DECLARE @SQL NVARCHAR(MAX);
--DECLARE @REQUESTOR_DEPT VARCHAR(40);
--print(@REQUESTOR_DEPT);
SELECT @CNT = COUNT(*) FROM TMAS_UAM_USER_TMP WHERE DSA_CODE = @DSA_CODE;
IF @CNT > 0
SET @ERROR_CODE = 1;
ELSE
SET @ERROR_CODE = 0;
if @REQUESTOR_DEPT = 'N'
SET @REQUESTOR_DEPT = '';
ELSE
SET @REQUESTOR_DEPT = @REQUESTOR_DEPT ;
print @REQUESTOR_DEPT;
IF @ERROR_CODE = 0
set @SQL = 'INSERT INTO TMAS_UAM_USER_TMP (
DSA_CODE
,DSA_NAME
,DSA_CITY
,DSA_PRODUCT
,DSA_PHNO
,DSA_MOBNO
,DSA_RQSTR
,DSA_RQSTR_DEPT
,GROUP_ID
,ACTIVE_STATUS
,REQ_TYPE
,LAST_LOGED_IN
,CREATED_ID
,CREATED_IP
,CREATED_DATE
,MAKER_ID
,MAKER_IP
,MAKER_DATE
) SELECT DSA_COD
,DSA_NAM
,DSA_CTY
,PRODUCT
,DSA_PHO
,DSA_MOB
,REQUESTOR
,'+@REQUESTOR_DEPT+'
,GROUP_ID
,@ACTIVE_STATUS
,1
,LAST_LOG_DAT
,CREATED_ID
,CREATED_IP
,CREATED_DATE
,'+@MAKER_ID+'
,'+@MAKER_IP+'
,GETDATE()
FROM DSA_MST WHERE DSA_COD = '+@DSA_CODE+' and ';
if @REQUESTOR_DEPT = 'N'
begin
set @SQL = @SQL + 'REQUESTOR_DEPT is null';
print('If Query'+@SQL);
end
else
begin
set @SQL = @SQL + 'REQUESTOR_DEPT = ''' + @REQUESTOR_DEPT + '''';
print('Else Query'+@SQL);
end
--EXEC sp_executesql @SQL, N'@REQUESTOR_DEPT varchar(100) output', @REQUESTOR_DEPT output
--EXECUTE sp_executesql @SQL;
execute (@SQL);
RETURN @ERROR_CODE;
ENDThe problem is that you are using dynamic SQL which you should not. Use the
below instead. Uncomment the query hint if you are worried about
performance.
ALTER PROCEDURE [dbo].[S_EDIT_USER]
( @DSA_CODE VARCHAR(10)
,@REQUESTOR_DEPT VARCHAR(40)
,@ACTIVE_STATUS INT
,@MAKER_ID VARCHAR(10)
,@MAKER_IP VARCHAR(20)
,@ERROR_CODE INT OUTPUT
AS
BEGIN
DECLARE @CNT INT;
--DECLARE @REQUESTOR_DEPT VARCHAR(40);
--print(@REQUESTOR_DEPT);
SELECT @CNT = COUNT(*) FROM TMAS_UAM_USER_TMP WHERE DSA_CODE = @DSA_CODE;
IF @CNT > 0
SET @ERROR_CODE = 1;
ELSE
SET @ERROR_CODE = 0;
if @REQUESTOR_DEPT = 'N'
SET @REQUESTOR_DEPT = '';
ELSE
SET @REQUESTOR_DEPT = @REQUESTOR_DEPT ;
print @REQUESTOR_DEPT;
IF @ERROR_CODE = 0
INSERT INTO TMAS_UAM_USER_TMP (
DSA_CODE
,DSA_NAME
,DSA_CITY
,DSA_PRODUCT
,DSA_PHNO
,DSA_MOBNO
,DSA_RQSTR
,DSA_RQSTR_DEPT
,GROUP_ID
,ACTIVE_STATUS
,REQ_TYPE
,LAST_LOGED_IN
,CREATED_ID
,CREATED_IP
,CREATED_DATE
,MAKER_ID
,MAKER_IP
,MAKER_DATE
) SELECT DSA_COD
,DSA_NAM
,DSA_CTY
,PRODUCT
,DSA_PHO
,DSA_MOB
,REQUESTOR
,'+@REQUESTOR_DEPT+'
,GROUP_ID
,@ACTIVE_STATUS
,1
,LAST_LOG_DAT
,CREATED_ID
,CREATED_IP
,CREATED_DATE
,'+@MAKER_ID+'
,'+@MAKER_IP+'
,GETDATE()
FROM DSA_MST
WHERE DSA_COD = @DSA_CODE
and (REQUESTOR_DEPT = @REQUESTOR_DEPT OR @REQUESTOR_DEPT = 'N')
-- OPTION (RECOMPILE)
END
Erland Sommarskog, SQL Server MVP, [email protected] -
Error must declare the scalar variable
por que me marca ese error una consulta?
DECLARE @feci AS datetime
DECLARE @fecf AS datetime
SET @FECI=(SELECT DISTINCT(T0.DOCDATE) FROM ORTT T0 WHERE T0.DOCDATE='[%0]')
SET @FECF=(SELECT DISTINCT(T0.DOCDATE) FROM ORTT T0 WHERE T0.DOCDATE='[%1]')
EXEC DBO.COMPARATIVO @FECI,@FECF
Edited by: mary merecias on Nov 17, 2011 3:15 PMel codigo no, son las variables. si pongo este código me marca que no tiene un select MUST SPECIFY TABLE TO SELECT FROM
Declare @fec1 as datetime
Declare @fec2 as datetime
SET @fec1=[%0]
SET @fec2=[%1]
SELECT DISTINCT(T0.itemcode),T0.itemname,T0.onhand,
(SELECT SUM(PCH1.linetotal) AS TOTAL
FROM OPCH
INNER JOIN pch1 on OPCH.docentry=PCH1.docentry
INNER JOIN OITM ON OITM.ITEMCODE=PCH1.ITEMCODE
WHERE pch1.targettype<>'19' and OITM.itemcode=T0.ITEMCODE AND OPCH.DOCDATE>=@FEC1 AND OPCH.DOCDATE<=@fec2)AS 'TOTAL COMPRAS',
(SELECT SUM(PCH1.QUANTITY) AS TOTAL
FROM OPCH
INNER JOIN pch1 on OPCH.docentry=PCH1.docentry
INNER JOIN OITM ON OITM.ITEMCODE=PCH1.ITEMCODE
WHERE pch1.targettype<>'19' and OITM.itemcode=T0.ITEMCODE AND OPCH.DOCDATE>=@fec1 AND OPCH.DOCDATE<=@fec2 ) AS 'PIEZAS COMPRADAS',
(SELECT SUM(INV1.linetotal) AS TOTAL
FROM OINV
INNER JOIN INV1 on OINV.docentry=INV1.docentry
INNER JOIN OITM ON OITM.ITEMCODE=INV1.ITEMCODE
WHERE INV1.targettype<>'14' and OITM.itemcode=T0.ITEMCODE AND OINV.DOCDATE>=@fec1 AND OINV.DOCDATE<=@fec2)AS 'TOTAL VENTAS',
(SELECT SUM(INV1.QUANTITY) AS TOTAL
FROM OINV
INNER JOIN INV1 on OINV.docentry=INV1.docentry
INNER JOIN OITM ON OITM.ITEMCODE=INV1.ITEMCODE
WHERE INV1.targettype<>'14' and OITM.itemcode=T0.ITEMCODE AND OINV.DOCDATE>=@fec1 AND OINV.DOCDATE<=@fec2 ) AS 'PIEZAS VENDIDAS'
FROM OITM T0
GROUP BY T0.itemcode,T0.itemname,T0.onhand
en SQL SERVER si funciona bien
Edited by: mary merecias on Nov 17, 2011 4:50 PM
Edited by: mary merecias on Nov 17, 2011 4:51 PM
Edited by: mary merecias on Nov 17, 2011 4:53 PM -
How to get the return value of a method
hi there
here is the code i write a method
public void time(int x,int y){
int xx;
int yy;
xx++;
yy++;
x=xx;
y=yy;
i want to use the return value of x and y at another place,who can tell if it is possible. thank u very muchYou declare the return type of the method, and then use the return keyword to return a value which you can assign to a variable.
As the other respondent said, you cannot return more than one value from a function. If you need to return two related values, you may want to enclose them in a class and return an instance of that class. For instance:
class TimeValue {
final int x;
final int y;
public TimeValue(int x, int y) {
this.x = x;
this.y = y;
}Then your method could create a new TimeValues and return it:
public TimeValue time(int x,int y){
int xx = x;
int yy = y;
++xx;
++yy;
return new TimeValue(xx, yy);
} -
DB adapter not returning return variable from database function
Hi,
We are calling a function using db adapter from our BPEL Process. It worked fine in 10.1.3.3.
after we migrated to 10.1.3.4 MLR# 8 , we are not able to see the return variable which function is returing.
Function is working fine when executed standalone. Its returing the variable. But we are not able to see that variable in bpel process invoke response variable. This is causing issue.
Any idea what causing the issue.
ThanksCheck your XSD to see if it is qualified (elementFormDefault="qualified") or unqualified. The XSDs were unqualified in 10.1.3.3. They became qualified in 10.1.3.4. If you have an unqualified XSD and you're using a 10.1.3.4 runtime you will likely have namespace issues that cause problems with the generated XML. The solution is to regenerate your XSD so that it becomes qualified.
-
Why do we declare the variables private in a bean
Hi,
when we create a bean in the MVC architecture why do we declare the variables private. Also when do we use the access specifier private.
Regards,
Prashantpksingh79 wrote:
Hi ^^,
thanks for replying.I had a discussion with one of my trainers and he was of the opinion that the variables should generally be declared private. In this way we prevent classes from accessing and setting illegal values to those variables.
Say for instance we have the class person as follows:
public class Person
int age;
setAge(int age)
if (age < 0)
return null
Person p = new Person() ;
p.age = -2;
//this would be perfectly legal
//where as if we declare the variable as private as follows:
public class Person
private int age;
setAge(int age)
if (age < 0)
return null
Person p = new Person() ;
// P.age = -2; this would be illegal as age is private and would have to be accessed by the method defined above.
p.setAge(-2);
//the cbove line would retun null values.
public class Person {
private int age;
public void setAge(int age) {
if (age < 0) {
throw new IllegalArgumentException("...");
this.age = age;
} -
Where are the BEx variable stored
Hi All,
I have couple of doubts. I would appreciate, if some one can through some light on these.
1. Where does all the BEx variables stored, if they are stored in BW, then in which transparent tables these are stored.
2. Where does the properties of the BEx InfoObject in the BEX Query are stored, if they are stored in BW, then in which transparent tables these are stored.
Thanks in advance,
CKHi Sudheer,
Are you ready for have some fun?!?
With BW Analyzer loaded and one of your BW workbooks open in Excel do the following:
First, launch the Visual Basic Editor. You do this either on the Excel Menu Bar (Tools >> Macro >> Visual Basic Editor); or, by pressing Alt + F11.
Be sure that the Project Explorer Window is visible. If not, on the VB Editor toolbar select View >> Project Explorer; or, press Ctrl + R.
Projects are listed alphabetically. Probably the first object you see in the Project list is SAPBEX(sapbex.xla). This is the BW Analyzer. You can't open it, but you can explore it using the VB Editor Object Browser. More about that later.
For now, locate your workbook. It will probably be named VBAProject(name of workbook.xls). If there is a "+" to the left of the project name, click on the + to expand it.
You will see at least two types of objects:
+ Microsoft Excel Objects
+ Modules
Expand them both.
Among the Microsoft Excel Objects, you will see worksheets, maybe charts, and the object for the workbook itself (ThisWorkbook).
Each sheet has two names. The first is the codename. The second is the name you see on the tabs when you are in Excel.
Notice that there are two more worksheets here than you see in Excel. One of these has a "tab name" of SAPBEXqueries; the other is named SAPBEXfilters.
There is nothing you can do in Excel to make these sheets visible. They are not ordinary hidden worksheets.
There are two ways you can make them visible:
1. using the Properties Window
2. using Visual Basic code
If the Properties Window is not visible, on the VB Editor toolbar select View >> Properties Window; or, press F4. Double-click on the worksheet object to select it. Then, change the Visible Property to Visible.
Or, use this line of code (for example):
Sheets("SAPBEXqueries").Visible = True
to return it to its original condition, the VBA command is:
Sheets("SAPBEXqueries").visible = xlSheetVeryHidden
Now I must tell you that anything you do from this point on is not covered by your warranty. Don't worry, you can't break BW. But, you can create a beautiful report that stops working with the next system patch that gets installed.
Now that you are looking at these sheets, you probably would like to have a guide as to what they contain. I posted some of that a few months ago. I can't locate the posting right now. You can do a search on my name to find it. Or, if you wait, I'll find it and post the link to this thread.
But ... there is a better way than reading my old posting. Try this ... refresh a query in Excel. Then, come back to the Visual Basic Editor. Select the BW Analyzer Object ... SAPBEX(sapbex.xla). Then, on the VB Editor menu, select Run >> Run Macro (F5); scroll down to sapbexDebugPrint and run that macro. It will create an amazing workbook that tells you everything you could ever want to know about the query you just refreshed. (Including a complete list of valid OLAP fire commands.)
By comparing the various worksheets in this amazing workbook with the tables in the very-hidden SAPBEXqueries worksheet, you can learn what just about every one of those tables is all about.
But ... before you get too carried away with making changes to the values on those sheets ... I have found that I can do almost everything I need to do without ever needing to touch those very-hidden worksheets.
What I use mostly are the API functions. Some of these are listed in the BW documentation. But, there are about as many API functions that are NOT documented. To find the API functions ... in the VB Editor, select the BW Analyzer object ... SAPBEX(sapbex.xla). Then, select on the VE Editor menu bar, select View >> Object Browser (F2). Change the Library to SAPBEX (this does not work unless you have already selected the SAPBEX oject). In the Classes column, scroll down to xBEXapi. You will now see listed all of the API functions and subroutines.
The Object Browser tells you ALMOST everything you need to know. Most people need a few examples to get them started. You can look at my postings here to find examples. Or, just do a search on "SAPBEX". Almost every hit will lead to a discussion and/or example of these API functions.
When you have more questions, write back.
- Pete
Maybe you are looking for
-
Adobe Photoshop Elements 11 does not open in OS X 10.10 Yosemite
Ever since I upgraded to OS X 10.10 Yosemite, Adobe Photoshop Elements 11 crashes immediately upon launch. The system generates a report that Apple receives. However, it states to contact the developer of the app. I already deleted and reinstalled t
-
The SIM card inserted in this iPhone does not appear to be supported. The SIM card that you currently have installed in this iPhone is from a carrier that is not supported under the activation policy that is currently assigned by the activation serve
-
Hi. Can I see business rules, which were creating in Calculation Manager for Hyperion Planning Application, in Essbase Administration Services Console? Thanks.
-
Iphoto library.tmp file - can i delete it?
I'm wondering if I can go ahead and delete the iphoto library.tmp file. It's over 2.5 GB and it basically seems to be duplicates of photos from 2008. I'm not sure why it's there. Anyone know if it's okay to delete it to free up a few extra GBs?
-
Contribute 2 isn't editing Dreamweaver templage page with frames
Help please. I'm trying to use Contribute 2 to edit a website I created with a Dreamweaver CSS template. When I loaded Contribute, it let me edit the first time I tried. Now I'm getting an error message saying the page has frames and I can't edit i