473,774 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to recompile / refresh UDFs ?

Ben
Hi!
I need to refresh an entire database.

I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

Any help appreciated :) !

Ben

Mar 6 '07 #1
5 14490
Hi Ben,
Hi!
I need to refresh an entire database.

I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

I'm afraid that no such procedure/DBCC command exists to recompile a
function. IMHO the best way to refresh function meta-data is to ALTER
it. That's better solution than dropping and creating (recreating) a
function, because when using ALTER FUNCTION permissions are retained.
--
Best regards,
Marcin Guzowski
http://guzowski.info
Mar 6 '07 #2
Ben (be****@gmail.c om) writes:
I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).
What do you really want to achieve? sp_recompile and FLUSHPROCINDB just
removes plans out the query cache. sp_refreshview on the other hand
reinterprets the definition of the view, and this is necessary if
the view definition has an * in the select list. Thus the two serve
completely different purposes.

IF the problem is that you cannot refresh your inline table functions,
the simple solution is not to use SELECT *, which is generally considered
bad practice.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 6 '07 #3
Ben
What I'm trying to achieve, as I said:
I need to refresh an entire database.
So, all SPs, functions, and views.

The refresh problems arose when I changed a few columns' order : I
still receive all the data from the functions but they're incorrectly
ordered and labelled.
It gets even worse as some functions are nested (say, I select all
valid clients according to dates criteria, then all valid orders from
those clients, etc), or other functions are used in CHECK constraints
and so I SQL Server refuses to alter them, so I have to kil the
constraint, alter the function, and re-create the constraint... nice.

I heard about the "select * is bad practice", but I'm dealing with a
constantly evolving database (not yet in production), so I use a lot
of it to just pump everything and send it back to webpages. And even
if I didn't all that would mean is I'd have to manually go into every
function and update them, which is exactly what I've been doing so far
(open, backspace to alter, save --seems to be the only way to
refresh).

None of this is unsolvable, it just takes unnecessary time (one change
can mean 20 functions to track), and I can't find a way to do it
automatically.
Plus I find it really frustrating to be faced with compile problems
using a language that is supposed to be interpreted!
I get enough trouble updating DLLs, plus at least VS provides the
"recompile all" function...

Maybe if I do enough nagging my boss'll get me a SQL Server 2005.
Would that solve at least some of this?

Cheers, Ben.
On Mar 6, 11:50 pm, Erland Sommarskog <esq...@sommars kog.sewrote:
Ben (ben...@gmail.c om) writes:
I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

What do you really want to achieve? sp_recompile and FLUSHPROCINDB just
removes plans out the query cache. sp_refreshview on the other hand
reinterprets the definition of the view, and this is necessary if
the view definition has an * in the select list. Thus the two serve
completely different purposes.

IF the problem is that you cannot refresh your inline table functions,
the simple solution is not to use SELECT *, which is generally considered
bad practice.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se

Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx

Mar 19 '07 #4
Ben
Thanks, I knew about the ALTER solution, the only problem is I can
only do it manually (in the manager, open each function, backspace to
alter and enable the save button, and save).
Do you know any way to do the same automatically? (refresh ALL
functions, or the ENTIRE database) (PS: I can't rebuild it, have to
keep the data)

Cheers, Ben
On Mar 6, 6:17 pm, "Marcin A. Guzowski"
<tu_wstaw_moje_ i...@guzowski.i nfowrote:
Hi Ben,
Hi!
I need to refresh an entire database.
I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

I'm afraid that no such procedure/DBCC command exists to recompile a
function. IMHO the best way to refresh function meta-data is to ALTER
it. That's better solution than dropping and creating (recreating) a
function, because when using ALTER FUNCTION permissions are retained.

--
Best regards,
Marcin Guzowskihttp://guzowski.info

Mar 19 '07 #5
Ben (be****@gmail.c om) writes:
I heard about the "select * is bad practice", but I'm dealing with a
constantly evolving database (not yet in production), so I use a lot
of it to just pump everything and send it back to webpages. And even
if I didn't all that would mean is I'd have to manually go into every
function and update them, which is exactly what I've been doing so far
(open, backspace to alter, save --seems to be the only way to
refresh).
Not really. If you have everything under version control, or at least
on disk, you can easily run a BAT file that loads all functions it can
find. The database is no place for source code; in my opinion that is
only a container for binaries.

And while it may seem easy to have SELECT *, it does come back and bite
you. As I understood, you got this problem because you changed the column
order. If you had used explicit column lists, you could just have
changed the column lists, and you would have to change the underlying
tables.

I work with a constantly evolving database, for over ten years now. One
thing I hate is to find a stored procedure to return about every column
in a table. Then I have to dig further into the client code so see if
the column I want to drop or redefine is actually use somewhere. So there
are very good reasons to only return the columns that actually are
in use. This makes it much easier to track down where things are used.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2355
by: Andrew Mayo | last post by:
There is something very strange going on here. Tested with ADO 2.7 and MSDE/2000. At first, things look quite sensible. You have a simple SQL query, let's say select * from mytab where col1 = 1234 Now, let's write a simple VB program to do this query back to an MSDE/2000 database on our local machine. Effectively, we'll
16
4210
by: DraguVaso | last post by:
Hi, I have a Windows Service running (made in VB.NET), and wanted to be able to change from time to time some parameters by changing them in the App.config. But it seems that the application doesn't use the changed values in the App.config, but continue to use the values that were there during start-up. Is there a way to let the application use the new values in the App.config? Is there kind of some 'refresh' function that I should...
4
1935
by: Pete H | last post by:
Hi All; I'm trying to get some of the samples that are amply illustrated in multiple docs to work. When I try to create a Warehouse Center view "...for MQ Series messages" or use the UDF wizard in Development Center, I get the following error/warning: ------------------------------------------------------------------------- MQSeries Integration Functions could not be found on the target database. To run the DB2 table UDFs built by this...
7
1587
by: Rhino | last post by:
I am updating some Java UDFs from DB2GENERAL to DB2JAVA as suggested in the manuals for DB2 Version 8 but I'm having problems with setSQLstate() and setSQLmessage(). If I'm reading the manuals correctly, they are only supported in UDFs that use DB2GENERAL. Is that right? If it is, is there any equivalent to these methods for DB2JAVA UDFs? I'd really like to be able to return a message and SQLState of my own choosing. (I know that I...
2
1789
by: MB | last post by:
Hello! At home I am using ASP.net to develop an asp application. Now I have copied this application to my IIS5.0 server at my workplace. Everything works fine, but then I would do a change in a code behind file. I made the changes with notepad, but I can't get it to take affect. Not event restarting IIS solved it. How do I compile or refresh IIS so that my changes takes affect? I do not have VS.Net at my workplace. Where is the running...
3
2308
by: jefftyzzer | last post by:
Friends, Say I have the following UDF: CREATE FUNCTION GET_MONTH(P_DATE DATE) RETURNS INTEGER INHERIT SPECIAL REGISTERS SPECIFIC GET_MONTH DETERMINISTIC BEGIN ATOMIC
0
1403
by: Helmut Tessarek | last post by:
Hi everybody, I've written some UDFs to generate passwords within DB2. They are compatible to the functions that are used in Apache's htpasswd utility. Maybe someone can use them. http://sourceforge.net/project/showfiles.php?group_id=103064&package_id=110695 The UDFS are
6
4857
by: Carsten | last post by:
Hello Folks, I encountered a problem with SQL server 2000 and UDFs. I have a scalar UDF and a table UDF where I would like the scalar UDF to provide the argument for the table UDF like in: SELECT * FROM
0
1443
by: sqldba20 | last post by:
Is there a way (command or stored procedure) to RECOMPILE or REFRESH a USER DEFINED FUNCTION? I can recompile SPs with sp_recompile and refresh views with sp_refreshView, but I could not find any way to refresh User-defined functions (some of them are like views, with parameters). Environment: SQL 2005 SP2. Thanks !
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.