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 > Dummy data in postgres gives error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-11, 04:16
prasadk11 prasadk11 is offline
Registered User
 
Join Date: Jun 2011
Posts: 2
Dummy data in postgres gives error

CREATE OR REPLACE FUNCTION updateWebTransLog() RETURNS TRIGGER AS '
DECLARE
transactionType character varying(3);
BEGIN
INSERT INTO webtranslog(username,reqtime,transactiontype,descr iption) (SELECT tellerid,date,'CR', mbnumber FROM userreg WHERE mbnumber = NEW.mbnumber);
RETURN NULL;
END;

' LANGUAGE plpgsql;




ifollowing is th output::


ERROR: syntax error at or near "CR"
LINE 5: ...ansactiontype,description) (SELECT tellerid,date,'CR', mbnum...
^


********** Error **********

ERROR: syntax error at or near "CR"
SQL state: 42601
Character: 220



please help!!
Reply With Quote
  #2 (permalink)  
Old 06-07-11, 04:29
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
This error occurs because you are nesting single quotes.

Quote from the manual for the CREATE FUNCTION statement regarding the function body:
Quote:
Originally Posted by Manual
definition:

It is often helpful to use dollar quoting (see Section 4.1.2.4) to write the function definition string, rather than the normal single quote syntax. Without dollar quoting, any single quotes or backslashes in the function definition must be escaped by doubling them.
For details on how to use the dollar quotings, read the mentioned section:

http://www.postgresql.org/docs/9.0/s...DOLLAR-QUOTING
Reply With Quote
  #3 (permalink)  
Old 06-07-11, 04:36
prasadk11 prasadk11 is offline
Registered User
 
Join Date: Jun 2011
Posts: 2
I tried it and it worked. Very thankful to u... shammat
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