Re: Problem related to Hive using JDBC

2012-03-18 Thread Bhavesh Shah
Thanks Shashwat for your reply.

According your reply, I am getting all column data using
res.getInt/getString for 30 times.
Actually my doubt is in:

sql="select a,c,b from tbl_name";
res=stmt.executeQuery();---> CONTAINS 30 RECORDS
while(res.next())
{
 sql="select d,e,f, from t1";
 rs1=stmt.executeQuery();
 like wise many queries are there.

.
.
.
..
}
This above syntax is execute only once instead of 30 times.
Thats what my doubt is?




On Sat, Mar 17, 2012 at 4:26 PM, shashwat shriparv <
dwivedishash...@gmail.com> wrote:

>  S.O.P.("fields : "+res.getString(0));
> according type of your fields you can acc more res.getint(1)
> res.getString(2) like this up to 30 so this will give all the columns you
> needed.
>
>
>
> On Fri, Mar 16, 2012 at 11:17 AM, Bhavesh Shah wrote:
>
>>
>> Hi,
>> I am trying to implement a task in Hive like Stored Procedure in SQL.
>> In SQL, when we write cursor, first we execute select query and then
>> fetching the records we perform some actions.
>>
>> Likely I have fired a select query as actions in Hive.
>> sql="select a,c,b from tbl_name";
>> res=stmt.executeQuery();---> CONTAINS 30 RECORDS
>> while(res.next())
>> {
>>  sql="insert into tabl2. ";
>>  rs1=stmt.executeQuery();
>>  like wise many queries are there.
>>
>> .
>> .
>> .
>> ..
>> }
>>
>> As my select query contans 30 records but when I execute it   my
>> while(res.next()) execute only once.
>> I didn't get any kind of errors/exceptions
>>
>> But instead of queries I just try to display field to check whether it is
>> fetching or not
>> then it is working fine..  (while loop contains only System.out.println
>> statements)
>>
>> sql="select * from tbl_name";
>> res=stmt.executeQuery(sql);
>>
>> while(res.next())
>> {
>>S.O.P.("fields : "+res.getString(0));
>> }
>>
>> Why it is happening I am not getting. Is anything I am doing wrong?
>>
>>
>>
>>
>>
>>
>> --
>> Regards,
>> Bhavesh Shah
>>
>>
>
>
> --
> Shashwat Shriparv
>
> +91-9663531241
> +91-990059620
>
>


-- 
Regards,
Bhavesh Shah


Re:Re: update a hive table

2012-03-18 Thread Richard
I see, thanks.




At 2012-03-16 20:30:24,"Bejoy Ks"  wrote:

Hi Robert,
Sorry I missed answering your question
>If mytable has many columns but I only need to update one of them, how can I 
>write the
>statement short?
It is not possible in hive. At a bare minimum hive would overwrite a partition 
(not even a record/file) if you frame an optimized query.



Hope it helps!...


Regards
Bejoy.K.S


From: Bejoy Ks 
To: "user@hive.apache.org" 
Sent: Friday, March 16, 2012 5:56 PM
Subject: Re: update a hive table



Hey Richard
 First, don't treat hive as a database. Hive is just an interface above 
map reduce that help you write SQL like queries that inturn is converted to MR 
jobs. Saying that hive doesn't support update. 


If you are just experimenting, the query that you wrote would overwrite a whole 
record (in a broader context a whole partion/table)


Regards
Bejoy.K.S


From: Richard 
To:user@hive.apache.org
Sent: Friday, March 16, 2012 4:26 PM
Subject: update a hive table



if I wang to update a table, e.g,
 
insert overwrite table mytable
select lower(col1), col2, col3 from mytable;
 
if mytable has many columns but I only need to update one of them, how can I 
write the
statement short?