Hi Luke, Thanks a lot. It really helps.
Kamal. On Wed, Jun 28, 2017 at 8:29 PM, Lukas Eder <[email protected]> wrote: > Hi Kamal, > > 2017-06-28 16:48 GMT+02:00 Kamal raj <[email protected]>: > >> Hi Luke, >> >> May be this is a novice question. I did the following code: >> >> *String sql = "SELECT DISTINCT TABLE_NAME FROM information_schema.columns >> WHERE table_schema = 'employees'";* >> > > May I suggest using this query instead, then: > > SELECT table_name FROM information_schema.tables WHERE table_schema = > 'employees'; > > > It'll certainly run faster for large schemas. > > *Result<Record> result = context.fetch(sql);* >> *System.out.println(result.size());* >> >> *for(Record a : result) {* >> * System.out.println(a.valuesRow().toString());* >> *}* >> >> The result looks like: >> >> *('current_dept_emp')* >> >> *('departments')* >> >> *('dept_emp')* >> >> >> I'm wondering why the parenthesis and quotes comes with the string. >> > Yes, that's how an org.jooq.Row renders itself as a SQL string. The Row > type corresponds to the SQL row value expression (i.e. when you want to > work with tuples, such as row(A, B).eq(1, 2) in jOOQ). All jOOQ QueryPart > types generally produce a workable SQL string when you call toString() on > them. > > What you wanted is simply a.get(0), instead: > > Result<Record> result = context.fetch(sql); > System.out.println(result.size()); > > for(Record a : result) { > System.out.println(a.get(0, String.class)); > } > > > Notice that I think a much better solution would be to fetch everything in > a single query and turn that into a Map<String, Result> as follows: > > Map<?, Result<Record>> result = context.resultQuery(sql). > fetchGroups("table_name"); > for (Entry<?, Result<Record>> entry : result.entrySet()) { > System.out.println(entry.getKey()); > > System.out.println(entry.getValue()); > > System.out.println(); > > } > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "jOOQ User Group" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/jooq-user/TiP_Pj5kN68/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
