If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > enterprisedb postgres studio

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-09-11, 06:21
shorif2000 shorif2000 is offline
Registered User
 
Join Date: May 2011
Posts: 5
enterprisedb postgres studio

I have managed to convert most of my schema from mysql to postgres but it doesn't seem to convert the functions or triggers.

i have used the mysql editor in the program but it doesn't seem to show any errors and looks like it executed fine but no triggers or functions seem to appear.

can anyone help.

Code:
create or replace function prodotti_price_log_after_insert_trigger()
returns trigger
language plpgsql volatile as $$
  declare previous_price real;
begin


  SELECT prezzobuy INTO previous_price FROM prodotti WHERE codart=NEW.codart;

  IF previous_price > NEW.prezzobuy THEN
    UPDATE prodotti_descriptions SET social_networks_reduced=0 WHERE codart=NEW.codart;
  END IF;


end
$$;

Code:
create or replace function shopto_customers_before_update_trigger()
returns trigger
language plpgsql volatile as $$
  declare exists_already integer;




begin


  IF NEW.platforms <> OLD.platforms THEN
    SELECT count(*) INTO exists_already FROM shopto_newsletters WHERE customer_id=OLD.id;

    IF exists_already > 0 THEN
      UPDATE shopto_newsletters SET platforms=NEW.platforms WHERE customer_id=NEW.id;
    ELSE
      INSERT INTO shopto_newsletters (created, modified, email, platforms, customer_id) VALUES (now(), now(), NEW.email, NEW.platforms, NEW.id);
    END IF;
  END IF;
  

end
$$;


Code:
create or replace function mtdb_magic_modified()
returns trigger
language plpgsql stable as $$
begin
    NEW.modified = CURRENT_TIMESTAMP;
    return new;
end;
$$;

those are just a few

Last edited by shorif2000; 05-09-11 at 06:33.
Reply With Quote
  #2 (permalink)  
Old 05-09-11, 06:44
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Did you run the corresponding CREATE TRIGGER statements?
Reply With Quote
  #3 (permalink)  
Old 05-09-11, 09:53
shorif2000 shorif2000 is offline
Registered User
 
Join Date: May 2011
Posts: 5
Quote:
Originally Posted by shammat View Post
Did you run the corresponding CREATE TRIGGER statements?
Yes i have, same thing. it runs the query OK but nothing appears under the sidebar under triggers


Code:
create trigger "mtdb_after_update" after update ON shopto.prodotti
  for each row execute procedure prodotti_after_update_trigger();
Reply With Quote
  #4 (permalink)  
Old 05-09-11, 10:18
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
I have no idea what that "sidebar" thing is.

Is anything visible in the system catalog pg_trigger?
Reply With Quote
  #5 (permalink)  
Old 05-09-11, 11:12
shorif2000 shorif2000 is offline
Registered User
 
Join Date: May 2011
Posts: 5
Quote:
Originally Posted by shammat View Post
I have no idea what that "sidebar" thing is.

Is anything visible in the system catalog pg_trigger?


In the object browser in pgAdmin III i do not see any function or triggers.

How ever if i take off the ''OR REPLACE'' on the trigger and run the create trigger statement they seem to exist as it says it exists already but the functions do not?
Reply With Quote
  #6 (permalink)  
Old 05-09-11, 11:22
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Is anything visible in the system catalog pg_trigger?
Reply With Quote
  #7 (permalink)  
Old 05-09-11, 11:28
shorif2000 shorif2000 is offline
Registered User
 
Join Date: May 2011
Posts: 5
Quote:
Originally Posted by shammat View Post
Is anything visible in the system catalog pg_trigger?
Under my database, under catalogs section I have 2 default ones i believe
- ANSI
- PostgreSQL (pg_catalog)

There are many triggers and functions under pg_catalog but none which our mines
Reply With Quote
  #8 (permalink)  
Old 05-09-11, 11:35
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by shorif2000 View Post
There are many triggers and functions under pg_catalog but none which our mines
Did you commit all your CREATE statements?
Reply With Quote
  #9 (permalink)  
Old 05-09-11, 11:56
shorif2000 shorif2000 is offline
Registered User
 
Join Date: May 2011
Posts: 5
Quote:
Originally Posted by shammat View Post
Did you commit all your CREATE statements?
yes. .....
Reply With Quote
  #10 (permalink)  
Old 05-11-11, 10:50
futurity futurity is offline
Registered User
 
Join Date: May 2008
Posts: 270
The code snippets you are posting cannot be what you're actually creating in the DBMS, because they have several errors:

1. The final END requires a semicolon ( ; ) after it.

2. All your trigger functions must return a value, which none of yours do. Per-statement triggers must return NULL. After per-row triggers must return NULL. Before per-row triggers must either return NULL to cancel the operation, or the row to insert/update/delete.

Both of these things should be generating errors while either loading the SQL or attempting to the run the trigger.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On