Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > desc $table in DBI Oracle

Reply
Thread Tools

desc $table in DBI Oracle

 
 
ngoc
Guest
Posts: n/a
 
      08-01-2005
Hi
I use "my $header_sql = qq { desc $table };". It does not work.
But "select column_name from all_tab_columns where table_name =
\'$table\'" work.
My problem is "desc $table" matching which "select * from $table"
than
select column_name ...........
(I mean data and column name order matching).
Thanks
 
Reply With Quote
 
 
 
 
ngoc
Guest
Posts: n/a
 
      08-01-2005
Sorry. I was lazy to type, because I write to newsgroup on another
computer than my perl program computer.


Code:
my $header_sql = qq {
select
column_name
from
all_tab_columns
where
table_name = \'$selected_table\'
};

my $csr = $db_handle->prepare($header_sql)
or die("Could not prepare : $db_handle->errstr\n");
$csr->execute()
or die("Could not execute : $db_handle->errstr\n");
while (my $row = $csr->fetchrow()) {
push @header, $row;
};
$csr->finish;
NO PROBLEM

I TRIED

my $header_sql = qq { desc $sel_table };

my $csr = $db_handle->prepare($header_sql)
or die("Could not prepare : $db_handle->errstr\n");
$csr->execute()
or die("Could not execute : $db_handle->errstr\n");
while (my $row = $csr->fetchrow()) {
push @header, $row;
};
$csr->finish;


Error: Could not execute : ORA-00900: invalid SQL statement (DBD ERROR:
OCIStmtExecute)

Paul Lalli wrote:
> ngoc wrote:
>
>>Hi
>>I use "my $header_sql = qq { desc $table };". It does not work.

>
>
> "does not work" is a remarkably poor error description. How does it
> not work? Compile error? Runtime error? Output you weren't
> expecting?
>
> Have you read the posting guildelines for this group?
>
>
>>But "select column_name from all_tab_columns where table_name =
>>\'$table\'" work.
>>My problem is "desc $table" matching which "select * from $table"
>>than
>>select column_name ...........
>>(I mean data and column name order matching).

>
>
> Please post a *short* but *complete* script that we can run by copy and
> pasting which illustrates the problem you are having.
>
> Paul Lalli
>

 
Reply With Quote
 
 
 
 
ngoc
Guest
Posts: n/a
 
      08-01-2005
Sorry. I was lazy to type, because I write to newsgroup on another
computer than my perl program computer.


Code:
my $header_sql = qq {
select
column_name
from
all_tab_columns
where
table_name = \'$selected_table\'
};

my $csr = $db_handle->prepare($header_sql)
or die("Could not prepare : $db_handle->errstr\n");
$csr->execute()
or die("Could not execute : $db_handle->errstr\n");
while (my $row = $csr->fetchrow()) {
push @header, $row;
};
$csr->finish;
NO PROBLEM

I TRIED

my $header_sql = qq { desc $selected_table };

my $csr = $db_handle->prepare($header_sql)
or die("Could not prepare : $db_handle->errstr\n");
$csr->execute()
or die("Could not execute : $db_handle->errstr\n");
while (my $row = $csr->fetchrow()) {
push @header, $row;
};
$csr->finish;


Error: Could not execute : ORA-00900: invalid SQL statement (DBD ERROR:
OCIStmtExecute)

Paul Lalli wrote:
> ngoc wrote:
>
>>Hi
>>I use "my $header_sql = qq { desc $table };". It does not work.

>
>
> "does not work" is a remarkably poor error description. How does it
> not work? Compile error? Runtime error? Output you weren't
> expecting?
>
> Have you read the posting guildelines for this group?
>
>
>>But "select column_name from all_tab_columns where table_name =
>>\'$table\'" work.
>>My problem is "desc $table" matching which "select * from $table"
>>than
>>select column_name ...........
>>(I mean data and column name order matching).

>
>
> Please post a *short* but *complete* script that we can run by copy and
> pasting which illustrates the problem you are having.
>
> Paul Lalli
>

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-01-2005
ngoc wrote:
> Hi
> I use "my $header_sql = qq { desc $table };". It does not work.


"does not work" is a remarkably poor error description. How does it
not work? Compile error? Runtime error? Output you weren't
expecting?

Have you read the posting guildelines for this group?

> But "select column_name from all_tab_columns where table_name =
> \'$table\'" work.
> My problem is "desc $table" matching which "select * from $table"
> than
> select column_name ...........
> (I mean data and column name order matching).


Please post a *short* but *complete* script that we can run by copy and
pasting which illustrates the problem you are having.

Paul Lalli

 
Reply With Quote
 
ngoc
Guest
Posts: n/a
 
      08-01-2005
$selected_table is the table name. I am sure table name is correct.
Brian Wakem wrote:
> ngoc wrote:
>
>
>> my $header_sql = qq { desc $selected_table };
>>
>> my $csr = $db_handle->prepare($header_sql)
>> or die("Could not prepare : $db_handle->errstr\n");
>> $csr->execute()
>> or die("Could not execute : $db_handle->errstr\n");
>> while (my $row = $csr->fetchrow()) {
>> push @header, $row;
>> };
>> $csr->finish;
>>
>>
>>Error: Could not execute : ORA-00900: invalid SQL statement (DBD ERROR:
>>OCIStmtExecute)

>
>
>
> What does $selected_table contain? Have you checked to see if it contains
> exactly what you thought?
>
> I'm not familiar with oracle, is 'desc tablename' valid syntax? You need to
> use "DESCRIBE tablename" in some DBs I believe?
>
>

 
Reply With Quote
 
Brian Wakem
Guest
Posts: n/a
 
      08-01-2005
ngoc wrote:

> my $header_sql = qq { desc $selected_table };
>
> my $csr = $db_handle->prepare($header_sql)
> or die("Could not prepare : $db_handle->errstr\n");
> $csr->execute()
> or die("Could not execute : $db_handle->errstr\n");
> while (my $row = $csr->fetchrow()) {
> push @header, $row;
> };
> $csr->finish;
>
>
> Error: Could not execute : ORA-00900: invalid SQL statement (DBD ERROR:
> OCIStmtExecute)



What does $selected_table contain? Have you checked to see if it contains
exactly what you thought?

I'm not familiar with oracle, is 'desc tablename' valid syntax? You need to
use "DESCRIBE tablename" in some DBs I believe?


--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
 
Reply With Quote
 
ngoc
Guest
Posts: n/a
 
      08-01-2005
The second message is the correct one. I deleted the previous one. Maybe
you have to refresh your news program.
Paul Lalli wrote:
> ngoc wrote:
>
>>Sorry. I was lazy to type, because I write to newsgroup on another
>>computer than my perl program computer.

>
>
> You just posted the same message twice, but with a significant
> difference to the code. In your previous post, you were using
> $selected_table in the first query, but $sel_table in the second.
> Which is it?
>
> Please post a short-but-*complete* script, so we can see exactly where
> all of your variables are being assigned. Otherwise, we have no way of
> verifying what you're telling us.
>
> Paul Lalli
>

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-01-2005
ngoc wrote:
> Sorry. I was lazy to type, because I write to newsgroup on another
> computer than my perl program computer.


You just posted the same message twice, but with a significant
difference to the code. In your previous post, you were using
$selected_table in the first query, but $sel_table in the second.
Which is it?

Please post a short-but-*complete* script, so we can see exactly where
all of your variables are being assigned. Otherwise, we have no way of
verifying what you're telling us.

Paul Lalli

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      08-01-2005
ngoc wrote:
> The second message is the correct one. I deleted the previous one. Maybe
> you have to refresh your news program.


Maybe you need to learn how Usenet works. There is no "delete" of
posts. Once you've sent it, you sent it. You can request that servers
don't archive it, but they're under no obligation to follow that
request. Whatever program you're using that gave you the option of
"deleting" your post was flat out lying to you.

Paul Lalli

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      08-01-2005
ngoc <(E-Mail Removed)> wrote:
> Hi
> I use "my $header_sql = qq { desc $table };". It does not work.
> But "select column_name from all_tab_columns where table_name =
> \'$table\'" work.
> My problem is "desc $table" matching which "select * from $table"
> than
> select column_name ...........
> (I mean data and column name order matching).
> Thanks


I believe, but am not certain, that "desc" is not valid Oracle SQL syntax.
Rather, it is a command to the oracle tool SQLPLUS. So when you are using
SQLPLUS, it intercepts the desc command and processes it itself. Since
perl is connecting directly to Oracle, not via SQLPLUS, then the command
does not work from Perl.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNLP installer-desc question Roedy Green Java 2 02-03-2006 11:20 PM
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 230. Feyruz Perl Misc 4 10-14-2005 06:47 PM
how to load a picture to an oracle database with theLoad a pictureto Oracle with DBI perl module Vincent Le-Texier Perl Misc 1 12-03-2004 03:29 PM
DBI and DBI::Oracle packages configuration ulloa Perl 1 07-22-2004 05:52 PM
DataGrid within scrollbar/Header must not scroll/Sorting on asc and desc VSK ASP .Net 1 10-21-2003 04:14 PM



Advertisments