Skip to content

Commit

Permalink
readme example update
Browse files Browse the repository at this point in the history
  • Loading branch information
denizzzka committed Apr 19, 2015
1 parent 90dd91e commit 21c0311
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,33 @@ void main()
// Separated arguments query with binary result:
queryParams p;
p.sqlCommand = "SELECT "
"$1::double precision, "
"$2::timestamp with time zone, "
"$1::double precision as double_field, "
"$2::timestamp with time zone as time_field, "
"$3::text, "
"$4::text, "
"$5::integer[]";
"$4::text as null_field, "
"array['first', 'second', NULL]::text[] as array_field, "
"$5::integer[] as multi_array";
p.args.length = 5;
p.args[0].value = "-1234.56789012345";
p.args[1].value = "2012-10-04 11:00:21.227803+08";
p.args[2].value = "first line\nsecond line";
p.args[3].value = null;
p.args[4].value = "{1, 2, NULL}";
p.args[4].value = "{{1, 2, 3}, {4, 5, 6}}";
auto r = conn.exec(p);
writeln( "0: ", r[0][0].as!PGdouble_precision );
writeln( "1: ", r[0][1].as!PGtime_stamp.toSimpleString );
writeln( "0: ", r[0]["double_field"].as!PGdouble_precision );
writeln( "1: ", r[0]["time_field"].as!PGtime_stamp.toSimpleString );
writeln( "2: ", r[0][2].as!PGtext );
writeln( "3 isNULL: ", r[0].isNULL(3) );
writeln( "4.1: ", r[0][4].asArray.getValue(1).as!PGinteger );
writeln( "4.2: ", r[0][4].asArray.isNULL(0) );
writeln( "4.3: ", r[0][4].asArray.isNULL(2) );
writeln( "3.1 isNull: ", r[0][3].isNull );
writeln( "3.2 isNULL: ", r[0].isNULL(3) );
writeln( "4.1: ", r[0][4].asArray[0].as!PGtext );
writeln( "4.2: ", r[0][4].asArray[1].as!PGtext );
writeln( "4.3: ", r[0]["array_field"].asArray[2].isNull );
writeln( "4.4: ", r[0]["array_field"].asArray.isNULL(2) );
writeln( "5: ", r[0]["multi_array"].asArray.getValue(1, 2).as!PGinteger );
version(LDC) delete r; // before Derelict unloads its bindings (prevents SIGSEGV)
}
Expand All @@ -93,10 +97,13 @@ Text query result: 456.78
1: 0013-Oct-05 03:00:21.227803Z
2: first line
second line
3 isNULL: true
4.1: 2
4.2: false
3.1 isNull: true
3.2 isNULL: true
4.1: first
4.2: second
4.3: true
4.4: true
5: 6
```

TODO
Expand Down

0 comments on commit 21c0311

Please sign in to comment.