Unix Technical Forum

temp tables

This is a discussion on temp tables within the pgsql Novice forums, part of the PostgreSQL category; --> hi, im working with php 4 and postgresql 8 and in my php script id like to create a ...


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, 08:46 PM
Cima
 
Posts: n/a
Default temp tables

hi,

im working with php 4 and postgresql 8 and in my php script id like to create a temp table on my database server. how do i do this? how do i verify it was created?

i tried the following:

$sql = "create temp table s_info(a int, b text) on commit delete rows ";

pg_query($dbh,$sql);


$dbh is my connection.

any help will be highly appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:46 PM
John DeSoi
 
Posts: n/a
Default Re: temp tables


On Apr 28, 2005, at 12:45 AM, Cima wrote:

>
> im working with php 4 and postgresql 8 and in my php script id like to
> create a temp table on my database server. how do i do this? how do i
> verify it was created?
> *
> i tried the following:
> *
> $sql = "create temp table s_info(a int, b text) on commit delete
> rows*";
> *
> pg_query($dbh,$sql);
> *
> *
> $dbh is my connection.
> *
> any help will be highly appreciated.



You can verify it was created by checking the result from pg_query and
looking at pg_last_error. The table is automatically dropped at the end
of the connection, most likely when your PHP script ends.


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 08:46 PM
Richard Lynch
 
Posts: n/a
Default Re: [PHP] temp tables

On Wed, April 27, 2005 9:45 pm, Cima said:
> im working with php 4 and postgresql 8 and in my php script id like to
> create a temp table on my database server. how do i do this? how do i
> verify it was created?
>
> i tried the following:
>
> $sql = "create temp table s_info(a int, b text) on commit delete rows ";
>
> pg_query($dbh,$sql);
>
>
> $dbh is my connection.


Did it print an error message?

What was the return value of pg_query()?

Did you check http://php.net/pg_last_error

What happens if you then do:
$sql = "insert into s_info(a, b) values(1, 'Test')";
pg_query($dbh, $sql) or die(pg_last_error());

$sql = "select * from s_info";
$sinfo = pg_query($dbh, $sql) or die(pg_last_error());
$srow = 0;
while (list($a, $b) = @pg_fetch_row($sinfo, $srow++)){
echo "a: $a b: $b<br />\n";
}

What makes you think it didn't work?

--
Like Music?
http://l-i-e.com/artists.htm


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 08:46 PM
Joshua D. Drake
 
Posts: n/a
Default Re: [PHP] temp tables

Cima wrote:
> hi,
>
> im working with php 4 and postgresql 8 and in my php script id like to create a temp table on my database server. how do i do this? how do i verify it was created?
>


Well if the creation fails pg_query will throw an error. However temp
tables are only good for the life of the connection (script in this
case). You will probably want to consider that.

Sincerely,

Joshua D. Drake



> i tried the following:
>
> $sql = "create temp table s_info(a int, b text) on commit delete rows ";
>
> pg_query($dbh,$sql);
>
>
> $dbh is my connection.
>
> any help will be highly appreciated.



--
Your PostgreSQL solutions provider, Command Prompt, Inc.
24x7 support - 1.800.492.2240, programming, and consulting
Home of PostgreSQL Replicator, plPHP, plPerlNG and pgPHPToolkit
http://www.commandprompt.com / http://www.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

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 05:17 AM.


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