Curl Global Community
Print data - Printable Version

+- Curl Global Community (http://communities.curl.com)
+-- Forum: Discussions (http://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (http://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: Print data (/showthread.php?tid=1443)



Print data - NamDH - 04-03-2017

English translated below.
_________________________________________


みんなこんにちは。
長い文書ですから、すみません。CURLプログラミング言語をまだ2週間勉強していますけど、今はちょっとCURL に困ります。例えば、ローカルの Oracle データバースから選択された 以下のような RecordSet があります。
Code:
{let rs:RecordSet =
    {connection.create-record-set "SCOTT","SELECT * FROM EMP"}
}

105レコードがあり、 RecordGridで表示でき、それから構築と この RecordSet のすべてのデータを表示たいです。CURL 資料に検索しましたが、 {dump rs}と {value rs}で実行見ましたけど実行できません。 [BasicConnectedRecordSet @0x0CE32A54] とういうしか表現しないです。
PHP プログラミング言語では、 var_dump()や print_r() が データを表示できます。CURL プログラミング言語では同じやつあるか。この文書は何か間違ったか教えてください。ありがとうございます。



_________________________________________
Hello everybody!


Sorry because of this rude post.
I am new to CURL programming language just for 2 weeks and i am very stuck with this problem.
Let's assume that I have a RecordSet selected in my local Oracle database:
Code:
{let rs:RecordSet =
    {connection.create-record-set "SCOTT","SELECT * FROM EMP"}
    }


I have 105 records, I can view it with RecordGrid and I want to show structure and all data of this RecordSet.
I searched in Curl documentation, I have tried "{dump rs}" and "{value rs}" but it doesn't work, what i got just a text "[BasicConnectedRecordSet @0x0CE32A54]".

In PHP programming language, we have syntax like "var_dump()" and "print_r()" to show all our data.
I wondering if we have similar syntax in Curl programming language?

Please tell me if this post is wrong thread or it rude.

Thank in advance.


RE: Print data - dyoshida - 04-03-2017

dump (macro) dumps specified values.
However, Recordset is a class object, not a value.
Therefore, the following code is necessary to dump data registered using the record set

Code:
{curl 8.0 applet}

{define-proc {output-recordset rs:RecordSet}:void
    {for f in rs.fields do
        {outfmt {format "%s, ", f.name}}
    }
    {outfmt "\n"}
    
    {for r in rs do
        {for f in rs.fields do
            {outfmt {format "%s, ", r[f.name]}}
        }
        {outfmt "\n"}
    }
}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField
                "First", caption = "First Name", domain = String
            },
            {RecordField
                "Last", caption = "Last Name", domain = String
            },
            {RecordField
                "Age", domain = int
            }
        },
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28}
    }
}

{output-recordset people}




RE: Print data - NamDH - 04-03-2017

(04-03-2017, 02:42 PM)dyoshida Wrote: dump (macro) dumps specified values.
However, Recordset is a class object, not a value.
Therefore, the following code is necessary to dump data registered using the record set

Code:
{curl 8.0 applet}

{define-proc {output-recordset rs:RecordSet}:void
    {for f in rs.fields do
        {outfmt {format "%s, ", f.name}}
    }
    {outfmt "\n"}
    
    {for r in rs do
        {for f in rs.fields do
            {outfmt {format "%s, ", r[f.name]}}
        }
        {outfmt "\n"}
    }
}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField
                "First", caption = "First Name", domain = String
            },
            {RecordField
                "Last", caption = "Last Name", domain = String
            },
            {RecordField
                "Age", domain = int
            }
        },
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28}
    }
}

{output-recordset people}
Thank you, I found output data with your code in Curl RTE Console, it works.

By the way, do you have any document or any example about CRUD (Create, Read, Update, Delete) with Oracle database?
I am searching in:
+ http://curl.com/

+ http://curlap.com/
+ http://tech.curlap.com/
+ Curl Documentation Viewer (it be shown when i hit F3 or choose Open Definition in Eclipse).

At this time, i can get data from Oracle database and show it with GridView.


RE: Print data - dyoshida - 04-03-2017

I found a similar old posted article.

http://communities.curl.com/showthread.php?tid=282


The link in the article is broken, but you can see from the link below.

http://tech.curlap.com/db/
http://tech.curlap.com/?s=data-connection.html



The following library may also be useful.
http://www.curl.com/products/prod/opensource/


RE: Print data - NamDH - 04-03-2017

(04-03-2017, 05:49 PM)dyoshida Wrote: I found a similar old posted article.

http://communities.curl.com/showthread.php?tid=282


The link in the article is broken, but you can see from the link below.

http://tech.curlap.com/db/
http://tech.curlap.com/?s=data-connection.html



The following library may also be useful.
http://www.curl.com/products/prod/opensource/
Thank you for your suggest library, I will do some simple sample to understand how it works.
I can connect to Oracle database at previous time. At this time, I expect more about how to Insert, Edit, Delete data in database.




RE: Print data - dyoshida - 04-04-2017

How to Insert, Edit, Delete using ConnectedRecordSet is described RecordSet section of the Curl document.

If the database server allows, committing changes to ConnectedRecordSet will update the data on the database server.
(Please refer to RecordSet.commit )