467,915 Members | 1,194 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

Convert PostgreSQL DB to MS-SQL

Hi,
I want to convert my complete database of PostgresQL to MS-SQL.
I am some what successful in converting tables but the major problem is Functions and Triggers.


Please help.
Oct 10 '08 #1
  • viewed: 4784
Share:
2 Replies
ck9663
Expert 2GB
Post your stored proc and functions and we can try to help you convert it.Depending on the logic and business rules of your procedure and functions, it might not be able to be translated line by line. Instead, some (or all) of them might be completely re-written.

-- CK
Oct 10 '08 #2
Post your stored proc and functions and we can try to help you convert it.Depending on the logic and business rules of your procedure and functions, it might not be able to be translated line by line. Instead, some (or all) of them might be completely re-written.

-- CK
One of the Function:

Expand|Select|Wrap|Line Numbers
  1. -- Function: sp_get_form_bag_content(bigint, bpchar)
  2.  
  3. -- DROP FUNCTION sp_get_form_bag_content(bigint, bpchar);
  4.  
  5. CREATE OR REPLACE FUNCTION sp_get_form_bag_content(in_cand_id bigint, in_payment_mode bpchar)
  6.   RETURNS SETOF typ_form_bag_content AS
  7. $BODY$
  8. DECLARE
  9.  
  10.    v_form_id_arr _int2;
  11.    v_rec form_bag%ROWTYPE;
  12.    v_return_rec typ_form_bag_content;
  13.    v_index int2;
  14.  
  15. BEGIN
  16.  
  17. update cand_preferences
  18.    set payment_mode = in_payment_mode
  19.    where cand_id = in_cand_id
  20.    and   payment_mode <> in_payment_mode;
  21.  
  22. v_index=0;
  23. for v_rec in select form_id from form_bag where cand_id=in_cand_id
  24. loop
  25.    v_form_id_arr[v_index]= v_rec.form_id;
  26.    v_index = v_index + 1;
  27. raise notice '%', v_form_id_arr[0];
  28. end loop;
  29.  
  30.  
  31. for v_return_rec in
  32. select temp2.form_id, college_name, course_list, form_cost, warning, sp_format_date(last_date,'DD-Mon-YYYY, DOW'), is_exam from (
  33. select college_id, temp.form_id, course_list, form_cost, warning, last_date, is_exam from
  34.    (    
  35.    select sp_warnings_cost.form_id, course_list, warning, form_cost from
  36.         (
  37.             select sp_cost.form_id, coalesce(sp_warnings.warning,'') as warning, sp_cost.form_cost from
  38.                 (
  39.                  select form_id,
  40.                     array_to_string(array_accum(warnings), '::') as warning
  41.                    from (
  42.                      select  *
  43.                         from sp_check_form_constraints(in_cand_id, v_form_id_arr)
  44.                     ) as sp1_warnings
  45.                    group by form_id
  46.                 ) as sp_warnings
  47.  
  48.                right outer join sp_get_forms_cost(in_cand_id, v_form_id_arr) as sp_cost on sp_cost.form_id=sp_warnings.form_id
  49.         ) as sp_warnings_cost
  50.  
  51.           left outer join sp_get_form_bag_courses(in_cand_id) sp_courses on sp_warnings_cost.form_id=sp_courses.form_id
  52.    ) as temp
  53.     inner join forms f on f.form_id=temp.form_id
  54. )temp2
  55. inner join colleges col on col.college_id=temp2.college_id
  56. loop
  57.  
  58. return next v_return_rec;
  59.  
  60. end loop;
  61.  
  62. return;
  63. END;
  64. $BODY$
  65.   LANGUAGE 'plpgsql' VOLATILE
  66.   COST 100
  67.   ROWS 1000;
  68. ALTER FUNCTION sp_get_form_bag_content(bigint, bpchar) OWNER TO postgres;
  69.  
Nov 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by G Lam | last post: by
4 posts views Thread by Chris M. Gamble | last post: by
26 posts views Thread by jini us | last post: by
13 posts views Thread by Zlatko Matiś | last post: by
19 posts views Thread by Alex Madon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.