Re: [ROOT] TOracleServer: problem with `describe' query

From: Dmitri Litvintsev (litvinse@fnal.gov)
Date: Wed May 09 2001 - 17:04:30 MEST


Hi Pasha,


On Tue, 8 May 2001, Pasha Murat (630)840-8237@169G wrote:

> - Original TOracleServer::GetTables assumes that all the tables are described in
>   the table called `sys.usr_tables'. Its equivalent in CDF Oracle DB is calles
>   `all_tables'. May be the name of this table needs to be made a configurable
>   parameter?


    you can use sys.user_tables and sys.all_tables in CDF DB as well. I
guess these are standard names, and user_tables(all_tables) is a synonym
for sys.user_tables (sys.all_tables);


>
> - now - the problem. below you find slightly modified source of the test_sql example,
>   which comes with the original distribution. I found, that I can successfully issue
>   `select' query, however `describe' query fails.

  "describe" command is PL/SQL specific, that is not a part of SQL standard, so the statement:

    "ORA-00900: invalid SQL statement"

is correct and does not reflect an error on the part of the underlying
ROOT Oracle API, but reflects a user error :).


regards,
Dmitri Litvintsev

/----------------------------------------------------------\
| Tel:       (630) 840 5005                                |
| FAX:       (630) 840 2968                                |
| office:    169-E CDF Trailers                            |
| E-mail:    litvinse@fnal.gov                             |
\----------------------------------------------------------/




>
>   Wondering if somebody by chance has a clue about what I'm doing wrong...
>
> 							-thanks, Pasha
>
> -----------------------------------------------------
> root [15] test_sql("select TABLE_NAME FROM all_tables where TABLE_NAME LIKE 'L3%'")
> TOracleServer begin
> L3_CALIBS
> L3_CUT_AND_PARAMETERS
> L3_EXES
> L3_OPTION_CLASSES
> L3_OPTION_CLASSES_L3_TALKTOS
> L3_OPTION_INSTANCES
> L3_OPTION_SEQUENCES
> L3_TALKTOS
> L3_TCLS
> L3PCS
> L3PCUPDATES
> end
> root [16] test_sql("describe all_tables")
> TOracleServer begin
>
> ORA-00900: invalid SQL statement
>
> Parse error at character offset 0 in SQL statement.
> end
>
> ------------------------------------------------------------------------------
> void test_sql(const char* query) {
> 					// any legal SQL statement, for example
>
>   char * sql="select table_name from all_tables";
>
> 					/*connect with oracle server */
>
>   TSQLServer *db=TSQLServer::Connect("oracle://cdfora.fnal.gov:1521/cdf.fnal.gov",
> 				     "hod","konem");
>   TSQLRow*     row1;
>   TSQLResult*  res=db->Query(query);
>   if (! res) goto EXIT;
> 					/*print rows one by one */
>   while (row1 = res->Next()) {
>     TOracleRow*  row2 = (TOracleRow*)row1;
>     for (int i=0; i<res->GetFieldCount();i++) {
>       int j=row2->GetFieldType(i);
>       switch(j) {
>       case 3:
> 	printf("%*d ",row2->GetFieldLength(i),*(int*)row2->GetFieldData(i));
> 	break;
>       case 4:
> 	printf("%*.2f",row2->GetFieldLength(i),*(float*)row2->GetFieldData(i));
>   	break;
>       default:
> 	printf("%*.*s",
> 	       row2->GetFieldLength(i),
> 	       row2->GetFieldLength(i),
> 	       row2->GetFieldData(i));
>       }
>     }
>     cout<<endl;
>     delete row1;
>   }
>
>  EXIT:;
>   printf("end \n");
>   delete res;
>   delete db;
> }
> ------------------------------------------------------------------------
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:44 MET