2
голосов
4ответов
11911 просмотров

How to create a user defined function in sybase?

I trying to define a function in sybase. I write this script: CREATE FUNCTION GetUserGroup (userId int) RETURNS int BEGIN RETURN (10) END but when I run this, I get this error: >[Error] Script lines: 1-6 -------------------------- Incorrect syntax near the keyword 'BEGIN'. Msg: 156, ...

0
голосов
6ответов
227 просмотров

My PHP Function isn't working

I'm having trouble with the following code. What it should do is echo cats.php followed by example.php but it's not echoing the example.php. Any ideas why this might be happening? $bookLocations = array( 'example.php', 'cats.php', 'dogs.php', 'fires.php', 'monkeys.php', '...

-1
голосов
1ответов
188 просмотров

Can any one suggest me how to resolve this problem: Error Code : 1064 in MY SQL 5.5 ver

DELIMITER $$; DROP FUNCTION IF EXISTS tonumeric $$; CREATE FUNCTION tonumeric() returns numeric BEGIN declare num numeric; set num = to_number('12'); return num; END$$ DELIMITER; $$ When I executed this function, I am facing this error. Error Code : 1064 You have an error in your S...

5
голосов
4ответов
5626 просмотров

SQL Server: Inline Table-Value UDF vs. Inline View

I'm working with a medical-record system that stores data in a construct that resembles a spreadsheet--date/time in column headers, measurements (e.g. physician name, Rh, blood type) in first column of each row, and a value in the intersecting cell. Reports that are based on this construct often...

1
голосов
1ответов
719 просмотров

How to get around UDF restriction on side-effecting operators?

Microsoft Books Online (BOL) on Using Change Data explains a misleading error messages for cdc.fn_cdc_get_all_changes_* & cdc.fn_cdc_get_net_changes_* when an invalid, out-of-range LSN (Log Sequence Number) has been passed to them. Msg 313, Level 16, State 3, Line 1 An insufficient number...

0
голосов
2ответов
550 просмотров

SQL Server StoredProc vs UDF inline table

I have written a complex query that will return me a list of IDs. Now I want to re-use this query so that I join the results with another query. For that I plan to put this into a Stored Proc or an UDF and then use it to insert into a temp table. Something like below 1) Put the query in a Store...

0
голосов
1ответов
316 просмотров

Deploy unsafe assembly to production in SQL Server 2005

I need to deploy an unsafe UDF assembly to a SQL Server 2005. I'm using C# and Visual Studio 2008. I need to know what are the steps that I need to take to allow smooth deployment of unsafe assembly to the client's machine - the client's DBA is a very strict fellow, so I need to satisfy him with ...

149
голосов
9ответов
65151 просмотров

How to report an error from a SQL Server user-defined function

I'm writing a user-defined function in SQL Server 2008. I know that functions cannot raise errors in the usual way - if you try to include the RAISERROR statement SQL returns: Msg 443, Level 16, State 14, Procedure ..., Line ... Invalid use of a side-effecting operator 'RAISERROR' within a funct...

2
голосов
3ответов
1163 просмотров

How does SQL server evaluate the cost of an execution plan which contains a user defined function?

I have a stored procedure which filters based on the result of the DATEADD function - My understanding is that this is similar to using user defined functions in that because SQL server cannot store statistics based on the output of that function it has trouble evaluating the cost of an execution...

2
голосов
4ответов
3811 просмотров

C/C++ Libraries for reading from Universal Disk Format devices or files

Are there any good free C/C++ libraries that enable reading from common devices with filesystems such as UDF, and ISO9660 and extracting files/metadata etc.? So far all I've been able to find is GNUs libcdio which is promising, and some "Magic UDF" which has so many hits I'm disgusted, pushes ot...

0
голосов
1ответов
347 просмотров

UDF which auto-switches between text and base64 xml attributes

My application serializes data into various XML attributes, and depending on data it might send it as text, or as base64. In the latter case, attribute name will be "attribute-base64". So, on SQL server side it is possible to use following convention to decode XML: declare @DataXml xml set @Data...

1
голосов
1ответов
849 просмотров

SQL - Select statement using LastIndex

I have a resultset which has ProductURL stored : accessoires/abc/285/P187654 accessoires/abc/285/D18765432 accessoires/abc/285/A1876543 I need to get the final part of the URL i.e. anything that is after the final '/' that appears in the URL. I have a function which gives me the LASTINDEX : ...

5
голосов
1ответов
1985 просмотров

Table Valued Function where did my query plan go?

I've just wrapped a complex SQL Statement in a Table-valued function on SQLServer 2000. When looking at the Query Plan for a SELECT * FROM dbo.NewFunc it just gives me a Table Scan of the table I have created. I'm guessing that this is because table is created in tempdb and I am just selecting f...

16
голосов
6ответов
26598 просмотров

SQL massive performance difference using SELECT TOP x even when x is much higher than selected rows

I'm selecting some rows from a table valued function but have found an inexplicable massive performance difference by putting SELECT TOP in the query. SELECT col1, col2, col3 etc FROM dbo.some_table_function WHERE col1 = @parameter --ORDER BY col1 is taking upwards of 5 or 6 mins to c...

1
голосов
2ответов
571 просмотров

How to retrieve metadata for return values of an sql server inline table-valued function?

It's not in INFORMATION_SCHEMA.COLUMNS, so where is it? This is a schemabound inline table valued function, so it doesn't have the issues which a stored procedure might have in being able to vary its output schema(s) based on parameters.

0
голосов
2ответов
182 просмотров

What is the great wisdom in defining your own object if I can't do this?

This is for Excel and VBA. Assume that BondClass has been properly defined in a Class Module. I get a #VALUE! when I type "=GetBondPrincipal()" into an Excel cell. Have I done something syntactically wrong or is this just not possible in Excel/VBA? I ask because what I really want to do is this: ...

4
голосов
3ответов
3675 просмотров

Return a User Defined Data Type in an Excel Cell

I've searched the web and I've searched the questions here on stackoverflow, but I haven't been able to find a solution. Here is what I'd like to do: Suppose I have the following code in a class module named "MyClass" Option Explicit Dim var1 as integer Sub Initialize(v as integer) var1 =...

0
голосов
1ответов
533 просмотров

Returning Explicit Open XML results sets from a Table Value Function

I'm trying to return rows in Open XML form from a table value function in SQL Server (2008). I'm occasionally getting errors when I select the results with "for xml explicit" which suggest that the order of the results is not guaranteed to be the same as the order I insert into the output of the ...

0
голосов
3ответов
1634 просмотров

Custom Sorting Function - of SQL Server

I have a column in SQL Server 2005 that stores a version number as a string that i would like to sort by. I have been unable to find out how to sort this column, although i am guessing it would be some kind of custom function or compare algorithm. Can anyone point me in the right direction of wh...

6
голосов
3ответов
7603 просмотров

Call methods written in C# in Excel 2007 from cell formulas

I am using Excel 2007. I have C# code written in a separate binary. The code uses static classes and static methods on the classes. I have a reference to the DLL in my VSTO Excel Worksheet project. What do I have to add or modify to get this to work? My C# code looks like this: using System; us...

1
голосов
1ответов
972 просмотров

Firebird UDF creation failure

I have a firebird database that I need to recreate. It contains an external UDF function. I made an SQL dump of the DB structure using IB Expert: DECLARE EXTERNAL FUNCTION LPAD CSTRING(255), INTEGER, CSTRING(1) RETURNS CSTRING(255) FREE_IT ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_ud...

5
голосов
5ответов
12176 просмотров

User Defined Functions in Excel and Speed Issues

I have an Excel model that uses almost all UDFs. There are say, 120 columns and over 400 rows. The calculations are done vertically and then horizontally --- that is first all the calculations for column 1 are done, then the final output of column 1 is the input of column 2, etc. In each column I...

2
голосов
5ответов
2825 просмотров

String matching in Oracle 10g where either side can have wildcards

Test case schema and data follow as: create table tmp ( vals varchar(8), mask varchar(8) ); insert into tmp values ('12345678',' '); insert into tmp values ('12_45678',' _ '); insert into tmp values ('12345678',' _ '); insert into tmp values ('92345678',' '); inse...

1
голосов
1ответов
576 просмотров

DB2 AS400 Java function always returns same value

I am writing a user defined function to DB2 on AS/400 in Java and the strangest thing happen.. I am always getting the same result from the function even when i am changing it, even if i am dropping it and create it again and even when i specify NOT DETERMINISTIC.. Does any one have ever encounte...

9
голосов
2ответов
15191 просмотров

Error Handling in User Defined Functions

I want to write a non-CLR user-defined function in SQL Server 2005. This function takes an input string and returns an output string. If the input string is invalid, then I want to indicate an error to the caller. My first thought was to use RAISERROR to raise an exception. However, SQL Server d...

3
голосов
1ответов
646 просмотров

metaprogramming with stored procedures?

This is going to be both a direct question and a discussion point. I'll ask the direct question first: Can a stored procedure create another stored procedure dynamically? (Personally I'm interested in SQL Server 2008, but in the interests of wider discussion will leave it open) Now to the reaso...

5
голосов
2ответов
1683 просмотров

UDF Performance in MySQL

I'm noticing exponential performance degradation in MySQL query execution times when queries include calls to UDF's in the SELECT or WHERE clauses. The UDF's in question query local tables to return scalar values - so they're not just performing arithmetic expressions, but serving as correlated ...

0
голосов
1ответов
1859 просмотров

Function in SQL Select Statement

CREATE VIEW View1 AS SELECT Col1, Col2, dbo.fn1(col2) as Col3 FROM TestTable /* --Instead of writing below query I created a new View View2 SELECT Col1, Col2, dbo.fn1(col2) as Col3 dbo.fn2(dbo.fn1(col2)) as Col4 FROM TestTable */...

4
голосов
1ответов
3422 просмотров

Can Excel Conditional Formatting use UDFs in the condition?

I have a cell in Excel that I want to format differently based on a user defined formula (UDF) - my formula tests whether there is a formula in the cell... I am trying to use conditional formatting with my UDF to format the cell - but it does not seem to be working. My condition is this: ="isM...

1
голосов
2ответов
84 просмотров

How can I make a multi search SPROC/UDF by passing a tabled-value to it?

I actually want to achieve the following description This is the table argument I want to pass to the server <items> <item category="cats">1</item> <item category="dogs">2</item> </items> SELECT * FROM Item WHERE Item.Category = <one of th...