On Fri, Jan 30, 2004 at 03:11:05PM +0000, Harry Jackson wrote:
> 
> .pcc_sub _MAIN prototyped
>     .param pmc argv
>     .include "/home/parrot/dbdi/lib/dbdi/dbdi_header.imc"
>     
>     .sym pmc dbh 
>     .sym string dbstring
>     dbstring = "host=lhost dbname=name user=user password=pass"
>     .sym string dbh_name
>     dbh_name = "dbh"
>     .pcc_begin prototyped
>         .arg dbstring 
>         .arg dbh_name 
>             .pcc_call connect 
>             retconnect:
>         .result dbh
>     .pcc_end
>     print "New $dbh successful????\n"   

I don't see the need for this naming. Why not just do:

      .sym string dbstring
      dbstring = "host=lhost dbname=name user=user password=pass"

      .sym pmc dbh1
      .sym pmc dbh2
      .pcc_begin prototyped
          .arg dbstring 
              .pcc_call connect 
              retconnect:
          .result dbh1
      .pcc_end
      .pcc_begin prototyped
          .arg dbstring 
              .pcc_call connect 
              retconnect:
          .result dbh2
      .pcc_end

?

>     # Now that we have a $dbh we can pass it into
>     # the prepare funtion with the SQL statement.
>     # We must also name our statement handle which
>     # allows us to have multiple statement handles
>     # per dbh object. Name collisions are being
>     # checked. We also check to make sure that the
>     # dbh that is passed in is valid otherwise we
>     # abort.
>     .sym pmc sth
>     .sym string sql
>     sql = "select * from parrot"
>     .sym string sth_name
>     sth_name = "sth"
>    
>     .pcc_begin prototyped
>         .arg dbh_name 
>         .arg sth_name 
>         .arg sql 
>             .pcc_call prepare 
>             retprepare:
>         .result sth
>     .pcc_end

That needs to be more like this:

      .sym string sql
      sql = "select * from parrot"
     
      .sym pmc sth1
      .pcc_begin prototyped
          .arg dbh1
          .arg sql 
              .pcc_call prepare 
              retprepare:
          .result sth1
      .pcc_end

No dbh name, no sth name. They're not needed and not in the spec.
Am I missing something?

The returned sth thingy holds a copy (ref) of its parent dbh.

Tim.

Reply via email to