On Thu, Jan 29, 2004 at 09:00:56PM +0000, Harry Jackson wrote:
> Ok.
>
> I have managed to knock up an initial draft. You will see straight away
> that it is very limited in what it does. I have managed to run the
> select statement as shown in the code and it does return 10000 records
> although I have not checked for any boundary conditions. Although I
> expect there are a few of them lurking due to the way the driver has
> been written but we can ignore the driver bugs for now ;-) or at least
> until Dan finds them.
>
> .pcc_sub _MAIN prototyped
> .param pmc argv
> .include "/home/parrot/dbdi/lib/dbdi/dbdi_header.imc"
>
> .sym string dbstring
> .sym PerlHash dbh
The application shouldn't need to know the type of the thing returned.
Can you use a 'reference' type here instead of PerlHash?
> dbstring = "host=lhost dbname=name user=user password=pass"
> .pcc_begin prototyped
> .arg dbstring
> .pcc_call connect
> retconnect:
> .result dbh
> .pcc_end
> print "New $dbh successful????\n"
When we move to objects we'll add in the driver handle and call connect
as a method on that.
I'd like to see username and password moved to separate parameters
and an attributes parameter added. (To get as close to the final
API as early as possible).
> # Now that we have a $dbh we can pass it into
> # the prepare funtion with the SQL statement
> .sym Sub sth
Er, Sub for sth?
> .sym int rows
> .pcc_begin prototyped
> .arg sth
> .pcc_call execute
> retexecute:
> .result rows
> .pcc_end
> .PRINT("Execution Successful ", rows, " Affected\n" )
>
> .sym PerlArray rowarray
> .sym int rowcount
> .sym PerlString field0
> .sym PerlString field1
> .sym PerlString field2
> .sym PerlString field3
> .sym PerlString field4
> fetchnext:
> .pcc_begin prototyped
> .pcc_call fetch
> retfetch:
> .result rowarray
> .result rowcount
> .pcc_end
> if rowcount == 0 goto finish
Is that returning a new PerlArray each time?
I think that should be another reference and have fetch() return
a reference to the same (internal) PerlArray each time.
rowcount shouldn't be returned (could be a global for now).
Use a nil/null reference in rowarray to indicate no more data.
Looking good. Thanks Harry.
> =head1 TODO
>
> =item Returning objects from functions
>
> I want to return some object like structures back
> from the functions above rather than hiding
> everything in the background. This will make it
> easier to see and know what is going on between calls.
I'm not sure what that means.
> =item We need objects
Very true.
> =item We need runtime loading
Yes, not urgent though.
Tim.