Want to convert function in SQL Server 2000

Hi ,
i am writing this function in oracle.Could you please convert this function in SQL Server 2000 because i am new in this and dont know how to use decode function in sql.
Please following is the code for oracle.
CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
return number
as  x number;
begin
select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
   SELECT
                   prereq_count,
                   username
             FROM
                     table1
group by     username ;
return x;
end fun;
Regards
Vishal

Just take a look example below might give you idea :
create or replace function f_makeAddress_tx (
i_address_tx VARCHAR2,
i_city_tx VARCHAR2,
i_state_tx VARCHAR2,
i_zip_tx VARCHAR2)
return VARCHAR2
is
e_badZip EXCEPTION; u279E8
pragma EXCEPTION_init(e_badZip,-20998); u279E9
v_out_tx VARCHAR2(256);
begin
p_validateZip (i_zip_tx); u279E12
v_out_tx:= i_address_tx||u2019, u2018|| u279E13
i_city_tx ||u2019, u2018||
i_state_tx ||u2019, u2018||
i_zip_tx;
return v_out_tx; u279E17
exception
when e_badZip then u279E19
return i_zip_tx || u2018: Invalid zip code.u2019;
end;
Regards,
Clint

Similar Messages

  • CONVERT function in SQL Server to oracle

    All,
    How to convert CONVERT function in SQL Server to oracle, below mentioned format is in SQL Server:
    variable1 = convert(numeric(20), SUBSTRING( parameter1,parameter2,parameter3)
    parameter1 datatype nvarchar2(100)
    parameter2 datatype bigint
    parameter3 datatype bigint
    I did bit R&D, but was not successful..but still getting on..
    If any help that would be great...
    Regards,
    ~ORA

    You cannot specify the precision/scale or length of input paramters to a stored procedure in Oracle, or at least the pl/sql engine does not respect the sizing. Assuming that you want to do something with variable1 in the procedure, and not just return it, the Oracle equivalent would be something along the lines of:
    SQL> CREATE FUNCTION f (p_param1 IN VARCHAR2,
      2                     p_param2 IN NUMBER,
      3                     p_param3 IN NUMBER) RETURN NUMBER IS
      4     l_var1 NUMBER(20) := SUBSTR(p_param1, p_param2, p_param3);
      5  BEGIN
      6     RETURN l_var1 * 10;
      7  END;
      8  /
    Function created.
    SQL> SELECT f('ABC10DEF', 4, 2) FROM dual;
    F('ABC10DEF',4,2)
                  100You may need to adjust the return type to match what you are actually returning.
    You can also use this iin a direct assignment in pl/sql without doig a select, something like:
    SQL> DECLARE
      2     l_num NUMBER(20);
      3  BEGIN
      4     l_num := f('ABC10DEF', 4, 2);
      5     DBMS_OUTPUT.Put_Line('The number is: '||l_num);
      6  END;
      7  /
    The number is: 100John

  • CONVERT function from SQL-Server 7.0 to Oracle

    Whenever a Convert function appears in the T-SQL, WorkBench converts it to RPAD and doesn't warm about it. How can I avoid this situation???
    It`s very urgent!! I`ve to migrate an entire system and I`m very short of time.
    Any comment would be helpfull!! Thanks!
    Julieta.

    THIS IS A DUPLICATE ENTRY AND REPLY, PLEASE USE ADD ADDITIONAL NOTES TO THE OTHER REPLY
    This has been logged as bug 1902143.
    Is altering the output from RPAD(12, 5, ' ') to RTRIM(RPAD(12, 5, ' ')) sufficient?
    Until this bug is fixed and released the only suggestion I can make is Generate Migration Scripts from the Action menu and then
    use an editor to alter the RPAD() to RTRIM(RPAD()).
    Turloch
    Oracle Migration Workbench Team

  • Sqlite query want to convert in MS Sql server 2008

    Hi 
    Please let me know how to write MS SQL server query for the below:
    Sqlite query :
    SELECT strftime('%s',event_time_gmt,'unixepoch','330 minutes') as time;
    Regards,
    Vijjivinayaka

    Declare @dt0 datetime, @dt datetime, @LocalTimeOffset int=5.5*60*60, @epochdt bigint=1389595157, @AdjustedLocaldt bigint;
    SET @AdjustedLocaldt = @epochdt + @LocalTimeOffset
    SELECT @dt0=DATEADD(second,@epochdt, CAST('1970-01-01 00:00:00' AS datetime))
    ,@dt=DATEADD(second,@AdjustedLocaldt, CAST('1970-01-01 00:00:00' AS datetime))
    ; with mycte as (SELECT @epochdt as epochdt, @dt0 as gmtdt , @dt as localdt
    , DATEADD(minute, DATEDIFF(minute,0,@dt),0) as StartOftheMinute
    ,DATEADD(hour, DATEDIFF(hour,0,@dt),0) as StartOftheHour
    , DATEADD(day, DATEDIFF(day,0,@dt),0) as StartOftheday
    , DATEADD(mm, DATEDIFF(mm,0,@dt),0) as StartOfThisMonth
    , DATEADD(year, DATEDIFF(year,0,@dt),0) as StartOftheYear
    , DATEADD(wk, DATEDIFF(wk,0,@dt),0) as StartOftheWeek)
    select epochdt,
    Left(datename(weekday,localdt),3) +' '+ CONVERT(varchar(26),localdt,109) as localdt
    ,Left(datename(weekday,gmtdt),3) +' '+ CONVERT(varchar(26),gmtdt,109) as gmtdt
    ,Left(datename(weekday,StartOftheMinute),3) +' '+ CONVERT(varchar(26),StartOftheMinute,109) as StartOftheMinute
    ,Left(datename(weekday,StartOftheHour),3) +' '+ CONVERT(varchar(26),StartOftheHour,109) as StartOftheHour
    ,Left(datename(weekday,StartOftheday),3) +' '+ CONVERT(varchar(26),StartOftheday,109) as StartOftheday
    ,Left(datename(weekday,StartOfThisMonth),3) +' '+ CONVERT(varchar(26),StartOfThisMonth,109) as StartOfThisMonth
    ,Left(datename(weekday,StartOftheYear),3) +' '+ CONVERT(varchar(26),StartOftheYear,109) as StartOftheYear
    ,Left(datename(weekday,StartOftheWeek),3) +' '+ CONVERT(varchar(26),StartOftheWeek,109) as StartOftheWeek
    from mycte
    --http://msdn.microsoft.com/en-us/library/ms187928.aspx

  • Call userdefined function on sql server 2000 from a rpt/crystalviewer CR11

    Post Author: schste0
    CA Forum: Data Connectivity and SQL
    Hi, i have userdefined functions in an sql2k database and look for a way to use them in cr11 and in the reportviewer with RAS. Thx in advance.

    Use a SQL Expression if the Driver supports it. Or a Command Object.

  • Creating user defined function in sql server 2000

    I have created a udf an i want to call it in another udf. will u please help me out how to create.
    thank you

    And you ask that in an ORACLE forum? Brilliant idea... ;)

  • How to crete the source system for the SQL Server 2000 to BI 7.1

    Dear All,
    We want to extract data from  SQL server 2000 data base to BI 7.1
    Please provide us the step-by-step procedure to be followed in BI as well as SQL server 2000 BD
    Thanks & Regards,
    sarasu

    Hi,
    You have two options, you can use DB Connect but you need SAP DBSL for SQL Server 2000 and the DB Client and this could be have a additional cost, or you can use UD Connect, that make the connection with Java, using JCo's and the Driver Java for SQL Server 2000, please review this link: [http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/58f4db47-0501-0010-a2bf-ff01b150fdff|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/58f4db47-0501-0010-a2bf-ff01b150fdff]
    I recomend if you dont have the SAP DBSL and DB Client for SQL Server 2000 that use UD Connect is really useful.
    Regards

  • How to migrate sql server 2000 user defined function returns table

    Hi,
    How do I capture the SQL Server 200 user defined function that returns table? Is this supported in the current version of Oracle Migration Workbench? I am using the latest version - Release 9.2.0.1.0 with SQL SERVER 2000 plug-in.
    I was able to capture the SQL Server 2000 user defined function that returns string and smalldatetime but not the functions return table during the migrate data source stage.
    Thanks in Advance,
    Susan

    Susan,
    This is not currently supported. The next release of the Oracle Migration Workbench (due very soon), will do a better job of catching this mad reporting an error. We are looking into a suitable mapping and have created bug # 2355073 - TABLE DEFINITIONS NOT ACCEPTED FOR TABLE FUNCTIONS to track this issue.
    Once possible solution we are looking into is using the object type to emulate. Here is an example from the bug:
    Original table
    SQL> create table tabela (a number, b number, c number, d number);
    SQL> insert some values...
    SQL> select * from tabela;
    A B C D
    1 1 1 1
    2 2 2 2
    3 3 3 3
    4 4 4 4
    SQL Server 2000 code
    CREATE FUNCTION FUNCRETORNATABELA()
    RETURNS TABLE
    AS
    RETURN SELECT A,B,C,D FROM TABELA
    SELECT A,B,C,D
    FROM FUNCRETORNATABELA()
    ORDER BY A
    Oracle code (workaround)
    SQL> create or replace type MyObjType as object (
    2 a number, b number, c number, d number);
    3 /
    Type created.
    SQL> create or replace type MyTabType as table of MyObjType;
    2 /
    Type created.
    SQL> create or replace function teste return Mytabtype pipelined as
    2 aa MyObjType := MyObjType(null, null, null, null);
    3 cursor c1 is select a,b,c,d from tabela;
    4 begin
    5 open c1;
    6 loop
    7 fetch c1 into aa.a, aa.b, aa.c, aa.d;
    8 exit when c1%NOTFOUND;
    9 pipe row (aa);
    10 end loop;
    11 close c1;
    12 return;
    13 end;
    14 /
    Function created.
    SQL> select * from table(teste);
    A B C D
    1 1 1 1
    2 2 2 2
    3 3 3 3
    4 4 4 4
    SQL> select a, c from table(teste) order by c desc;
    A C
    4 4
    3 3
    2 2
    1 1
    Donal

  • Converting SQL Server 2000 to Oracle 9i

    Hi,
    I am working on the migration of stored procs from a SQL Server 2000 database to Oracle 9i. The sqlsrvr db contains 75 relatively complex procs using temporary tables to create intermediate resultsets for further processing.
    The Oracle 9i environment has very strictly standards and temporary tables are not allowed.
    Is it standard practice to use PL/SQL tables to simulate the functionality of temp tables?
    I understand you can now use SQL against PL/SQL tables under certain circumstances.
    I would envisage using the PL/SQL tables in multi-table joins with schema tables.
    Any ideas whether I am going down the wrong path.
    Thanks in advance,
    Garrett Donnelly

    Garrett,
    Note that there is also an parser option to 'Generate8i temp tables', where the data in the permanent tables is seperated from other sessions by the use of an extra Session id colum.
    Please post the results of your PL/SQL table experiences.
    Regards,
    Turloch
    Oracle Migration Workbench Team

  • Problem converting captured SQL Server 2000 database to Oracle

    Java(TM) Platform     1.6.0_17
    Oracle IDE     2.1.1.64.45
    Versioning Support     2.1.1.64.45
    After creating MWREP user, granting it privileges and creating the migration repository, I have captured a small SQL Server 2000 database (1 table), but after performing "Convert to Oracle", I get the message that it has transformed correctly, but no converted model is shown. I was originally using the JRE supplied with SQL Developer 2.1.1, but replaced that with 1.6 U17 after researching the problem here.
    The only message in the Migration Log is as follows:
    Catalog RAC, Schema dbo coalesced to single schema dbo_RAC
    The following message appears in the console:
    SELECT DISTINCT(REF_ID_FK), REF_TYPE FROM MD_ADDITIONAL_PROPERTIES WHERE PROP_KEY IN (?) AND CONNECTION_ID_FK = ?
    I have tried this with a more complex database, with no luck.
    Any thoughts?

    I did an offline capture.
    I used Tools->Migration->Third Party Database Offline Capture->Create Database Capture Scripts to generate scripts OMWB_OFFLINE_CAPTURE.BAT, SS2K_BCP_SCRIPT.BAT and sqlserver2000.ocp. Then the SQL Server DBA ran OMWB_OFFLINE_CAPTURE.BAT and sent me the output.
    I used Tools->Migration->Third Party Database Offline Capture->Load Database Capture Scripts Output to capture the model into the repository successfully.

  • I want to move DTS packeges from sql server 2000 server to other server SQL2008R2

    Kindly provide help for move DTS packeges from sql server 2000  server to other server SQL2008R2

    Do you have a good technical reason for not wanting to use the Migration Workbench?
    Given that it's free and does a hell of a lot of the work for you, why wouldn't you use it?
    Other than that, I would say you would be on your own...
    cheers,
    Anthony

  • Which is the best way to migrate the SQL SERVER 2000 Database to SQL SERVER 2003 Database?

    Hi,
        I  need to migrate the Production database sql server 2000 to Sql server 2003, Please give me the best idea to migrate the database without any loss data, credentials and  Objects. 
    Nandha Kumar

    SQL server does not have any version named SQL server 2003 please check the version correctly it should be either SQL 2005,2008,2008 R2,2012
    You can use the backup/restore to upgrade the SQL 2000 database to till SQL 2005,2008,2008R2
    For SQL Server 2000 to 2012
    First upgrade from SQL 2000 database to either SQL 2005, 2008 or 2008R2 and than upgrade it to SQL 2012.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/eaa1eb44-729f-466b-8233-cb768fbb4208/upgrading-to-sql-server-2008-from-sql-server-2000?forum=sqlsetupandupgrade
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/4fac7511-2c75-46a0-802b-807dd26b12bf/sql-2012-will-not-convert-a-sql-2000-database?forum=sqlservermigration
    And after migration to SQL 2005 or 2008, if you want to script the database than can generate scripts pick DB and check off "script all objects in the selected database".
    http://blog.sqlauthority.com/2011/05/07/sql-server-2008-2008-r2-create-script-to-copy-database-schema-and-all-the-objects-data-schema-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/
    You can upgrade from SQL Server 2005, SQL Server 2008, and SQL Server 2008 R2 to SQL Server 2012.
    http://msdn.microsoft.com/en-us/library/ms143393(v=sql.110).aspx
    Please click the Mark as answer button and vote as helpful if this reply solves your problem

  • Query Perofmance is much more fast in SQL server 2000 than Oracle 9i

    I have converted a database from SQL Server 2000 to Oracle (9.0.2).
    In a stored procedure a query based on 4 tables working well in SQL Server which takes just 1 or 2 minutes to give result But in Oracle it takes 3 to 4 Hours to return the results.Although Database hit ratio is 99 plus %. In Oracle when i created indexes on 2 columns of 2 tables it just take 5 to 10 sec. But I want to get the result in less time without indexes. Because in
    SQL Server it Works well without indexes.
    Please reply me with some solutions or reasons
    Regards
    AN

    Most sites have a job that runs every night to keep the statistics up to date.Really? I would be very surprised if that was the case. Firstly, many sites don't want to take the hit of running stats for a whole system each night. Secondly, I would hope that many DBAs know this statement...
    Always keep up to date statistics if you want your database to be efficent. ...is wrong.
    The best that can happen from refreshing the statistics every night is that it makes no difference to your application. If your application is running nicely - that is, no users are yelling at you - then your current statistics are good enough. Refreshing statistics introduces instability into the system and might lead to queries performing worse than before.
    Gathering stats is not the sort of thing you want to do with a scattergun. Analyze your database once, after you've reached what is a representative data volume and then leave it alone. Only refresh statistics if you have a specific issue (user complaint) and you think stale statistics might be the cause.
    Cheers, APC

  • How to compare 2 dates in SQL Server 2000 DB using Java?

    How do you compare 2 dates in SQL Server 2000 DB using Java?
    Let's say we have two fields: Date Reported and Target Finish Date.
    Date Reported is 09-10-2004 09:55:55: PM
    Target Finish Date is 09-12-2004 11:59:59: PM
    What i want to happen is i want to convert both dates to days and get the difference of the two.
    can SQL Server 2000 DB do this?

    it doesnt wrk.
    ok here's what i did:
    iv tested a simple code for this case.
    I created a table name tblDate which has 3 columns namely date_ID, date_From (datatype datetime), date_To (datatype datetime).
    I inserted 1 row: date_ID has the value 1, date_From has the value 10/22/2004, and date_To has the value 10/24/2004.
    i run the java code below:
    int days = 0;
              String query = "SELECT date_From, date_To cast(date_From-date_To AS int) AS Diff FROM tblZoo WHERE date_ID = '1'";
              try
                   DBConnect db = new DBConnect();
                   db.openCon();
                   ResultSet rs = db.execute(query);
                   while(rs.next())
                        days = rs.getInt("Diff");
                   db.closeCon();                         
              catch (Exception ex)
                   System.out.println("Error on Execution: " + ex);
              return days;___________
    an error occurred: Error on Execution: java.lang.nullpointerexception

  • Storing and retrieving arabic in SQL Server 2000

    hello, i realize this problem has been posted lots before but i read in the forum and i couldn't find a solution to fix my problem
    i am developing a desktop application in java and sql server 2000, and i'm using JBuilder for writing my java codes
    here's the problem
    i can MANUALLY store arabic text in my database (directly in SQL Sever Query Analyzer) and can read it in arabic properly in SQL Server, but if i want to retrieve the arabic text in a query in JAVA, for example: select * from person i see weird characters (not question marks) but not the original arabic text
    and if i type arabic text in a java textfield and use the value entered in an sql query, for example:
    sqlQuery = "insert into person (fname) values ('" + jtfFName.getText() + "')";it is inserted in SQL Server as ?????s and when i retrieve the values from the table i also see it as ?????s
    even when i converted all the data types in the database to unicode data types (*nchar* instead of char and nvarchar instead of varchar) and modified the sql query to the following:
    sqlQuery = "insert into person (fname) values (N'" + jtfFName.getText() + "')";(N outside the single quotation mark since according to rules on msdn)
    it still didn't solve the problem
    please i need urgent help with this issue!

    problem was solved by setting the charSet encoding to "UTF-8" in the connection to sql server using the jdbc-odbc bridge

Maybe you are looking for

  • How to create an Event & schedule a rpt based on results of that Event..

    Help, I need to schedule a report, that will run after an event is done. I only want the rpt to run if the event produces more than 1 record. I dont know how to create an event? I am assuming I can use a SQL qry as an event. I would like to use: sele

  • Z87-G45 and SOME USB 3.0 ports not appearing in tray/prompting to eject

    The 2 lowest USB 3.0 ports on the back panel (Nearest the sound connectors) of my G45 have a weird issue under Win 7 Ultimate. When I plug in a 2.0 drive into those ports, everything is normal i.e. the eject icon and eject warning appear in the tray

  • How to hard code a printer in a report using Crystal 2008

    Up through Crystal 10 you could save the Printer you wanted to use in the report itself.  Since Crystal 11, this feature is no longer working.  At print time, the default printer is being used.  We have a report that prints to a specific printer util

  • Cant install on Mac 10.7.5 - please help

    Hi - Ive read and tried all the suggestions in this forum. Cant solve the basic problem that whenever I try to open the download forthe Flash update, the Flash Player Installer box simply goes black and remains black until I close it.  Please help!!!

  • LR2.4 not opening up

    I'm a Mac user using the latest Mac OS and Lightroom 2.4 and PSCS4.   When I'm on Lightroom and I go to Photoshop, I try to go back and Lightroom is open and I see the bar at the top of the computer with Lightroom next to the Apple Logo, but it doesn