Msg 15197, Level 16, State 1, Procedure sp_helptext, Line 107 - sql-server-2008

I have a procedure named dbo.CLRSPTest which i have encrypted. When I execute the procedure it gets executed but throws an error when I use sp_helptext CLRSPTest to view the code i.e Msg 15197, Level 16, State 1, Procedure sp_helptext, Line 107
There is no text for object 'CLRSPTest'.
Can anyone please help me out??? I am getting puzzled.

This error is raised by the following code in sp_helptext
if (select count(*) from syscomments c, sysobjects o where o.xtype not in ('S', 'U')
and o.id = c.id and o.id = #objid) = 0
begin
raiserror(15197,-1,-1,#objname) b
return (1)
end
This simply means that any object (not a table or system object) which does not have a line in syscomments will return this error.
Encrypted objects have a record in the syscomments table with NULL in the xtext field so they don't get caught by the earlier code. The message you get for those object comes from this query.
if (select count(*) from syscomments where id = #objid and encrypted = 0) = 0
begin
raiserror(15471,-1,-1,#objname)
return (0)
end
Now why do we get an error from the first one and no error for the second one... That can be explained by checking the data in master..sysmessages.
select error, severity, description
from master..sysmessages
where error in (15197, 15471)
and msglangid = 1033
This query returns:
error severity description
15197 16 There is no text for object '%s'.
15471 10 The text for object '%ls' is encrypted.
Here we see that error 15197 has severity 16 and error 15471 has severity 10. On msdn it is explained that error levels 0-9 are not "raised" and that error level 10 gets converted to error level 0 for compatibility reasons.
So to conclude it all. You get this error message because your procedure is a SQL CLR procedure (which don't get any records in the syscomments table)

Related

Use of Postgres Cursor

I have a problem to execute a function using a cursor on 2 table with a lot of data
(version PostgreSQL 11.12)
Here an extract of my function:
-- declaration cursor
curs_fat_contabilita scroll cursor (param_month integer, param_year integer) for
select fc.* from etaly.fat_contabilita fc
join etaly.multilevel_storico ms on fc.fk_mlm_storico = ms.id
where
(ms.year = param_year and ms.month = param_month
and (ms.rivendita > 0.00 or fc.saldo_imponibile <> 0.00) ;
----
begin
--1- open curs_fat_contabilita(_month ,_year);
--2- FOR row_fat_contab in FETCH ALL from curs_fat_contabilita ---
--3- loop
......
......
......
end loop
end
When i execute this function, it remains blocked at line 2 (without error in output).
I check with this script
SELECT * FROM pg_stat_activity WHERE state = 'active';
the process rest in pending.
Any ideas to solve this problem?
Thanks in advance
Nothing idea to resolve

SSIS Execute SQL Task error

I'm having an SSIS package which gives the following error when executed :
Error: 0xC002F210 at Execute SQL Task 1, Execute SQL Task: Executing the query "Declare #POID as Varchar(50)
Set #POID = 636268
..." failed with the following error: "Unable to populate result columns for single row result type. The query returned an empty result set.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Execute SQL Task 1
The package has a single Execute SQL task with the properties listed below :
General Properties
Result Set : Single Row
ConnectionType : OLEDB
Connection : Connected to Server
SQLSourceType : Direct Input
SQL Statement :
Declare #POID as Varchar(50)
Set #POID = 0
SELECT DISTINCT BizTalk_POA_HEADER.PONUMBER, FAN_Suppliers.SupplierName, FAN_Company_Details.CompanyName, FAN_Company_Details.[PrimaryEmail], BizTalk_POA_HEADER.[DeliveryDate]
FROM BizTalk_POA_HEADER
INNER JOIN FAN_PO_Details ON BizTalk_POA_HEADER.PONUMBER = FAN_PO_Details.PoNumber
INNER JOIN FAN_PO ON FAN_PO_Details.PurchaseOrderID = FAN_PO.PurchaseOrderID
INNER JOIN FAN_SupplierDetails ON FAN_PO.SupplierDetailsID = FAN_SupplierDetails.SuppliersDetailsID
INNER JOIN FAN_Suppliers ON FAN_SupplierDetails.SupplierID = FAN_Suppliers.SupplierID
INNER JOIN FAN_Company_Details ON FAN_PO.CompanyID = FAN_Company_Details.CompanyDetailsID
WHERE (BizTalk_POA_HEADER.PONUMBER = #POID)**
IsQueryStorePro : False
BypassPrepare : False
Parameter Mapping Properties
None
ResultSet
ResultName Variable Name
0 User:PONUMBER
1 User:StoreName
2 User:StoreEmail
3 User:Supplier
4 User:DeliveryDate
I would appreciate if anybody can help me out of this issue by suggeting where the problem is.
I then changed my query to the following as the above was showing conversion error in SSMS, when I try to include the below in Execute SQL Task the query isn't saved , any reason?
SELECT DISTINCT BizTalk_POA_HEADER.PONUMBER,FAN_Suppliers.SupplierName, FAN_Company_Details.CompanyName,
FAN_Company_Details.[PrimaryEmail], BizTalk_POA_HEADER.[DeliveryDate]
FROM BizTalk_POA_HEADER INNER JOIN
FAN_PO_Details ON CAST(BizTalk_POA_HEADER.PONUMBER AS VARCHAR(128)) = CAST(FAN_PO_Details.PoNumber AS VARCHAR(128)) INNER JOIN
FAN_PO ON FAN_PO_Details.PurchaseOrderID = FAN_PO.PurchaseOrderID INNER JOIN
FAN_SupplierDetails ON FAN_PO.SupplierDetailsID = FAN_SupplierDetails.SuppliersDetailsID INNER JOIN
FAN_Suppliers ON FAN_SupplierDetails.SupplierID = FAN_Suppliers.SupplierID INNER JOIN
FAN_Company_Details ON FAN_PO.CompanyID = FAN_Company_Details.CompanyDetailsID
Thanks in Advance.
If 0 records are returned from your query and you are trying to populate a result set, that is the error you will get. Change your query so it always returns a single result and the error will go away.

Conversion failed when converting the nvarchar value '7575932.' to data type int

I have this legacy code that started failing…
UPDATE B2C
SET B2C.dborderid = A.order_number__c
FROM b2csf B2C
JOIN Alemania A ON B2C.actualid = A.salesforce_id
I get this error:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '7201799-' to data type int.
I went ahead and changed it to:
UPDATE B2C
SET B2C.dborderid = (CASE
WHEN Isnumeric (a.order_number__c) = 1
THEN CAST(a.order_number__c AS INT)
END)
FROM b2csf B2C
JOIN Alemania A ON B2C.actualid = A.salesforce_id
And now I get
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '7575932.' to data type int.
My questions now are:
how can I avoid this error? I don’t mind for example losing '7575932.' value.(Ideally I would like to discard '7575932.' value)
I am trying my best to follow best practices... is changing the column DBorderid to nvarchar the only "best practice" alternative?
(I am using SQL Server 2008)
Instead of ... WHEN Isnumeric (a.order_number__c) = 1 ... use ... WHEN Isnumeric (a.order_number__c + '.0e0') = 1 ...

sqlserver Stop executing on any error

I want to stop executing on any error occured with out using "try catch",why some errors stop executing while others dont do Examples
Example 1:
select 5;
exec( 'select * from tttt') ; -- tttt is not table
select 6
I can sett in result
5 and 6 and Error Msg Msg 208, Level 16, State 1, Line 1 Invalid object name 'tttt'
in this case I want to skip out
Example 2:
select 5;
update t1 set ID=1 ;--ID is Primary Key
select 6
the result is only Error Msg
Msg 8102, Level 16, State 1, Line 3,Cannot update identity column 'ID'.
I know Example2 Error is on compilation time and Example1 Error is on executing time, But this is just example what I want.
for Example 1 I want the result to be 5 , Error Msg Msg 208 without continuing exeuting to return 6, All that without using try catch or raiseerror or comapring ##ERROR=0

Next value function error

I get the following error during postgresql execution:
ERROR [HY000] ERROR: you can only use a 'next value(s)' function within a target list
What is wrong with this sql statement:
SELECT TRFCON.ID
,
case when DDDCON.ID_CON = 0
then
NEXT VALUE FOR SEQ_DDD_CON
else
DWHCON.ID_CON
end ID_CON
FROM TTT_CONSUMPTION TTTCON
join DDDDWH_CON DWHCON on TTTCON.ID_ORG = DDDCON.ID_ORG
and TTTCON.ID_PRO = DDDCON.ID_PRO
and TTTCON.ID_REF = DDDCON.ID_REF
The DDL of the sequence is the following:
CREATE SEQUENCE SEQ_DDD_CON AS BIGINT
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
NO CYCLE;
From the docs for CREATE SEQUENCE
Compatibility
CREATE SEQUENCE conforms to the SQL standard, with the following exceptions:
[...]
Obtaining the next value is done using the nextval() function instead of the standard's NEXT VALUE FOR expression.