Unix Technical Forum

Re: Error

This is a discussion on Re: Error within the pgsql Novice forums, part of the PostgreSQL category; --> --- Charley Tiggs <charley@xpressdocs.com> wrote: > On Nov 30, 2005, at 7:12 PM, > <operationsengineer1@yahoo.com> > <operationsengineer1@yahoo.com> wrote: > ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 09:20 PM
operationsengineer1@yahoo.com
 
Posts: n/a
Default Re: Error

--- Charley Tiggs <charley@xpressdocs.com> wrote:

> On Nov 30, 2005, at 7:12 PM,
> <operationsengineer1@yahoo.com>
> <operationsengineer1@yahoo.com> wrote:
>
> >> What's the value of $customer_id before you

> attempt
> >> the insert?
> >>
> >> right after $customer_id variable is set, do the
> >> following:
> >>
> >> echo $customer_id . '<br />';
> >> echo gettype ( $customer_id );
> >> exit;
> >>
> >> With ADO, a couple of times, I've run into a

> glitch
> >> where bindings
> >> changed types. Haven't taken the time to figure

> out
> >> why. Switching
> >> to autoExecute solves the problem:
> >>
> >> $insert_array = array ( 'customer_id' =>
> >> $db->getone("select nextval
> >> ('t_customer_cust_id_seq')"),
> >> 'customer_name' =>
> >> $form->GetInputValue('customer_name'),
> >> 'customer_entry_date' =>

> $db->DBDate(time()))
> >>
> >> $result = $db->autoExecute ( 't_customer',
> >> $insert_array,
> >> 'INSERT' );
> >>
> >> Most likely, the reason it works for me is that I
> >> cleaned up my error
> >> when switching to the autoExecute method.
> >>
> >> Charley

> >
> > using php to cast to to an integer...
> >
> > $customer_id = (int) $customer_id;
> >
> > ...worked for me. i have a note in on the adodb

> forum
> > to find out why it is casting as boolean.

>
> I think your query failed.


great call.

> After you execute this query:
>
> >> $customer_id = $db->getone("select nextval
> >> ('t_customer_cust_id_seq')");

>
> do the following:
>
> echo $db->ErrorMsg();
> exit;
>
> That will tell you why the query failed.
>
> Charley


it says...

ERROR: relation "t_customer_cust_id_seq" does not
exist

i'm off to hunt down the actual name of the sequence.

bottom line - if you get a boolean response, check to
see if the query has failed first.

thank you for the insight.



__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 09:20 PM
Marcus Engene
 
Posts: n/a
Default Re: Error


> it says...
>
> ERROR: relation "t_customer_cust_id_seq" does not
> exist
>
> i'm off to hunt down the actual name of the sequence.
>
> bottom line - if you get a boolean response, check to
> see if the query has failed first.
>
> thank you for the insight.


Quite a few functions in php do this. If you use the
syntax == or != it is C-style compare. That is, zero
is false and basically the rest is true.

If you use === or !== it evaluates to true if both
the types are equal AND the statement is true.

So, the correct syntax would be

if (false === ($customer_id = $db->getone("..."))) {
error handling.
}

Example from the manual:
// in PHP 4.0b3 and newer:
$pos = strrpos($mystring, "b");
if ($pos === false) { // note: three equal signs
// not found...
}

By doing this, strrpos can return 0 (not an error) or
false (not found). Without === strrpos would have to
return -1 or some other illegal position for not found.

Best regards,
Marcus

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:44 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com