[Bond-users] Open updatable <sql> from PostgeSQL Function

n.vorotnikova n.vorotnikova at rts.ru
Wed Aug 7 12:59:46 EDT 2013


Hello dear colleagues.
Help me please.
I would like to get:
1 open "testwidget"
2 create temp table TMPTable
3 change  data in TMPTable in "testwidget"
4 Save updated data from TMPTable in table T1 by TMPTable's trigger

When I try to open window  "testwidget"  I get :
Warning: bonddb/bonddbid.c: 254: bonddb_id_get(): No primary key set in 
query: select * From dobancurrencies(341::int);

I can see that my temp table created with right data.
But any changes not save to TMPTable and  trigger doesn't work

Where is my mistake?
Could you tell me better way to do this?


I have in xml:
         <window  name="testwidget" parentwindow = "parentwind" 
modal="true" >
         <dbobject name="test">
             <sql>select * from CreateTempTableWithTrigger(<field 
dbobjectsrc="parentwind">ID</field>::int);</sql>
         </dbobject>
         <hbox>
             <cell>
                 <entry name="fld1">
                     <field>fld1</field>
                 </entry>
             </cell>
             <cell>
                 <entry name="fld2">
                     <field>fld2</field>
                 </entry>
             </cell>
             <cell  >
                 <button name="save">
                     <trigger event="click">
                         <api call="save">
<widget>testwidget</widget>
                         </api>
                     </trigger>
                 </button>
             </cell>

         </hbox>
     </window>

I have in PostgreSQL:

CREATE OR REPLACE FUNCTION SaveDataFromTMP() RETURNS trigger AS
$$BEGIN
INSERT INTO T1 (fld1, fld2) SELECT fld1, fld2 FROM TMPTable;

RETURN NEW;
END;
$BODY$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION CreateTempTableWithTrigger( prmId int )
RETURNS TABLE ( id int, fld1 int, fld2 int) AS
$$ BEGIN
DROP TABLE IF EXISTS TMPTable CASCADE;
Create TEMP  Table TMPTable( id int, fld1 int, fld2 int);
Insert Into TMPTable("ID") Values(prmID);

CREATE TRIGGER Test_update AFTER UPDATE OR INSERT ON TMPTable  FOR EACH 
ROW  EXECUTE PROCEDURE SaveDataFromTMP();

RETURN QUERY SELECT * FROM TempBanCurrencies;

END $$
LANGUAGE plpgSQL;

Sorry for lot letters.
Thanks in advance
Nadia

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.hcoop.net/pipermail/bond-users/attachments/20130807/50c697ee/attachment.htm 


More information about the Bond-users mailing list