Empty date passing to Postgres Stored Procedure from PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In my application I am passing a date field to the postgres stored
procedure. The problem is when the date field is blank.

My code is like this :

-----------------------------------------------------------------
<TH>Bill Date:</TH>
<TD>
   <INPUT TYPE=text NAME="txtBillDate" 
          VALUE="<? echo $txtBillDate ?>" SIZE=10 MAXLENGTH=10>
</TD>
-----------------------------------------------------------------

I pass the parameters to the stored procedure like this :

-----------------------------------------------------------------
$sSql = "select grn_actions
         ('FREE','$sYearId','$sUserId',1,1,'$hdnGrnType',
                 '$txtGrnNumber','$txtGrnDate', '', '', '',
                 '$txtSupplierCode','$txtBillNumber','$txtBillDate',
                 '$txtChallanNumber','$ParamStr') as tr_id";
-----------------------------------------------------------------

No if in the above case $txtBillDate is blank, php throws the following
error :

-----------------------------------------------------------------
PostgreSQL query failed: ERROR: Bad date external representation '' in
/home/rajesh/public_html/inv/php/INVGoodsReceiptNoteFreeAddUpd.php on
line 478
-----------------------------------------------------------------

My stored procedure declaration is as below :

-----------------------------------------------------------------
CREATE FUNCTION
grn_actions(varchar,char,char,integer,integer,char,char,date,char,char,char,char,varchar,date,varchar,varchar)
returns char as '
DECLARE
    vdocument_type               alias for $1;
    cyear_id                     alias for $2;
    cuser_id                     alias for $3;
    iform_id                     alias for $4;
    iaction_id                   alias for $5;
    cgrn_type                    alias for $6;
    cgrn_number                  alias for $7;
    dgrn_date                    alias for $8;
    cpurchase_order_year_id      alias for $9;
    cpurchase_order_type         alias for $10;
    cpurchase_order_number       alias for $11;
    csupplier_code               alias for $12;
    vbill_number                 alias for $13;
    dbill_date                   alias for $14;
    vchallan_number              alias for $15;
    funcparam_str                alias for $16;
-----------------------------------------------------------------

Can anybody tell me how should I pass the date in case it is blank ? The
above field txtBillDate can be blank is certain cases.

Thanks in advance.

Peace

--
Rajesh
:
####[ GNU/Linux One Stanza Tip (LOST) ]#######################

Sub : Linux Commands (#1)                            LOST #021

No consolidated command list. Do an ls for the following dirs:
/sbin, /usr/sbin               ... for system related commands
/bin, /usr/bin, /usr/local/bin           ... for user commands
/usr/X11R6/bin                      ... for X program commands

####<bish@nde.vsnl.net.in>####################################
:

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux