Home » Open Source » Programming Interfaces » ORACLE - PHP Issue
ORACLE - PHP Issue [message #164653] Fri, 24 March 2006 09:27 Go to next message
larevanche64
Messages: 4
Registered: March 2006
Junior Member
Dear all,

I would like to create a table using a variable :

$id_ses = "pws_tmp_".$id_session;

$query = 'create table ".$id_ses." (test(40))';


I have tried several ways for the syntax of the create table but it does not work.
I have also tested OCIBindByName function but I cant find the solution.

Could you please help me on this?

Thanks in advance for your support

Cheers,

Juan
Re: ORACLE - PHP Issue [message #164661 is a reply to message #164653] Fri, 24 March 2006 10:03 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
You did not define a datatype.
test(40) means column name test and a length of 40.
This should read
test varchar2(40)

hth
Re: ORACLE - PHP Issue [message #164666 is a reply to message #164661] Fri, 24 March 2006 10:14 Go to previous messageGo to next message
larevanche64
Messages: 4
Registered: March 2006
Junior Member
Thanks Frank,

but it is still not working :

$create_pws_prepro_sc = 'create table '$id_ses' (test varchar2(40))';

the problem seems to be linked to the quotes.

Juan


Frank wrote on Fri, 24 March 2006 10:03

You did not define a datatype.
test(40) means column name test and a length of 40.
This should read
test varchar2(40)

hth

Re: ORACLE - PHP Issue [message #164669 is a reply to message #164666] Fri, 24 March 2006 10:26 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Quote:

$create_pws_prepro_sc = 'create table '$id_ses' (test varchar2(40))';


No dots to concatenate the variable into the statement. A typo?

What error do you get?
Re: ORACLE - PHP Issue [message #164671 is a reply to message #164669] Fri, 24 March 2006 10:41 Go to previous messageGo to next message
larevanche64
Messages: 4
Registered: March 2006
Junior Member
Frank,

my problem is the following : I want to create a table and the name of the table should be a variable.
I do not get any error, it is just not working.

I have tested :

$test = 'create table '$tst_table' (test varchar2(40))';
$test = 'create table "$tst_table" (test varchar2(40))';
...

Thanks for your coop

Juan



Frank wrote on Fri, 24 March 2006 10:26

Quote:

$create_pws_prepro_sc = 'create table '$id_ses' (test varchar2(40))';


No dots to concatenate the variable into the statement. A typo?

What error do you get?

Re: ORACLE - PHP Issue [message #164672 is a reply to message #164671] Fri, 24 March 2006 10:55 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
$test = 'create table '$tst_table' (test varchar2(40))';
$test = 'create table "$tst_table" (test varchar2(40))';
The first line contains a syntax error and should give you the error "Parse error: syntax error, unexpected T_VARIABLE in ..."

Are the contents of your $tst_table variable in uppercase?
Re: ORACLE - PHP Issue [message #164794 is a reply to message #164672] Sun, 26 March 2006 10:30 Go to previous messageGo to next message
larevanche64
Messages: 4
Registered: March 2006
Junior Member
Frank,

My problem is not depending on my variable (same problem : lowercas / uppercase).

It is just a syntax issue : I need to know the correct syntax to create a table using a variable name.

Juan
Re: ORACLE - PHP Issue [message #164805 is a reply to message #164653] Sun, 26 March 2006 14:59 Go to previous message
BlackSwan
Messages: 23159
Registered: January 2009
Senior Member
>It is just a syntax issue
It is a PEBKAC issue.
Print out the variable "$test" before passing it to the DB.
If it is OK, you will be able to cut & paste it into SQL*Plus & successfully execute it.
Previous Topic: Oracle and Perl
Next Topic: Connectivity from php to oracle database running on windows NT server
Goto Forum:
  


Current Time: Mon Dec 22 02:02:00 CST 2014

Total time taken to generate the page: 0.13633 seconds