Curl Global Community
Modify Record - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Discussions (https://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (https://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: Modify Record (/showthread.php?tid=1444)



Modify Record - benzamil - 04-03-2017

Hi every body ! I have a problem about modify RecordSet after get from database via connection.
This is my source code .
=========================================================

{import * from CURL.DATA-ACCESS.BASE}
{import * from CURL.DATA-ACCESS.CONNECTED}
{let connection:BasicConnection =
{BasicConnection {url "http://192.168.1.18:9999/cdbc-server/CdbcServlet"}}
}
{let sqlChart:String={String
"SELECT E.EMPLOYEE_ID,
E.FIRST_NAME,
E.LAST_NAME,
E.EMAIL,
E.PHONE_NUMBER,
E.HIRE_DATE,
E.JOB_ID,
E.SALARY,
E.COMMISSION_PCT,
(SELECT CONCAT(CONCAT(S.FIRST_NAME,' '),S.LAST_NAME) FROM EMPLOYEES S WHERE S.EMPLOYEE_ID = E.MANAGER_ID) AS MANAGER ,
D.DEPARTMENT_NAME
FROM EMPLOYEES E LEFT JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID = D.DEPARTMENT_ID"
}
}

{let rsbase:RecordSet={connection.create-record-set "HR","EMPLOYEES",request-modifiable?=true}}
{define-proc {get-all-record rss:RecordSet}:RecordSet
{let rsMod:RecordSet =
{RecordSet
{RecordFields
{RecordField "f_name",caption = "FIRST NAME", domain = String},
{RecordField "l_name",caption ="LAST NAME",domain = String}
}
}
}
{for r:Record in rss do
{rsMod.append{RecordData f_name = r["FIRST_NAME"],l_name = r["LAST_NAME"] }}
}
{return rsMod}
}
{let rs:RecordSet = {get-all-record rsbase}}
{value rs.size}

=================================================================
it's seem a problem happend in my proc get-all-record,I couldn't modified RecordSet. Please tell me about this problem. Thanks


RE: Modify Record - dyoshida - 04-03-2017

Before appending a new record, you need to create a new record using Recordset.new-record method.

Code:
{for r:Record in rss do
|| {rsMod.append{RecordData f_name = r["FIRST_NAME"],l_name = r["LAST_NAME"] }}
    def nr = {rsMod.new-record}
    {nr.set "f_name", r["FIRST_NAME"]}
    {nr.set "l_name", r["LAST_NAME"]}
    {rsMod.append nr}
}



RE: Modify Record - benzamil - 04-03-2017

(04-03-2017, 01:23 PM)dyoshida Wrote: Before appending a new record, you need to create a new record using Recordset.new-record method.

Code:
{for r:Record in rss do
|| {rsMod.append{RecordData f_name = r["FIRST_NAME"],l_name = r["LAST_NAME"] }}
    def nr = {rsMod.new-record}
    {nr.set "f_name", r["FIRST_NAME"]}
    {nr.set "l_name", r["LAST_NAME"]}
    {rsMod.append nr}
}
Thank you very much ! Smile I wil try it .