Skip to Main Content

SQLcl

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Is it possible to retrieve content only with 'sqlformat json output', i.e. not include metadata?

3272816Nov 8 2018 — edited Nov 9 2018

Are there any settings, or combination of settings, in sqlci that would eliminate metadata {"results"} - providing content only?

test case

drop table example;

create table example (pk numeric, description varchar2(50));

insert into example values (1, 'First');

insert into example values (2, 'Second');

commit;

set sqlformat json

select * from example;

What sqlci returns:

{"results":[{"columns":[{"name":"PK","type":"NUMBER"},{"name":"DESCRIPTION","type":"VARCHAR2"}],"items":

[

{"pk":1,"description":"First"}

,{"pk":2,"description":"Second"}

]}]}

Desired output:

{"pk":1,"description":"First"}

,{"pk":2,"description":"Second"}

Regards

This post has been answered by Gaz in Oz on Nov 9 2018
Jump to Answer

Comments

TPD-Opitz

b84d6217-63ff-4b01-ac20-dedb366b9b09 wrote:

Hi guys,

I have a simple doubt. I was studying and create some code to check the result and I found out a strange situation.

since you postsd uncompilable code we cannot tell what's really goning on in your example. please always post an SSCCE. http://sscce.org

Whats wrong with this code? Why it does not print anything?

char = 0; //integer value

System.out.println( c +" String ");

You ran in the beginners trap of not distinguishing between numbers as they are used by the Computer and human readable characters.

Java converts numbers to human readable characters when ever it can. But when you declare a variable of type char than you are telling the JVM you want to do this conversion yourself.

According to the ASCII Standard the decimal value 0 is a non printable character.

and why this next works very well?

char = 1; //integer value

System.out.println( c +" String ");

this is also "not working".  depending on the terminal you use you may get something to see but according to the ASCII Standard it should also not print to Screen.

I know that char is stored as a positive integer and assign with 0 is different of assign with '0'.

But you are not Aware that

char c;

is different from

int c;

public class CharPlusStringTest {

@Test
public void test0() {
  char c= 0; //integer value
  System.out.println( ">"+c +"< String ");
}

@Test
public void test1() {
  char c= 1; //integer value
  System.out.println( ">"+c +"< String ");
}

@Test
public void test3() {
  int c= 1; //integer value
  System.out.println( ">"+c +"< String ");
}
}

bye

TPD

1 - 1

Post Details

Added on Nov 8 2018
4 comments
160 views